/******************************* VM simcalls ********************************/
// Create the vm_workstation at the SURF level
XBT_PUBLIC(void) simcall_vm_resume(sg_host_t vm);
-XBT_PUBLIC(void) simcall_vm_save(sg_host_t vm);
XBT_PUBLIC(void) simcall_vm_suspend(sg_host_t vm);
XBT_PUBLIC(void) simcall_vm_shutdown(sg_host_t vm);
*/
void MSG_vm_save(msg_vm_t vm)
{
- if (MSG_vm_is_migrating(vm))
- THROWF(vm_error, 0, "Cannot save VM '%s', which is migrating.", vm->cname());
-
- simcall_vm_save(vm);
+ smx_actor_t issuer=SIMIX_process_self();
+ simgrid::simix::kernelImmediate([vm,issuer]() {
+ static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->save(issuer);
+ });
if (TRACE_msg_vm_is_enabled()) {
container_t vm_container = PJ_container_get(vm->cname());
vmState_ = SURF_VM_STATE_RUNNING;
}
-void VirtualMachineImpl::save()
+/**
+ * @brief Function to save a VM.
+ * This function is the same as vm_suspend, but the state of the VM is saved to the disk, and not preserved in memory.
+ * We can later restore it again.
+ *
+ * @param vm the vm host to save (a sg_host_t)
+ */
+void VirtualMachineImpl::save(smx_actor_t issuer)
{
+ if (isMigrating)
+ THROWF(vm_error, 0, "Cannot save VM %s: it is migrating.", piface_->cname());
+
+ if (getState() != SURF_VM_STATE_RUNNING)
+ THROWF(vm_error, 0, "Cannot save VM %s: it is not running.", piface_->cname());
+
+ xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
+
+ XBT_DEBUG("Save VM %s, where %d processes exist", piface_->cname(), xbt_swag_size(process_list));
+
vmState_ = SURF_VM_STATE_SAVING;
action_->suspend();
vmState_ = SURF_VM_STATE_SAVED;
+
+ smx_actor_t smx_process, smx_process_safe;
+ xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
+ XBT_DEBUG("suspend %s", smx_process->cname());
+ SIMIX_process_suspend(smx_process, issuer);
+ }
}
void VirtualMachineImpl::restore()
/** @brief Resume the VM */
virtual void resume();
- /** @brief Save the VM (Not yet implemented) */
- virtual void save();
+ /** @brief Save the VM */
+ virtual void save(smx_actor_t issuer);
/** @brief Restore the VM (Not yet implemented) */
virtual void restore();
simcall_BODY_vm_resume(vm);
}
-/**
- * \ingroup simix_vm_management
- * \brief Save the given VM
- *
- * \param vm VM
- */
-void simcall_vm_save(sg_host_t vm)
-{
- simcall_BODY_vm_save(vm);
-}
-
/**
* \ingroup simix_vm_management
* \brief Shutdown the given VM
simgrid::simix::marshal<sg_host_t>(simcall->args[0], arg);
}
-static inline sg_host_t simcall_vm_save__get__ind_vm(smx_simcall_t simcall) {
- return simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]);
-}
-static inline void simcall_vm_save__set__ind_vm(smx_simcall_t simcall, sg_host_t arg) {
- simgrid::simix::marshal<sg_host_t>(simcall->args[0], arg);
-}
-
static inline smx_actor_t simcall_process_kill__get__process(smx_simcall_t simcall) {
return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
}
XBT_PRIVATE void simcall_HANDLER_vm_suspend(smx_simcall_t simcall, sg_host_t ind_vm);
XBT_PRIVATE void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm);
-XBT_PRIVATE void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t ind_vm);
XBT_PRIVATE void simcall_HANDLER_process_kill(smx_simcall_t simcall, smx_actor_t process);
XBT_PRIVATE void simcall_HANDLER_process_killall(smx_simcall_t simcall, int reset_pid);
XBT_PRIVATE void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process);
return simcall<void, sg_host_t>(SIMCALL_VM_SHUTDOWN, ind_vm);
}
-inline static void simcall_BODY_vm_save(sg_host_t ind_vm) {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_vm_save(&SIMIX_process_self()->simcall, ind_vm);
- return simcall<void, sg_host_t>(SIMCALL_VM_SAVE, ind_vm);
- }
-
inline static void simcall_BODY_process_kill(smx_actor_t process) {
/* Go to that function to follow the code flow through the simcall barrier */
if (0) simcall_HANDLER_process_kill(&SIMIX_process_self()->simcall, process);
SIMCALL_VM_SUSPEND,
SIMCALL_VM_RESUME,
SIMCALL_VM_SHUTDOWN,
- SIMCALL_VM_SAVE,
SIMCALL_PROCESS_KILL,
SIMCALL_PROCESS_KILLALL,
SIMCALL_PROCESS_CLEANUP,
"SIMCALL_NONE", "SIMCALL_VM_SUSPEND",
"SIMCALL_VM_RESUME",
"SIMCALL_VM_SHUTDOWN",
- "SIMCALL_VM_SAVE",
"SIMCALL_PROCESS_KILL",
"SIMCALL_PROCESS_KILLALL",
"SIMCALL_PROCESS_CLEANUP",
SIMIX_simcall_answer(simcall);
break;
-case SIMCALL_VM_SAVE:
- simcall_HANDLER_vm_save(simcall, simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]));
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_PROCESS_KILL:
simcall_HANDLER_process_kill(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]));
SIMIX_simcall_answer(simcall);
void vm_suspend(sg_host_t ind_vm);
void vm_resume(sg_host_t ind_vm) [[nohandler]];
void vm_shutdown(sg_host_t ind_vm);
-void vm_save(sg_host_t ind_vm);
void process_kill(smx_actor_t process);
void process_killall(int reset_pid);
XBT_PRIVATE void SIMIX_vm_suspend(sg_host_t ind_vm, smx_actor_t issuer);
// --
-XBT_PRIVATE void SIMIX_vm_save(sg_host_t ind_vm, smx_actor_t issuer);
-
XBT_PRIVATE void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_actor_t issuer);
// --
}
}
-/**
- * @brief Function to save a SIMIX VM host.
- * This function is the same as vm_suspend, but the state of the VM is saved to the disk, and not preserved on memory.
- * We can later restore it again.
- *
- * @param vm the vm host to save (a sg_host_t)
- */
-void SIMIX_vm_save(sg_host_t vm, smx_actor_t issuer)
-{
- if (static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getState() != SURF_VM_STATE_RUNNING)
- THROWF(vm_error, 0, "VM(%s) is not running", vm->cname());
-
- XBT_DEBUG("save VM(%s), where %d processes exist", vm->cname(), xbt_swag_size(sg_host_simix(vm)->process_list));
-
- static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->save();
-
- smx_actor_t smx_process, smx_process_safe;
- xbt_swag_foreach_safe(smx_process, smx_process_safe, sg_host_simix(vm)->process_list) {
- XBT_DEBUG("suspend %s", smx_process->cname());
- SIMIX_process_suspend(smx_process, issuer);
- }
-}
-
-void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t vm)
-{
- SIMIX_vm_save(vm, simcall->issuer);
-}
-
/**
* @brief Function to shutdown a SIMIX VM host. This function powers off the
* VM. All the processes on this VM will be killed. But, the state of the VM is