Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
(hopefully) fix the memory issues in the VMs
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 20 Nov 2016 18:18:49 +0000 (19:18 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 20 Nov 2016 18:23:02 +0000 (19:23 +0100)
- Create and populate an host extension, used by the VM plugin to
  check the total amount of memory of that host and whether this host
  allows overcommiting VM above this value.
- This is a great step toward the pluginization of the VMs
- Unfortunately, there is no way to change these values for an host
  yet :-|

src/msg/msg_vm.cpp
src/plugins/vm/VmHostExt.cpp
src/plugins/vm/VmHostExt.hpp
src/simix/smx_vm.cpp

index 35efaa7..fb1e82d 100644 (file)
@@ -12,6 +12,7 @@
 #include <xbt/ex.hpp>
 
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
+#include "src/plugins/vm/VmHostExt.hpp"
 #include <simgrid/s4u/VirtualMachine.hpp>
 #include <simgrid/s4u/host.hpp>
 
@@ -127,8 +128,9 @@ int MSG_vm_is_restoring(msg_vm_t vm)
 msg_vm_t MSG_vm_create(msg_host_t pm, const char *name, int ncpus, int ramsize, int net_cap, char *disk_path,
                        int disksize, int mig_netspeed, int dp_intensity)
 {
-  /* For the moment, intensity_rate is the percentage against the migration
-   * bandwidth */
+  simgrid::vm::VmHostExt::ensureVmExtInstalled();
+
+  /* For the moment, intensity_rate is the percentage against the migration bandwidth */
   double host_speed = MSG_host_get_speed(pm);
   double update_speed = ((double)dp_intensity/100) * mig_netspeed;
 
@@ -225,7 +227,8 @@ void MSG_vm_shutdown(msg_vm_t vm)
 {
   /* msg_vm_t equals to msg_host_t */
   simcall_vm_shutdown(vm);
-
+  MSG_process_sleep(0.); // Make sure that the processes in the VM are killed in this scheduling round before processing
+                         // (eg with the VM destroy)
   // TRACE_msg_vm_(vm);
 }
 
index a4fcf09..17d3e9c 100644 (file)
@@ -10,8 +10,15 @@ XBT_LOG_DEFAULT_CATEGORY(surf_vm);
 
 namespace simgrid {
 namespace vm {
+simgrid::xbt::Extension<s4u::Host, VmHostExt> VmHostExt::EXTENSION_ID;
+
 VmHostExt::~VmHostExt()
 {
 }
+void VmHostExt::ensureVmExtInstalled()
+{
+  if (!EXTENSION_ID.valid())
+    EXTENSION_ID = simgrid::s4u::Host::extension_create<VmHostExt>();
+}
 }
 }
index 6795ba2..46a26c8 100644 (file)
@@ -14,8 +14,14 @@ namespace simgrid {
 namespace vm {
 /** @brief Host extension for the VMs */
 class VmHostExt {
-  virtual ~VmHostExt();
+public:
   static simgrid::xbt::Extension<simgrid::s4u::Host, VmHostExt> EXTENSION_ID;
+  virtual ~VmHostExt();
+
+  sg_size_t ramsize = 0;    /* available ramsize (0= not taken into account) */
+  bool overcommit   = true; /* Whether the host allows overcommiting more VM than the avail ramsize allows */
+
+  static void ensureVmExtInstalled();
 };
 }
 }
index d1b585f..359286a 100644 (file)
@@ -7,6 +7,7 @@
 #include "simgrid/s4u/VirtualMachine.hpp"
 #include "smx_private.h"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
+#include "src/plugins/vm/VmHostExt.hpp"
 #include "src/surf/HostImpl.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virtual Machines");
@@ -26,10 +27,14 @@ static long host_get_ramsize(sg_host_t vm, int *overcommit)
 /* **** start a VM **** */
 static int __can_be_started(sg_host_t vm)
 {
+  simgrid::vm::VmHostExt::ensureVmExtInstalled();
+
   sg_host_t pm = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getPm();
 
   int pm_overcommit = 0;
-  long pm_ramsize = host_get_ramsize(pm, &pm_overcommit);
+  if (pm->extension<simgrid::vm::VmHostExt>() == nullptr)
+    pm->extension_set(new simgrid::vm::VmHostExt());
+  long pm_ramsize = pm->extension<simgrid::vm::VmHostExt>()->ramsize;
   long vm_ramsize = host_get_ramsize(vm, nullptr);
 
   if (!pm_ramsize) {