summaryrefslogtreecommitdiff
path: root/src/cpu/kvm/vm.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/kvm/vm.cc')
-rw-r--r--src/cpu/kvm/vm.cc26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/cpu/kvm/vm.cc b/src/cpu/kvm/vm.cc
index 87a76c242..ccf739305 100644
--- a/src/cpu/kvm/vm.cc
+++ b/src/cpu/kvm/vm.cc
@@ -291,12 +291,12 @@ Kvm::createVM()
KvmVM::KvmVM(KvmVMParams *params)
: SimObject(params),
- kvm(), system(params->system),
- vmFD(kvm.createVM()),
+ kvm(new Kvm()), system(params->system),
+ vmFD(kvm->createVM()),
started(false),
nextVCPUID(0)
{
- maxMemorySlot = kvm.capNumMemSlots();
+ maxMemorySlot = kvm->capNumMemSlots();
/* If we couldn't determine how memory slots there are, guess 32. */
if (!maxMemorySlot)
maxMemorySlot = 32;
@@ -307,7 +307,25 @@ KvmVM::KvmVM(KvmVMParams *params)
KvmVM::~KvmVM()
{
- close(vmFD);
+ if (vmFD != -1)
+ close(vmFD);
+
+ if (kvm)
+ delete kvm;
+}
+
+void
+KvmVM::notifyFork()
+{
+ if (vmFD != -1) {
+ if (close(vmFD) == -1)
+ warn("kvm VM: notifyFork failed to close vmFD\n");
+
+ vmFD = -1;
+
+ delete kvm;
+ kvm = NULL;
+ }
}
void