Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
store the VMs by their interface, not by their implementation
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 21 Nov 2016 07:22:08 +0000 (08:22 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 21 Nov 2016 07:22:08 +0000 (08:22 +0100)
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/VirtualMachineImpl.hpp
src/simix/smx_vm.cpp
src/surf/HostImpl.cpp

index 931e00c..b01ab0a 100644 (file)
@@ -38,7 +38,7 @@ simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmStateChange;
  * Model *
  *********/
 
  * Model *
  *********/
 
-std::deque<VirtualMachineImpl*> VirtualMachineImpl::allVms_;
+std::deque<s4u::VirtualMachine*> VirtualMachineImpl::allVms_;
 
 /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
  * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system. */
 
 /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
  * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system. */
@@ -72,13 +72,13 @@ double VMModel::nextOccuringEvent(double now)
    **/
 
   /* iterate for all virtual machines */
    **/
 
   /* iterate for all virtual machines */
-  for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
-    Cpu* cpu = ws_vm->piface_->pimpl_cpu;
+  for (s4u::VirtualMachine* ws_vm : VirtualMachineImpl::allVms_) {
+    Cpu* cpu = ws_vm->pimpl_cpu;
     xbt_assert(cpu, "cpu-less host");
 
     xbt_assert(cpu, "cpu-less host");
 
-    double solved_value = ws_vm->action_->getVariable()->value;
-    XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->piface_->name().c_str(),
-              ws_vm->getPm()->name().c_str());
+    double solved_value = ws_vm->pimpl_vm_->action_->getVariable()->value;
+    XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->name().c_str(),
+              ws_vm->pimpl_vm_->getPm()->name().c_str());
 
     // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
     // cpu_cas01->constraint->bound = solved_value;
 
     // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
     // cpu_cas01->constraint->bound = solved_value;
@@ -98,11 +98,11 @@ double VMModel::nextOccuringEvent(double now)
  * Resource *
  ************/
 
  * Resource *
  ************/
 
-VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::Host* piface, simgrid::s4u::Host* host_PM)
+VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM)
     : HostImpl(piface, nullptr /*storage*/), hostPM_(host_PM)
 {
   /* Register this VM to the list of all VMs */
     : HostImpl(piface, nullptr /*storage*/), hostPM_(host_PM)
 {
   /* Register this VM to the list of all VMs */
-  allVms_.push_back(this);
+  allVms_.push_back(piface);
 
   /* 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 ? */
 
   /* 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 ? */
@@ -120,7 +120,7 @@ extern "C" int
 VirtualMachineImpl::~VirtualMachineImpl()
 {
   onVmDestruction(this);
 VirtualMachineImpl::~VirtualMachineImpl()
 {
   onVmDestruction(this);
-  allVms_.erase(find(allVms_.begin(), allVms_.end(), this));
+  allVms_.erase(find(allVms_.begin(), allVms_.end(), piface_));
 
   /* dirty page tracking */
   unsigned int size          = xbt_dict_size(dp_objs);
 
   /* dirty page tracking */
   unsigned int size          = xbt_dict_size(dp_objs);
index 06d413e..353f9a9 100644 (file)
@@ -57,7 +57,7 @@ extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)
  */
 class VirtualMachineImpl : public HostImpl {
 public:
  */
 class VirtualMachineImpl : public HostImpl {
 public:
-  explicit VirtualMachineImpl(s4u::Host* piface, s4u::Host* host);
+  explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host);
   ~VirtualMachineImpl();
 
   /** @brief Suspend the VM */
   ~VirtualMachineImpl();
 
   /** @brief Suspend the VM */
@@ -99,7 +99,7 @@ protected:
 public:
   e_surf_vm_state_t getState();
   void setState(e_surf_vm_state_t state);
 public:
   e_surf_vm_state_t getState();
   void setState(e_surf_vm_state_t state);
-  static std::deque<VirtualMachineImpl*> allVms_;
+  static std::deque<s4u::VirtualMachine*> allVms_;
 
   bool isMigrating = false;
 
 
   bool isMigrating = false;
 
index e11f077..429bd5c 100644 (file)
@@ -40,9 +40,9 @@ void SIMIX_vm_start(sg_host_t vm)
   if (pm_ramsize && !pm_overcommit) { /* Only verify that we don't overcommit on need */
     /* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
     long total_ramsize_of_vms = 0;
   if (pm_ramsize && !pm_overcommit) { /* Only verify that we don't overcommit on need */
     /* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
     long total_ramsize_of_vms = 0;
-    for (simgrid::surf::VirtualMachineImpl* ws_vm : simgrid::surf::VirtualMachineImpl::allVms_)
-      if (pm == ws_vm->getPm())
-        total_ramsize_of_vms += ws_vm->getRamsize();
+    for (simgrid::s4u::VirtualMachine* ws_vm : simgrid::surf::VirtualMachineImpl::allVms_)
+      if (pm == ws_vm->pimpl_vm_->getPm())
+        total_ramsize_of_vms += ws_vm->pimpl_vm_->getRamsize();
 
     if (vm_ramsize > pm_ramsize - total_ramsize_of_vms) {
       XBT_WARN("cannnot start %s@%s due to memory shortage: vm_ramsize %ld, free %ld, pm_ramsize %ld (bytes).",
 
     if (vm_ramsize > pm_ramsize - total_ramsize_of_vms) {
       XBT_WARN("cannnot start %s@%s due to memory shortage: vm_ramsize %ld, free %ld, pm_ramsize %ld (bytes).",
index c24abb7..bda7540 100644 (file)
@@ -35,9 +35,9 @@ namespace surf {
 void HostModel::adjustWeightOfDummyCpuActions()
 {
   /* iterate for all virtual machines */
 void HostModel::adjustWeightOfDummyCpuActions()
 {
   /* iterate for all virtual machines */
-  for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
+  for (s4u::VirtualMachine* ws_vm : VirtualMachineImpl::allVms_) {
 
 
-    Cpu* cpu = ws_vm->piface_->pimpl_cpu;
+    Cpu* cpu = ws_vm->pimpl_cpu;
 
     int is_active = lmm_constraint_used(cpu->getModel()->getMaxminSystem(), cpu->getConstraint());
 
 
     int is_active = lmm_constraint_used(cpu->getModel()->getMaxminSystem(), cpu->getConstraint());
 
@@ -47,13 +47,13 @@ void HostModel::adjustWeightOfDummyCpuActions()
 
       /* FIXME: we should use lmm_update_variable_weight() ? */
       /* FIXME: If we assign 1.05 and 0.05, the system makes apparently wrong values. */
 
       /* FIXME: we should use lmm_update_variable_weight() ? */
       /* FIXME: If we assign 1.05 and 0.05, the system makes apparently wrong values. */
-      ws_vm->action_->setPriority(1);
+      ws_vm->pimpl_vm_->action_->setPriority(1);
 
     } else {
       /* no task exits on this VM */
       XBT_DEBUG("set the weight of the dummy CPU action on PM to 0");
 
 
     } else {
       /* no task exits on this VM */
       XBT_DEBUG("set the weight of the dummy CPU action on PM to 0");
 
-      ws_vm->action_->setPriority(0);
+      ws_vm->pimpl_vm_->action_->setPriority(0);
     }
   }
 }
     }
   }
 }