- 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
vm0 = MSG_vm_create_core(pm0, "VM0");
vm0 = MSG_vm_create_core(pm0, "VM0");
- s_vm_params_t params;
- memset(¶ms, 0, sizeof(params));
- params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
- MSG_vm_set_params(vm0, ¶ms);
+ 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);
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(¶ms, 0, sizeof(params));
- params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes
- MSG_vm_set_params(vm, ¶ms);
+ 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);
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(¶ms, 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, ¶ms);
+ MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
- 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, ¶ms);
+ MSG_vm_set_ramsize(vm0, 1e8); // 100Mbytes
- 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);
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, ¶ms);
- MSG_vm_set_params(vm1, ¶ms);
+ 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);
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, ¶ms);
- MSG_vm_set_params(vm1, ¶ms);
+ 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);
" 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(¶ms, 0, sizeof(params));
- params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes
- MSG_vm_set_params(vm0, ¶ms);
+ 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);
#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;
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);
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;
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);
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();
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)
{
/* 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);
- 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(¶ms);
XBT_DEBUG("migspeed : %f intensity mem : %d", params.mig_speed, dp_intensity);
vm->setParameters(¶ms);
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(¶ms, 0, sizeof(params));
+ vm->setParameters(¶ms);
+ 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*
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(¶ms, 0, sizeof(params));
+ vm->setParameters(¶ms);
+ return vm;
}
/** @brief Destroy a VM. Destroy the VM object from the simulation.
}
/** @brief Destroy a VM. Destroy the VM object from the simulation.
double host_speed = ms->vm->pimpl_vm_->getPm()->getSpeed();
s_vm_params_t params;
ms->vm->getParameters(¶ms);
double host_speed = ms->vm->pimpl_vm_->getPm()->getSpeed();
s_vm_params_t params;
ms->vm->getParameters(¶ms);
- 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;
************/
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);
/* 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());
}
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);
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 */
/** @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);
simgrid::s4u::Host* hostPM_;
s_vm_params_t params_;
int coreAmount_;
simgrid::s4u::Host* hostPM_;
s_vm_params_t params_;
int coreAmount_;
e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
};
e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
};
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);
{
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)