XBT_PUBLIC(e_smx_state_t) simcall_execution_wait(smx_activity_t execution);
/******************************* VM simcalls ********************************/
-XBT_PUBLIC(void) simcall_vm_suspend(sg_host_t vm);
XBT_PUBLIC(void) simcall_vm_shutdown(sg_host_t vm);
/**************************** Process simcalls ********************************/
/* Stage3: stop the VM and copy the rest of states. */
XBT_DEBUG("mig-stage3: remaining_size %f", remaining_size);
- simcall_vm_suspend(ms->vm);
+ simgrid::vm::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(ms->vm)->pimpl_vm_;
+ pimpl->setState(SURF_VM_STATE_RUNNING); // FIXME: this bypass of the checks in suspend() is not nice
+ pimpl->isMigrating = false; // FIXME: this bypass of the checks in suspend() is not nice
+ pimpl->suspend(SIMIX_process_self());
stop_dirty_page_tracking(ms->vm);
try {
*/
void MSG_vm_suspend(msg_vm_t vm)
{
- if (MSG_vm_is_migrating(vm))
- THROWF(vm_error, 0, "Cannot suspend VM '%s', which is migrating", vm->cname());
-
- simcall_vm_suspend(vm);
+ smx_actor_t issuer = SIMIX_process_self();
+ simgrid::simix::kernelImmediate([vm,issuer]() {
+ static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->suspend(issuer);
+ });
XBT_DEBUG("vm_suspend done");
{
vmState_ = state;
}
-void VirtualMachineImpl::suspend()
+void VirtualMachineImpl::suspend(smx_actor_t issuer)
{
+ if (isMigrating)
+ THROWF(vm_error, 0, "Cannot suspend VM '%s': it is migrating", piface_->cname());
+ if (getState() != SURF_VM_STATE_RUNNING)
+ THROWF(vm_error, 0, "Cannot suspend VM %s: it is not running.", piface_->cname());
+ if (issuer->host == piface_)
+ THROWF(vm_error, 0, "Actor %s cannot suspend the VM %s in which it runs", issuer->cname(), piface_->cname());
+
+ xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
+ XBT_DEBUG("suspend VM(%s), where %d processes exist", piface_->cname(), xbt_swag_size(process_list));
+
action_->suspend();
+
+ 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->name.c_str());
+ SIMIX_process_suspend(smx_process, issuer);
+ }
+
+ XBT_DEBUG("suspend all processes on the VM done done");
+
vmState_ = SURF_VM_STATE_SUSPENDED;
}
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;
~VirtualMachineImpl();
/** @brief Suspend the VM */
- virtual void suspend();
+ virtual void suspend(smx_actor_t issuer);
/** @brief Resume the VM */
virtual void resume();
/** @brief Save the VM */
virtual void save(smx_actor_t issuer);
- /** @brief Restore the VM (Not yet implemented) */
+ /** @brief Restore the VM */
virtual void restore();
/** @brief Migrate the VM to the destination host */
return (e_smx_state_t) simcall_BODY_execution_wait(execution);
}
-/**
- * \ingroup simix_vm_management
- * \brief Suspend the given VM
- *
- * \param vm VM
- */
-void simcall_vm_suspend(sg_host_t vm)
-{
- simcall_BODY_vm_suspend(vm);
-}
-
/**
* \ingroup simix_vm_management
* \brief Shutdown the given VM
*/
#include "src/simix/popping_private.h"
-static inline sg_host_t simcall_vm_suspend__get__ind_vm(smx_simcall_t simcall) {
- return simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]);
-}
-static inline void simcall_vm_suspend__set__ind_vm(smx_simcall_t simcall, sg_host_t arg) {
- simgrid::simix::marshal<sg_host_t>(simcall->args[0], arg);
-}
-
static inline sg_host_t simcall_vm_shutdown__get__ind_vm(smx_simcall_t simcall) {
return simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]);
}
/* The prototype of all simcall handlers, automatically generated for you */
-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_process_kill(smx_simcall_t simcall, smx_actor_t process);
XBT_PRIVATE void simcall_HANDLER_process_killall(smx_simcall_t simcall, int reset_pid);
return simgrid::simix::unmarshal<R>(self->simcall.result);
}
-inline static void simcall_BODY_vm_suspend(sg_host_t ind_vm) {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_vm_suspend(&SIMIX_process_self()->simcall, ind_vm);
- return simcall<void, sg_host_t>(SIMCALL_VM_SUSPEND, ind_vm);
- }
-
inline static void simcall_BODY_vm_shutdown(sg_host_t ind_vm) {
/* Go to that function to follow the code flow through the simcall barrier */
if (0) simcall_HANDLER_vm_shutdown(&SIMIX_process_self()->simcall, ind_vm);
*/
typedef enum {
SIMCALL_NONE,
- SIMCALL_VM_SUSPEND,
SIMCALL_VM_SHUTDOWN,
SIMCALL_PROCESS_KILL,
SIMCALL_PROCESS_KILLALL,
/** @brief Simcalls' names (generated from src/simix/simcalls.in) */
const char* simcall_names[] = {
- "SIMCALL_NONE", "SIMCALL_VM_SUSPEND",
- "SIMCALL_VM_SHUTDOWN",
- "SIMCALL_PROCESS_KILL",
- "SIMCALL_PROCESS_KILLALL",
- "SIMCALL_PROCESS_CLEANUP",
- "SIMCALL_PROCESS_SUSPEND",
- "SIMCALL_PROCESS_RESUME",
- "SIMCALL_PROCESS_SET_HOST",
- "SIMCALL_PROCESS_IS_SUSPENDED",
- "SIMCALL_PROCESS_JOIN",
- "SIMCALL_PROCESS_SLEEP",
- "SIMCALL_EXECUTION_START",
- "SIMCALL_EXECUTION_PARALLEL_START",
- "SIMCALL_EXECUTION_CANCEL",
- "SIMCALL_EXECUTION_SET_PRIORITY",
- "SIMCALL_EXECUTION_SET_BOUND",
- "SIMCALL_EXECUTION_WAIT",
- "SIMCALL_PROCESS_ON_EXIT",
- "SIMCALL_PROCESS_AUTO_RESTART_SET",
- "SIMCALL_PROCESS_RESTART",
- "SIMCALL_MBOX_CREATE",
- "SIMCALL_MBOX_SET_RECEIVER",
- "SIMCALL_COMM_IPROBE",
- "SIMCALL_COMM_SEND",
- "SIMCALL_COMM_ISEND",
- "SIMCALL_COMM_RECV",
- "SIMCALL_COMM_IRECV",
- "SIMCALL_COMM_WAITANY",
- "SIMCALL_COMM_WAIT",
- "SIMCALL_COMM_TEST",
- "SIMCALL_COMM_TESTANY",
- "SIMCALL_MUTEX_INIT",
- "SIMCALL_MUTEX_LOCK",
- "SIMCALL_MUTEX_TRYLOCK",
- "SIMCALL_MUTEX_UNLOCK",
- "SIMCALL_COND_INIT",
- "SIMCALL_COND_SIGNAL",
- "SIMCALL_COND_WAIT",
- "SIMCALL_COND_WAIT_TIMEOUT",
- "SIMCALL_COND_BROADCAST",
- "SIMCALL_SEM_INIT",
- "SIMCALL_SEM_RELEASE",
- "SIMCALL_SEM_WOULD_BLOCK",
- "SIMCALL_SEM_ACQUIRE",
- "SIMCALL_SEM_ACQUIRE_TIMEOUT",
- "SIMCALL_SEM_GET_CAPACITY",
- "SIMCALL_FILE_READ",
- "SIMCALL_FILE_WRITE",
- "SIMCALL_FILE_OPEN",
- "SIMCALL_FILE_CLOSE",
- "SIMCALL_FILE_UNLINK",
- "SIMCALL_FILE_GET_SIZE",
- "SIMCALL_FILE_TELL",
- "SIMCALL_FILE_SEEK",
- "SIMCALL_FILE_GET_INFO",
- "SIMCALL_FILE_MOVE",
- "SIMCALL_STORAGE_GET_FREE_SIZE",
- "SIMCALL_STORAGE_GET_USED_SIZE",
- "SIMCALL_STORAGE_GET_PROPERTIES",
- "SIMCALL_STORAGE_GET_CONTENT",
- "SIMCALL_MC_RANDOM",
- "SIMCALL_SET_CATEGORY",
- "SIMCALL_RUN_KERNEL",
- "SIMCALL_RUN_BLOCKING",};
+ "SIMCALL_NONE",
+ "SIMCALL_VM_SHUTDOWN",
+ "SIMCALL_PROCESS_KILL",
+ "SIMCALL_PROCESS_KILLALL",
+ "SIMCALL_PROCESS_CLEANUP",
+ "SIMCALL_PROCESS_SUSPEND",
+ "SIMCALL_PROCESS_RESUME",
+ "SIMCALL_PROCESS_SET_HOST",
+ "SIMCALL_PROCESS_IS_SUSPENDED",
+ "SIMCALL_PROCESS_JOIN",
+ "SIMCALL_PROCESS_SLEEP",
+ "SIMCALL_EXECUTION_START",
+ "SIMCALL_EXECUTION_PARALLEL_START",
+ "SIMCALL_EXECUTION_CANCEL",
+ "SIMCALL_EXECUTION_SET_PRIORITY",
+ "SIMCALL_EXECUTION_SET_BOUND",
+ "SIMCALL_EXECUTION_WAIT",
+ "SIMCALL_PROCESS_ON_EXIT",
+ "SIMCALL_PROCESS_AUTO_RESTART_SET",
+ "SIMCALL_PROCESS_RESTART",
+ "SIMCALL_MBOX_CREATE",
+ "SIMCALL_MBOX_SET_RECEIVER",
+ "SIMCALL_COMM_IPROBE",
+ "SIMCALL_COMM_SEND",
+ "SIMCALL_COMM_ISEND",
+ "SIMCALL_COMM_RECV",
+ "SIMCALL_COMM_IRECV",
+ "SIMCALL_COMM_WAITANY",
+ "SIMCALL_COMM_WAIT",
+ "SIMCALL_COMM_TEST",
+ "SIMCALL_COMM_TESTANY",
+ "SIMCALL_MUTEX_INIT",
+ "SIMCALL_MUTEX_LOCK",
+ "SIMCALL_MUTEX_TRYLOCK",
+ "SIMCALL_MUTEX_UNLOCK",
+ "SIMCALL_COND_INIT",
+ "SIMCALL_COND_SIGNAL",
+ "SIMCALL_COND_WAIT",
+ "SIMCALL_COND_WAIT_TIMEOUT",
+ "SIMCALL_COND_BROADCAST",
+ "SIMCALL_SEM_INIT",
+ "SIMCALL_SEM_RELEASE",
+ "SIMCALL_SEM_WOULD_BLOCK",
+ "SIMCALL_SEM_ACQUIRE",
+ "SIMCALL_SEM_ACQUIRE_TIMEOUT",
+ "SIMCALL_SEM_GET_CAPACITY",
+ "SIMCALL_FILE_READ",
+ "SIMCALL_FILE_WRITE",
+ "SIMCALL_FILE_OPEN",
+ "SIMCALL_FILE_CLOSE",
+ "SIMCALL_FILE_UNLINK",
+ "SIMCALL_FILE_GET_SIZE",
+ "SIMCALL_FILE_TELL",
+ "SIMCALL_FILE_SEEK",
+ "SIMCALL_FILE_GET_INFO",
+ "SIMCALL_FILE_MOVE",
+ "SIMCALL_STORAGE_GET_FREE_SIZE",
+ "SIMCALL_STORAGE_GET_USED_SIZE",
+ "SIMCALL_STORAGE_GET_PROPERTIES",
+ "SIMCALL_STORAGE_GET_CONTENT",
+ "SIMCALL_MC_RANDOM",
+ "SIMCALL_SET_CATEGORY",
+ "SIMCALL_RUN_KERNEL",
+ "SIMCALL_RUN_BLOCKING",
+};
/** @private
* @brief (in kernel mode) unpack the simcall and activate the handler
if (simcall->issuer->context->iwannadie && simcall->call != SIMCALL_PROCESS_CLEANUP)
return;
switch (simcall->call) {
-case SIMCALL_VM_SUSPEND:
- simcall_HANDLER_vm_suspend(simcall, simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]));
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_VM_SHUTDOWN:
simcall_HANDLER_vm_shutdown(simcall, simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]));
SIMIX_simcall_answer(simcall);
# ./include/simgrid/simix.h (otherwise you will get a warning at the
# compilation time)
-void vm_suspend(sg_host_t ind_vm);
void vm_shutdown(sg_host_t ind_vm);
void process_kill(smx_actor_t process);
return ' SIMCALL_%s,' % (self.name.upper())
def string(self):
- return ' "SIMCALL_%s",' % self.name.upper()
+ return ' "SIMCALL_%s",' % self.name.upper()
def accessors(self):
res = []
'/** @brief Simcalls\' names (generated from src/simix/simcalls.in) */\n')
fd.write('const char* simcall_names[] = {\n')
- fd.write(' "SIMCALL_NONE",')
+ fd.write(' "SIMCALL_NONE",\n')
handle(fd, Simcall.string, simcalls, simcalls_dict)
- fd.write('};\n\n')
+ fd.write('\n};\n\n')
fd.write('/** @private\n')
fd.write(
XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, const char *category);
/* vm related stuff */
-XBT_PRIVATE void SIMIX_vm_suspend(sg_host_t ind_vm, smx_actor_t issuer);
-// --
XBT_PRIVATE void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_actor_t issuer);
// --
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virtual Machines");
-/**
- * @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
- * preserved on memory. We can later resume it again.
- *
- * @param vm the vm host to suspend (a sg_host_t)
- */
-void SIMIX_vm_suspend(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("suspend VM(%s), where %d processes exist", vm->cname(), xbt_swag_size(sg_host_simix(vm)->process_list));
-
- /* jump to vm_ws_suspend. The state will be set. */
- static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->suspend();
-
- 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->name.c_str());
- SIMIX_process_suspend(smx_process, issuer);
- }
-
- XBT_DEBUG("suspend all processes on the VM done done");
-}
-
-void simcall_HANDLER_vm_suspend(smx_simcall_t simcall, sg_host_t vm)
-{
- xbt_assert(simcall->issuer->host != vm, "cannot suspend the VM where I run");
-
- SIMIX_vm_suspend(vm, simcall->issuer);
-
- XBT_DEBUG("simcall_HANDLER_vm_suspend done");
-}
-
/**
* @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