Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
isolate VM migration parameters from others
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 6 Dec 2017 11:23:29 +0000 (12:23 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 6 Dec 2017 11:23:29 +0000 (12:23 +0100)
- overcommit is in VMHostExt
- ncpus is the pimpl coreAmount
- ramsize is added to the pimpl with get/set methods at different levels

Remarks:
 - MSG_vm_(get/set)_params are no longer used
 - the vm_params_t structure should (IMHO) become an extension
   decicated to migration in the plugin

examples/msg/cloud-capping/cloud-capping.c
examples/msg/cloud-masterworker/cloud-masterworker.c
examples/msg/cloud-migration/cloud-migration.c
examples/msg/cloud-simple/cloud-simple.c
include/simgrid/datatypes.h
include/simgrid/msg.h
include/simgrid/s4u/VirtualMachine.hpp
src/msg/msg_vm.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/VirtualMachineImpl.hpp
src/plugins/vm/s4u_VirtualMachine.cpp

index e84ac2c..b27d11e 100644 (file)
@@ -246,10 +246,7 @@ static int master_main(int argc, char *argv[])
 
   vm0 = MSG_vm_create_core(pm0, "VM0");
 
 
   vm0 = MSG_vm_create_core(pm0, "VM0");
 
-  s_vm_params_t params;
-  memset(&params, 0, sizeof(params));
-  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
-  MSG_vm_set_params(vm0, &params);
+  MSG_vm_set_ramsize(vm0, 1e9); // 1GB
   MSG_vm_start(vm0);
 
   cpu_speed = MSG_host_get_speed(pm0);
   MSG_vm_start(vm0);
 
   cpu_speed = MSG_host_get_speed(pm0);
index 86449a4..12044ad 100644 (file)
@@ -83,10 +83,7 @@ static int master_fun(int argc, char *argv[])
     XBT_INFO("create %s on PM(%s)", vm_name, MSG_host_get_name(pm));
     msg_vm_t vm = MSG_vm_create_core(pm, vm_name);
 
     XBT_INFO("create %s on PM(%s)", vm_name, MSG_host_get_name(pm));
     msg_vm_t vm = MSG_vm_create_core(pm, vm_name);
 
-    s_vm_params_t params;
-    memset(&params, 0, sizeof(params));
-    params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes
-    MSG_vm_set_params(vm, &params);
+    MSG_vm_set_ramsize(vm, 1L * 1024 * 1024 * 1024); // 1GiB
 
     MSG_vm_start(vm);
     xbt_dynar_push(vms, &vm);
 
     MSG_vm_start(vm);
     xbt_dynar_push(vms, &vm);
index 29b10c9..5fd2143 100644 (file)
@@ -55,25 +55,21 @@ static int master_main(int argc, char *argv[])
   msg_host_t pm0 = MSG_host_by_name("Fafard");
   msg_host_t pm1 = MSG_host_by_name("Tremblay");
   msg_host_t pm2 = MSG_host_by_name("Bourassa");
   msg_host_t pm0 = MSG_host_by_name("Fafard");
   msg_host_t pm1 = MSG_host_by_name("Tremblay");
   msg_host_t pm2 = MSG_host_by_name("Bourassa");
-  s_vm_params_t params;
-  memset(&params, 0, sizeof(params));
 
   msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
 
   msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
-  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
-  MSG_vm_set_params(vm0, &params);
+  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
   MSG_vm_start(vm0);
 
   MSG_vm_start(vm0);
 
-  XBT_INFO("Test: Migrate a VM with %llu Mbytes RAM", params.ramsize / 1000 / 1000);
+  XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", MSG_vm_get_ramsize(vm0) / 1000 / 1000);
   vm_migrate(vm0, pm1);
 
   MSG_vm_destroy(vm0);
 
   vm0 = MSG_vm_create_core(pm0, "VM0");
   vm_migrate(vm0, pm1);
 
   MSG_vm_destroy(vm0);
 
   vm0 = MSG_vm_create_core(pm0, "VM0");
-  params.ramsize = 1L * 1000 * 1000 * 100; // 100Mbytes
-  MSG_vm_set_params(vm0, &params);
+  MSG_vm_set_ramsize(vm0, 1e8); // 100Mbytes
   MSG_vm_start(vm0);
 
   MSG_vm_start(vm0);
 
-  XBT_INFO("Test: Migrate a VM with %llu Mbytes RAM", params.ramsize / 1000 / 1000);
+  XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", MSG_vm_get_ramsize(vm0) / 1000 / 1000);
   vm_migrate(vm0, pm1);
 
   MSG_vm_destroy(vm0);
   vm_migrate(vm0, pm1);
 
   MSG_vm_destroy(vm0);
@@ -81,9 +77,8 @@ static int master_main(int argc, char *argv[])
   vm0 = MSG_vm_create_core(pm0, "VM0");
   msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
 
   vm0 = MSG_vm_create_core(pm0, "VM0");
   msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
 
-  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
-  MSG_vm_set_params(vm0, &params);
-  MSG_vm_set_params(vm1, &params);
+  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
+  MSG_vm_set_ramsize(vm1, 1e9); // 1Gbytes
   MSG_vm_start(vm0);
   MSG_vm_start(vm1);
 
   MSG_vm_start(vm0);
   MSG_vm_start(vm1);
 
@@ -98,9 +93,8 @@ static int master_main(int argc, char *argv[])
   vm0 = MSG_vm_create_core(pm0, "VM0");
   vm1 = MSG_vm_create_core(pm0, "VM1");
 
   vm0 = MSG_vm_create_core(pm0, "VM0");
   vm1 = MSG_vm_create_core(pm0, "VM1");
 
-  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
-  MSG_vm_set_params(vm0, &params);
-  MSG_vm_set_params(vm1, &params);
+  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
+  MSG_vm_set_ramsize(vm1, 1e9); // 1Gbytes
   MSG_vm_start(vm0);
   MSG_vm_start(vm1);
 
   MSG_vm_start(vm0);
   MSG_vm_start(vm1);
 
index 76dbf94..f576b25 100644 (file)
@@ -234,10 +234,7 @@ static int master_main(int argc, char *argv[])
            " network one");
   XBT_INFO("### Relocate VM0 between PM0 and PM1");
   vm0 = MSG_vm_create_core(pm0, "VM0");
            " network one");
   XBT_INFO("### Relocate VM0 between PM0 and PM1");
   vm0 = MSG_vm_create_core(pm0, "VM0");
-  s_vm_params_t params;
-  memset(&params, 0, sizeof(params));
-  params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes
-  MSG_vm_set_params(vm0, &params);
+  MSG_vm_set_ramsize(vm0, 1L * 1024 * 1024 * 1024); // 1GiB
 
   MSG_vm_start(vm0);
   launch_communication_worker((msg_host_t)vm0, pm2);
 
   MSG_vm_start(vm0);
   launch_communication_worker((msg_host_t)vm0, pm2);
index 815e937..d52d21f 100644 (file)
 #include "simgrid/forward.h"
 
 struct vm_params {
 #include "simgrid/forward.h"
 
 struct vm_params {
-  int ncpus;
-  sg_size_t ramsize;
-  int overcommit;
-
-  /* The size of other states than memory pages, which is out-of-scope of dirty
-   * page tracking. */
+  /* The size of other states than memory pages, which is out-of-scope of dirty page tracking. */
   sg_size_t devsize;
   int skip_stage1;
   int skip_stage2;
   sg_size_t devsize;
   int skip_stage1;
   int skip_stage2;
index 068e469..b4e5304 100644 (file)
@@ -469,6 +469,8 @@ XBT_PUBLIC(int) MSG_vm_is_suspended(msg_vm_t vm);
 XBT_PUBLIC(const char*) MSG_vm_get_name(msg_vm_t vm);
 XBT_PUBLIC(void) MSG_vm_get_params(msg_vm_t vm, vm_params_t params);
 XBT_PUBLIC(void) MSG_vm_set_params(msg_vm_t vm, vm_params_t params);
 XBT_PUBLIC(const char*) MSG_vm_get_name(msg_vm_t vm);
 XBT_PUBLIC(void) MSG_vm_get_params(msg_vm_t vm, vm_params_t params);
 XBT_PUBLIC(void) MSG_vm_set_params(msg_vm_t vm, vm_params_t params);
+XBT_PUBLIC(void) MSG_vm_set_ramsize(msg_vm_t vm, size_t size);
+XBT_PUBLIC(size_t) MSG_vm_get_ramsize(msg_vm_t vm);
 
 // TODO add VDI later
 XBT_PUBLIC(msg_vm_t) MSG_vm_create_core(msg_host_t location, const char *name);
 
 // TODO add VDI later
 XBT_PUBLIC(msg_vm_t) MSG_vm_create_core(msg_host_t location, const char *name);
index 0d6023d..d736b50 100644 (file)
@@ -36,6 +36,7 @@ XBT_PUBLIC_CLASS VirtualMachine : public s4u::Host
 
 public:
   explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount);
 
 public:
   explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount);
+  explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount, size_t ramsize);
 
   // No copy/move
   VirtualMachine(VirtualMachine const&) = delete;
 
   // No copy/move
   VirtualMachine(VirtualMachine const&) = delete;
@@ -43,15 +44,15 @@ public:
 
 private:
   virtual ~VirtualMachine();
 
 private:
   virtual ~VirtualMachine();
-
 public:
   void start();
   bool isMigrating();
 
   void getParameters(vm_params_t params);
   void setParameters(vm_params_t params);
 public:
   void start();
   bool isMigrating();
 
   void getParameters(vm_params_t params);
   void setParameters(vm_params_t params);
-  double getRamsize();
   simgrid::s4u::Host* getPm();
   simgrid::s4u::Host* getPm();
+  size_t getRamsize();
+  void setRamsize(size_t ramsize);
 
   e_surf_vm_state_t getState();
 
 
   e_surf_vm_state_t getState();
 
index 00d1d02..06abe65 100644 (file)
@@ -59,6 +59,15 @@ void MSG_vm_get_params(msg_vm_t vm, vm_params_t params)
   vm->getParameters(params);
 }
 
   vm->getParameters(params);
 }
 
+void MSG_vm_set_ramsize(msg_vm_t vm, size_t size)
+{
+  vm->setRamsize(size);
+}
+size_t MSG_vm_get_ramsize(msg_vm_t vm)
+{
+  return vm->getRamsize();
+}
+
 /* **** Check state of a VM **** */
 static inline int __MSG_vm_is_state(msg_vm_t vm, e_surf_vm_state_t state)
 {
 /* **** Check state of a VM **** */
 static inline int __MSG_vm_is_state(msg_vm_t vm, e_surf_vm_state_t state)
 {
@@ -113,18 +122,15 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int coreAmount, int rams
 
   /* For the moment, intensity_rate is the percentage against the migration bandwidth */
 
 
   /* For the moment, intensity_rate is the percentage against the migration bandwidth */
 
-  msg_vm_t vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
+  msg_vm_t vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount, static_cast<sg_size_t>(ramsize) * 1024 * 1024);
   s_vm_params_t params;
   s_vm_params_t params;
-  params.ncpus        = 0;
-  params.ramsize      = static_cast<sg_size_t>(ramsize) * 1024 * 1024;
-  params.overcommit   = 0;
   params.devsize      = 0;
   params.skip_stage1  = 0;
   params.skip_stage2  = 0;
   params.max_downtime = 0.03;
   params.mig_speed    = static_cast<double>(mig_netspeed) * 1024 * 1024; // mig_speed
   params.dp_intensity = static_cast<double>(dp_intensity) / 100;
   params.devsize      = 0;
   params.skip_stage1  = 0;
   params.skip_stage2  = 0;
   params.max_downtime = 0.03;
   params.mig_speed    = static_cast<double>(mig_netspeed) * 1024 * 1024; // mig_speed
   params.dp_intensity = static_cast<double>(dp_intensity) / 100;
-  params.dp_cap       = params.ramsize * 0.9; // assume working set memory is 90% of ramsize
+  params.dp_cap       = vm->getRamsize() * 0.9; // assume working set memory is 90% of ramsize
 
   XBT_DEBUG("migspeed : %f intensity mem : %d", params.mig_speed, dp_intensity);
   vm->setParameters(&params);
 
   XBT_DEBUG("migspeed : %f intensity mem : %d", params.mig_speed, dp_intensity);
   vm->setParameters(&params);
@@ -142,7 +148,11 @@ msg_vm_t MSG_vm_create_core(msg_host_t pm, const char* name)
   xbt_assert(sg_host_by_name(name) == nullptr,
              "Cannot create a VM named %s: this name is already used by an host or a VM", name);
 
   xbt_assert(sg_host_by_name(name) == nullptr,
              "Cannot create a VM named %s: this name is already used by an host or a VM", name);
 
-  return new simgrid::s4u::VirtualMachine(name, pm, 1);
+  msg_vm_t vm = new simgrid::s4u::VirtualMachine(name, pm, 1);
+  s_vm_params_t params;
+  memset(&params, 0, sizeof(params));
+  vm->setParameters(&params);
+  return vm;
 }
 /** @brief Create a new VM object with the default parameters, but with a specified amount of cores
  *  @ingroup msg_VMs*
 }
 /** @brief Create a new VM object with the default parameters, but with a specified amount of cores
  *  @ingroup msg_VMs*
@@ -154,7 +164,11 @@ msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount
   xbt_assert(sg_host_by_name(name) == nullptr,
              "Cannot create a VM named %s: this name is already used by an host or a VM", name);
 
   xbt_assert(sg_host_by_name(name) == nullptr,
              "Cannot create a VM named %s: this name is already used by an host or a VM", name);
 
-  return new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
+  msg_vm_t vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
+  s_vm_params_t params;
+  memset(&params, 0, sizeof(params));
+  vm->setParameters(&params);
+  return vm;
 }
 
 /** @brief Destroy a VM. Destroy the VM object from the simulation.
 }
 
 /** @brief Destroy a VM. Destroy the VM object from the simulation.
@@ -509,7 +523,7 @@ static int migration_tx_fun(int argc, char *argv[])
   double host_speed = ms->vm->pimpl_vm_->getPm()->getSpeed();
   s_vm_params_t params;
   ms->vm->getParameters(&params);
   double host_speed = ms->vm->pimpl_vm_->getPm()->getSpeed();
   s_vm_params_t params;
   ms->vm->getParameters(&params);
-  const sg_size_t ramsize   = params.ramsize;
+  const sg_size_t ramsize   = ms->vm->getRamsize();
   const sg_size_t devsize   = params.devsize;
   const int skip_stage1     = params.skip_stage1;
   int skip_stage2           = params.skip_stage2;
   const sg_size_t devsize   = params.devsize;
   const int skip_stage1     = params.skip_stage1;
   int skip_stage2           = params.skip_stage2;
index ce764f6..87e2bad 100644 (file)
@@ -114,8 +114,8 @@ double VMModel::nextOccuringEvent(double now)
  ************/
 
 VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM,
  ************/
 
 VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM,
-                                       int coreAmount)
-    : HostImpl(piface), hostPM_(host_PM), coreAmount_(coreAmount)
+                                       int coreAmount, size_t ramsize)
+    : HostImpl(piface), hostPM_(host_PM), coreAmount_(coreAmount), ramsize_(ramsize)
 {
   /* Register this VM to the list of all VMs */
   allVms_.push_back(piface);
 {
   /* Register this VM to the list of all VMs */
   allVms_.push_back(piface);
@@ -124,9 +124,6 @@ VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, sim
   /* TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
   action_ = host_PM->pimpl_cpu->execution_start(0, coreAmount);
 
   /* TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
   action_ = host_PM->pimpl_cpu->execution_start(0, coreAmount);
 
-  /* Initialize the VM parameters */
-  params_.ramsize = 0;
-
   XBT_VERB("Create VM(%s)@PM(%s)", piface->getCname(), hostPM_->getCname());
 }
 
   XBT_VERB("Create VM(%s)@PM(%s)", piface->getCname(), hostPM_->getCname());
 }
 
@@ -295,11 +292,6 @@ void VirtualMachineImpl::setPm(s4u::Host* destination)
   XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
 }
 
   XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
 }
 
-sg_size_t VirtualMachineImpl::getRamsize()
-{
-  return params_.ramsize;
-}
-
 void VirtualMachineImpl::setBound(double bound)
 {
   action_->setBound(bound);
 void VirtualMachineImpl::setBound(double bound)
 {
   action_->setBound(bound);
index 771747b..f0af82e 100644 (file)
@@ -53,7 +53,7 @@ XBT_PUBLIC_CLASS VirtualMachineImpl : public surf::HostImpl
   friend simgrid::s4u::VirtualMachine;
 
 public:
   friend simgrid::s4u::VirtualMachine;
 
 public:
-  explicit VirtualMachineImpl(s4u::VirtualMachine * piface, s4u::Host * host, int coreAmount);
+  explicit VirtualMachineImpl(s4u::VirtualMachine * piface, s4u::Host * host, int coreAmount, size_t ramsize);
   ~VirtualMachineImpl();
 
   /** @brief Suspend the VM */
   ~VirtualMachineImpl();
 
   /** @brief Suspend the VM */
@@ -71,7 +71,8 @@ public:
   /** @brief Get the physical machine hosting the VM */
   s4u::Host* getPm();
 
   /** @brief Get the physical machine hosting the VM */
   s4u::Host* getPm();
 
-  sg_size_t getRamsize();
+  sg_size_t getRamsize() { return ramsize_; }
+  void setRamsize(sg_size_t ramsize) { ramsize_ = ramsize; }
 
   virtual void setBound(double bound);
 
 
   virtual void setBound(double bound);
 
@@ -97,6 +98,7 @@ private:
   simgrid::s4u::Host* hostPM_;
   s_vm_params_t params_;
   int coreAmount_;
   simgrid::s4u::Host* hostPM_;
   s_vm_params_t params_;
   int coreAmount_;
+  size_t ramsize_            = 0;
   e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
 };
 
   e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
 };
 
index 3dd17c2..5b0ade8 100644 (file)
@@ -15,7 +15,12 @@ namespace simgrid {
 namespace s4u {
 
 VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount)
 namespace s4u {
 
 VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount)
-    : Host(name), pimpl_vm_(new vm::VirtualMachineImpl(this, pm, coreAmount))
+    : VirtualMachine(name, pm, coreAmount, 0)
+{
+}
+
+VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount, size_t ramsize)
+    : Host(name), pimpl_vm_(new vm::VirtualMachineImpl(this, pm, coreAmount, ramsize))
 {
   XBT_DEBUG("Create VM %s", name);
 
 {
   XBT_DEBUG("Create VM %s", name);
 
@@ -91,19 +96,27 @@ bool VirtualMachine::isMigrating()
 {
   return pimpl_vm_ && pimpl_vm_->isMigrating;
 }
 {
   return pimpl_vm_ && pimpl_vm_->isMigrating;
 }
-double VirtualMachine::getRamsize()
-{
-  return pimpl_vm_->params_.ramsize;
-}
+
 simgrid::s4u::Host* VirtualMachine::getPm()
 {
   return pimpl_vm_->getPm();
 }
 simgrid::s4u::Host* VirtualMachine::getPm()
 {
   return pimpl_vm_->getPm();
 }
+
 e_surf_vm_state_t VirtualMachine::getState()
 {
   return pimpl_vm_->getState();
 }
 
 e_surf_vm_state_t VirtualMachine::getState()
 {
   return pimpl_vm_->getState();
 }
 
+size_t VirtualMachine::getRamsize()
+{
+  return pimpl_vm_->getRamsize();
+}
+
+void VirtualMachine::setRamsize(size_t ramsize)
+{
+  pimpl_vm_->setRamsize(ramsize);
+}
+
 /** @brief Retrieve a copy of the parameters of that VM/PM
  *  @details The ramsize and overcommit fields are used on the PM too */
 void VirtualMachine::getParameters(vm_params_t params)
 /** @brief Retrieve a copy of the parameters of that VM/PM
  *  @details The ramsize and overcommit fields are used on the PM too */
 void VirtualMachine::getParameters(vm_params_t params)