Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix host name issue with ns3 wifi, add ssid, set active probing to false
[simgrid.git] / src / plugins / vm / s4u_VirtualMachine.cpp
index c689d2dcce470ef80c677d2ec5498fd6e1853ee8..8c3963ad607c38ebad341122645875284fac3cfa 100644 (file)
@@ -44,6 +44,10 @@ VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host
   surf_cpu_model_vm->create_cpu(this, speeds, core_amount);
   if (physical_host->get_pstate() != 0)
     set_pstate(physical_host->get_pstate());
+
+  // Real hosts are (only) created through NetZone::create_host(), and this where the on_creation signal is fired.
+  // VMs are created directly, thus firing the signal here. The right solution is probably to separate Host and VM.
+  simgrid::s4u::Host::on_creation(*this);
 }
 
 VirtualMachine::~VirtualMachine()
@@ -127,9 +131,10 @@ simgrid::s4u::Host* VirtualMachine::get_pm() const
   return pimpl_vm_->get_physical_host();
 }
 
-void VirtualMachine::set_pm(simgrid::s4u::Host* pm)
+VirtualMachine* VirtualMachine::set_pm(simgrid::s4u::Host* pm)
 {
   kernel::actor::simcall([this, pm]() { pimpl_vm_->set_physical_host(pm); });
+  return this;
 }
 
 VirtualMachine::state VirtualMachine::get_state()
@@ -142,9 +147,10 @@ size_t VirtualMachine::get_ramsize() const
   return pimpl_vm_->get_ramsize();
 }
 
-void VirtualMachine::set_ramsize(size_t ramsize)
+VirtualMachine* VirtualMachine::set_ramsize(size_t ramsize)
 {
   pimpl_vm_->set_ramsize(ramsize);
+  return this;
 }
 /** @brief Set a CPU bound for a given VM.
  *  @ingroup msg_VMs
@@ -172,9 +178,10 @@ void VirtualMachine::set_ramsize(size_t ramsize)
  * 2. Note that bound == 0 means no bound (i.e., unlimited). But, if a host has multiple CPU cores, the CPU share of a
  *    computation task (or a VM) never exceeds the capacity of a CPU core.
  */
-void VirtualMachine::set_bound(double bound)
+VirtualMachine* VirtualMachine::set_bound(double bound)
 {
   kernel::actor::simcall([this, bound]() { pimpl_vm_->set_bound(bound); });
+  return this;
 }
 
 } // namespace simgrid