From 3d4b8c836d627f90b4113e9f3709167a28cf5233 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 21 Nov 2016 02:09:45 +0100 Subject: [PATCH] the implementation should not mess with the fields of the interface --- src/plugins/vm/VirtualMachineImpl.cpp | 18 +----------------- src/plugins/vm/VirtualMachineImpl.hpp | 2 +- src/plugins/vm/s4u_VirtualMachine.cpp | 13 ++++++++++++- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 51e42efd6d..93dd5d206e 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -104,25 +104,9 @@ VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::Host* piface, simgrid::s4u: /* Register this VM to the list of all VMs */ allVms_.push_back(this); - /* Currently, a VM uses the network resource of its physical host. In - * host_lib, this network resource object is referred from two different keys. - * When deregistering the reference that points the network resource object - * from the VM name, we have to make sure that the system does not call the - * free callback for the network resource object. The network resource object - * is still used by the physical machine. */ - piface_->pimpl_netcard = host_PM->pimpl_netcard; - - // //// CPU RELATED STUFF //// - // Roughly, create a vcpu resource by using the values of the sub_cpu one. - CpuCas01* sub_cpu = dynamic_cast(host_PM->pimpl_cpu); - - piface_->pimpl_cpu = surf_cpu_model_vm->createCpu(piface_, sub_cpu->getSpeedPeakList(), 1 /*cores*/); - if (sub_cpu->getPState() != 0) - piface_->pimpl_cpu->setPState(sub_cpu->getPState()); - /* We create cpu_action corresponding to a VM process on the host operating system. */ /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */ - action_ = sub_cpu->execution_start(0); + action_ = host_PM->pimpl_cpu->execution_start(0); /* Initialize the VM parameters */ params_.ramsize = 0; diff --git a/src/plugins/vm/VirtualMachineImpl.hpp b/src/plugins/vm/VirtualMachineImpl.hpp index b13f3e7450..06d413e311 100644 --- a/src/plugins/vm/VirtualMachineImpl.hpp +++ b/src/plugins/vm/VirtualMachineImpl.hpp @@ -86,7 +86,7 @@ public: void setParams(vm_params_t params); /* The vm object of the lower layer */ - CpuAction* action_ = nullptr; + Action* action_ = nullptr; /* Dirty pages stuff */ int dp_enabled = 0; diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index f46ee37c9a..13357ef955 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -7,11 +7,12 @@ #include "simgrid/s4u/VirtualMachine.hpp" #include "simgrid/s4u/host.hpp" #include "simgrid/simix.hpp" +#include "src/instr/instr_private.h" #include "src/plugins/vm/VirtualMachineImpl.hpp" #include "src/simix/smx_host_private.h" #include "src/surf/HostImpl.hpp" +#include "src/surf/cpu_cas01.hpp" #include "xbt/asserts.h" -#include "src/instr/instr_private.h" XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_vm, "S4U virtual machines"); @@ -23,6 +24,16 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm) : Host(name) XBT_DEBUG("Create VM %s", name); pimpl_vm_ = new surf::VirtualMachineImpl(this, pm); + /* Currently, a VM uses the network resource of its physical host */ + pimpl_netcard = pm->pimpl_netcard; + // Create a VCPU for this VM + surf::CpuCas01* sub_cpu = dynamic_cast(pm->pimpl_cpu); + + pimpl_cpu = surf_cpu_model_vm->createCpu(this, sub_cpu->getSpeedPeakList(), 1 /*cores*/); + if (sub_cpu->getPState() != 0) + pimpl_cpu->setPState(sub_cpu->getPState()); + + /* Make a process container */ extension_set(new simgrid::simix::Host()); if (TRACE_msg_vm_is_enabled()) { -- 2.20.1