#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>
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;
{
/* 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);
}
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>();
+}
}
}
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();
};
}
}
#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");
/* **** 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) {