sim, kvm: make KvmVM a System parameter
[gem5.git] / src / cpu / kvm / vm.cc
index d3ab8c45a6c08b19b1908ba3c831dedcb8ddc671..604d182ab2e5fe0057bbe9dfe42956f9aa04af42 100644 (file)
@@ -292,7 +292,7 @@ Kvm::createVM()
 
 KvmVM::KvmVM(KvmVMParams *params)
     : SimObject(params),
-      kvm(new Kvm()), system(params->system),
+      kvm(new Kvm()), system(nullptr),
       vmFD(kvm->createVM()),
       started(false),
       nextVCPUID(0)
@@ -342,6 +342,7 @@ KvmVM::cpuStartup()
 void
 KvmVM::delayedStartup()
 {
+    assert(system); // set by the system during its construction
     const std::vector<BackingStoreEntry> &memories(
         system->getPhysMem().getBackingStore());
 
@@ -526,6 +527,13 @@ KvmVM::createDevice(uint32_t type, uint32_t flags)
 #endif
 }
 
+void
+KvmVM::setSystem(System *s) {
+    panic_if(system != nullptr, "setSystem() can only be called once");
+    panic_if(s == nullptr, "setSystem() called with null System*");
+    system = s;
+}
+
 int
 KvmVM::createVCPU(long vcpuID)
 {