// Create the vm_workstation at the SURF level
XBT_PUBLIC(sg_host_t) simcall_vm_create(const char *name, sg_host_t host);
XBT_PUBLIC(void) simcall_vm_start(sg_host_t vm);
-XBT_PUBLIC(void) simcall_vm_migrate(sg_host_t vm, sg_host_t dst_pm);
XBT_PUBLIC(void *) simcall_vm_get_pm(sg_host_t vm);
XBT_PUBLIC(void) simcall_vm_set_bound(sg_host_t vm, double bound);
XBT_PUBLIC(void) simcall_vm_resume(sg_host_t vm);
msg_host_t src_pm = ms->src_pm;
msg_host_t dst_pm = ms->dst_pm;
- // TODO: we have an issue, if the DST node is turning off during the three next calls, then the VM is in an
- // inconsistent
- // state. I should check with Takahiro in order to make this portion of code atomic
- //
- // /* Update the vm location */
- // simcall_vm_migrate(vm, dst_pm);
- //
- // /* Resume the VM */
- // simcall_vm_resume(vm);
- //
+ // Make sure that we cannot get interrupted between the migrate and the resume to not end in an inconsistent state
simgrid::simix::kernelImmediate([vm, src_pm, dst_pm]() {
/* Update the vm location */
- SIMIX_vm_migrate(vm, dst_pm);
+ /* precopy migration makes the VM temporally paused */
+ xbt_assert(static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getState() == SURF_VM_STATE_SUSPENDED);
+
+ /* jump to vm_ws_xigrate(). this will update the vm location. */
+ static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->migrate(dst_pm);
/* Resume the VM */
SIMIX_vm_resume(vm);
[vm, bound]() { static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->setBound(bound); });
}
-/**
- * \ingroup simix_vm_management
- * \brief Migrate the given VM to the given physical host
- *
- * \param vm VM
- * \param host Destination physical host
- */
-void simcall_vm_migrate(sg_host_t vm, sg_host_t host)
-{
- simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_migrate, vm, host));
-}
-
/**
* \ingroup simix_vm_management
* \brief Suspend the given VM
XBT_PRIVATE void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_actor_t issuer);
// --
-XBT_PRIVATE void SIMIX_vm_migrate(sg_host_t ind_vm, sg_host_t ind_dst_pm);
-
SG_END_DECL()
#endif
static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->setState(SURF_VM_STATE_RUNNING);
}
-/**
- * @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<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getState() == SURF_VM_STATE_SUSPENDED);
-
- /* jump to vm_ws_xigrate(). this will update the vm location. */
- static_cast<simgrid::s4u::VirtualMachine*>(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