Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Set s4u::VirtualMachine as deprecated
[simgrid.git] / src / kernel / resource / VirtualMachineImpl.cpp
index 9288d0b..9d829de 100644 (file)
@@ -184,10 +184,15 @@ Action* VMModel::execute_thread(const s4u::Host* host, double flops_amount, int
 
 VirtualMachineImpl::VirtualMachineImpl(const std::string& name, s4u::VirtualMachine* piface,
                                        simgrid::s4u::Host* host_PM, int core_amount, size_t ramsize)
-    : HostImpl(name), piface_(piface), physical_host_(host_PM), core_amount_(core_amount), ramsize_(ramsize)
+    : VirtualMachineImpl(name, host_PM, core_amount, ramsize)
+{
+  set_piface(piface);
+}
+
+VirtualMachineImpl::VirtualMachineImpl(const std::string& name, simgrid::s4u::Host* host_PM, int core_amount,
+                                       size_t ramsize)
+    : HostImpl(name), physical_host_(host_PM), core_amount_(core_amount), ramsize_(ramsize)
 {
-  /* Register this VM to the list of all VMs */
-  allVms_.push_back(piface);
   /* We create cpu_action corresponding to a VM process on the host operating system. */
   /* TODO: we have to periodically input GUESTOS_NOISE to the system? how ?
    * The value for GUESTOS_NOISE corresponds to the cost of the global action associated to the VM.  It corresponds to
@@ -200,6 +205,14 @@ VirtualMachineImpl::VirtualMachineImpl(const std::string& name, s4u::VirtualMach
   XBT_VERB("Create VM(%s)@PM(%s)", name.c_str(), physical_host_->get_cname());
 }
 
+void VirtualMachineImpl::set_piface(s4u::VirtualMachine* piface)
+{
+  xbt_assert(not piface_, "Pointer to interface already configured for this VM (%s)", get_cname());
+  piface_ = piface;
+  /* Register this VM to the list of all VMs */
+  allVms_.push_back(piface);
+}
+
 /** @brief A physical host does not disappear in the current SimGrid code, but a VM may disappear during a simulation */
 void VirtualMachineImpl::vm_destroy()
 {