X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/20fc29c9161b5d8356c192fc2ddd031f7fe1fe76..411bdcf820a148926951d59809cd452e1c683eec:/src/simix/smx_vm.cpp diff --git a/src/simix/smx_vm.cpp b/src/simix/smx_vm.cpp index 080cf30b7a..10def72ddd 100644 --- a/src/simix/smx_vm.cpp +++ b/src/simix/smx_vm.cpp @@ -12,79 +12,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virtual Machines"); -/* works for VMs and PMs */ -static long host_get_ramsize(sg_host_t vm, int *overcommit) -{ - s_vm_params_t params; - static_cast(vm)->parameters(¶ms); - - if (overcommit) - *overcommit = params.overcommit; - - return params.ramsize; -} - -/* **** start a VM **** */ -static int __can_be_started(sg_host_t vm) -{ - sg_host_t pm = static_cast(vm)->pimpl_vm_->getPm(); - - simgrid::vm::VmHostExt::ensureVmExtInstalled(); - if (pm->extension() == nullptr) - pm->extension_set(new simgrid::vm::VmHostExt()); - - long pm_ramsize = pm->extension()->ramsize; - int pm_overcommit = pm->extension()->overcommit; - long vm_ramsize = host_get_ramsize(vm, nullptr); - - if (!pm_ramsize) { - /* We assume users do not want to care about ramsize. */ - return 1; - } - - if (pm_overcommit) { - XBT_VERB("%s allows memory overcommit.", sg_host_get_name(pm)); - return 1; - } - - /* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */ - long total_ramsize_of_vms = 0; - for (simgrid::surf::VirtualMachineImpl* ws_vm : simgrid::surf::VirtualMachineImpl::allVms_) - if (pm == ws_vm->getPm()) - total_ramsize_of_vms += ws_vm->getRamsize(); - - if (vm_ramsize > pm_ramsize - total_ramsize_of_vms) { - XBT_WARN("cannnot start %s@%s due to memory shortage: vm_ramsize %ld, free %ld, pm_ramsize %ld (bytes).", - sg_host_get_name(vm), sg_host_get_name(pm), - vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize); - return 0; - } - - return 1; -} - -void SIMIX_vm_start(sg_host_t vm) -{ - if (__can_be_started(vm)) - static_cast(vm)->pimpl_vm_->setState(SURF_VM_STATE_RUNNING); - else - THROWF(vm_error, 0, "The VM %s cannot be started", vm->name().c_str()); -} - -/** - * @brief Function to migrate a SIMIX VM host. - * - * @param host the vm host to migrate (a sg_host_t) - */ -void SIMIX_vm_migrate(sg_host_t vm, sg_host_t dst_pm) -{ - /* precopy migration makes the VM temporally paused */ - xbt_assert(static_cast(vm)->pimpl_vm_->getState() == SURF_VM_STATE_SUSPENDED); - - /* jump to vm_ws_xigrate(). this will update the vm location. */ - static_cast(vm)->pimpl_vm_->migrate(dst_pm); -} - /** * @brief Function to suspend a SIMIX VM host. This function stops the execution of the * VM. All the processes on this VM will pause. The state of the VM is