- 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);
- xbt_dynar_free(&dyn_vms);
- return 0;
- }
-
- return 1;
-}
-
-void SIMIX_vm_start(sg_host_t vm)
-{
- if (__can_be_started(vm))
- static_cast<simgrid::surf::VirtualMachine*>(
- vm->pimpl_
- )->setState(SURF_VM_STATE_RUNNING);
- else
- THROWF(vm_error, 0, "The VM %s cannot be started", vm->name().c_str());
-}
-
-
-e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t vm)
-{
- return static_cast<simgrid::surf::VirtualMachine*>(
- vm->pimpl_
- )->getState();
-}
-
-/**
- * @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(SIMIX_vm_get_state(vm) == SURF_VM_STATE_SUSPENDED);
-
- /* jump to vm_ws_xigrate(). this will update the vm location. */
- surf_vm_migrate(vm, dst_pm);
-}
-
-/**
- * @brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration
- * The simcall actually invokes the following calls:
- * simcall_vm_migrate(vm, dst_pm);
- * simcall_vm_resume(vm);
- *
- * It is called at the end of the migration_rx_fun function from msg/msg_vm.c
- *
- * @param vm VM to migrate
- * @param src_pm Source physical host
- * @param dst_pmt Destination physical host
- */
-void SIMIX_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t dst_pm)
-{
- /* Update the vm location */
- SIMIX_vm_migrate(vm, dst_pm);
-
- /* Resume the VM */
- smx_actor_t self = SIMIX_process_self();
- SIMIX_vm_resume(vm, self);
-}
-
-/**
- * @brief Function to get the physical host of the given SIMIX VM host.
- *
- * @param host the vm host to get_phys_host (a sg_host_t)
- */
-void *SIMIX_vm_get_pm(sg_host_t host)
-{
- return surf_vm_get_pm(host);
-}
-
-/**
- * @brief Function to set the CPU bound of the given SIMIX VM host.
- *
- * @param host the vm host (a sg_host_t)
- * @param bound bound (a double)
- */
-void SIMIX_vm_set_bound(sg_host_t vm, double bound)
-{
- surf_vm_set_bound(vm, bound);