Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
the implementation should not mess with the fields of the interface
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 21 Nov 2016 01:09:45 +0000 (02:09 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 21 Nov 2016 01:09:45 +0000 (02:09 +0100)
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/VirtualMachineImpl.hpp
src/plugins/vm/s4u_VirtualMachine.cpp

index 51e42ef..93dd5d2 100644 (file)
@@ -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<CpuCas01*>(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;
index b13f3e7..06d413e 100644 (file)
@@ -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;
index f46ee37..13357ef 100644 (file)
@@ -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<surf::CpuCas01*>(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<simgrid::simix::Host>(new simgrid::simix::Host());
 
   if (TRACE_msg_vm_is_enabled()) {