From: Martin Quinson Date: Sun, 20 Nov 2016 18:18:49 +0000 (+0100) Subject: (hopefully) fix the memory issues in the VMs X-Git-Tag: v3_14~166 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/069e3778afeb19b676671732f94e986d3ed73d06 (hopefully) fix the memory issues in the VMs - 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 :-| --- diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 35efaa791e..fb1e82d780 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -12,6 +12,7 @@ #include #include "src/plugins/vm/VirtualMachineImpl.hpp" +#include "src/plugins/vm/VmHostExt.hpp" #include #include @@ -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); } diff --git a/src/plugins/vm/VmHostExt.cpp b/src/plugins/vm/VmHostExt.cpp index a4fcf09ece..17d3e9ca4e 100644 --- a/src/plugins/vm/VmHostExt.cpp +++ b/src/plugins/vm/VmHostExt.cpp @@ -10,8 +10,15 @@ XBT_LOG_DEFAULT_CATEGORY(surf_vm); namespace simgrid { namespace vm { +simgrid::xbt::Extension VmHostExt::EXTENSION_ID; + VmHostExt::~VmHostExt() { } +void VmHostExt::ensureVmExtInstalled() +{ + if (!EXTENSION_ID.valid()) + EXTENSION_ID = simgrid::s4u::Host::extension_create(); +} } } diff --git a/src/plugins/vm/VmHostExt.hpp b/src/plugins/vm/VmHostExt.hpp index 6795ba2f9b..46a26c8ff7 100644 --- a/src/plugins/vm/VmHostExt.hpp +++ b/src/plugins/vm/VmHostExt.hpp @@ -14,8 +14,14 @@ namespace simgrid { namespace vm { /** @brief Host extension for the VMs */ class VmHostExt { - virtual ~VmHostExt(); +public: static simgrid::xbt::Extension 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(); }; } } diff --git a/src/simix/smx_vm.cpp b/src/simix/smx_vm.cpp index d1b585fb40..359286a48a 100644 --- a/src/simix/smx_vm.cpp +++ b/src/simix/smx_vm.cpp @@ -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(vm)->pimpl_vm_->getPm(); int pm_overcommit = 0; - long pm_ramsize = host_get_ramsize(pm, &pm_overcommit); + if (pm->extension() == nullptr) + pm->extension_set(new simgrid::vm::VmHostExt()); + long pm_ramsize = pm->extension()->ramsize; long vm_ramsize = host_get_ramsize(vm, nullptr); if (!pm_ramsize) {