MSG_vm_reboot would be equivalent to MSG_vm_shutdown and MSG_vm_start.
XBT_PUBLIC(void) MSG_vm_migrate(msg_vm_t vm, msg_host_t destination);
+/* Suspend the execution of the VM, but keep its state on memory. */
XBT_PUBLIC(void) MSG_vm_suspend(msg_vm_t vm);
- // \forall p in VM, MSG_process_suspend(p) // Freeze the processes
+XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm);
-XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm); // Simulate the fact of reading the processes from disk and resuming them
- // \forall p in VM, MSG_process_resume(p) // unfreeze them
+/* Save the VM state to a disk. */
+XBT_PUBLIC(void) MSG_vm_save(msg_vm_t vm);
+XBT_PUBLIC(void) MSG_vm_restore(msg_vm_t vm);
-XBT_PUBLIC(void) MSG_vm_shutdown(msg_vm_t vm); // killall
-
-XBT_PUBLIC(void) MSG_vm_reboot(msg_vm_t vm);
+/* Shutdown the guest operating system. */
+XBT_PUBLIC(void) MSG_vm_shutdown(msg_vm_t vm);
XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm);
}
-
/** @brief Migrate the VM to the given host.
* @ingroup msg_VMs
*
- * FIXME: update comments.
- * No migration cost occurs. If you want to simulate this too, you want to use a
+ * FIXME: No migration cost occurs. If you want to simulate this too, you want to use a
* MSG_task_send() before or after, depending on whether you want to do cold or hot
* migration.
*/
}
-
/** @brief Resume the execution of the VM. All processes on the VM run again.
* @ingroup msg_VMs
*
- * No resume cost occurs. If you want to simulate this too, you want to
+ * FIXME: No resume cost occurs. If you want to simulate this too, you want to
* use a \ref MSG_file_read() before or after, depending on the exact semantic
* of VM resume to you.
*/
#endif
}
-//
-///**
-// * \ingroup msg_VMs
-// * \brief Reboot the VM, restarting all the processes in it.
-// */
-//void MSG_vm_reboot(msg_vm_t vm)
-//{
-// xbt_dynar_t new_processes = xbt_dynar_new(sizeof(msg_process_t),NULL);
-//
-// msg_process_t process;
-// unsigned int cpt;
-//
-// xbt_dynar_foreach(vm->processes,cpt,process) {
-// msg_process_t new_process = MSG_process_restart(process);
-// xbt_dynar_push_as(new_processes,msg_process_t,new_process);
-//
-// }
-//
-// xbt_dynar_foreach(new_processes, cpt, process) {
-// MSG_vm_bind(vm,process);
-// }
-//
-// xbt_dynar_free(&new_processes);
-//}
-//
+
+/** @brief Immediately save the execution of all processes within the given VM.
+ * @ingroup msg_VMs
+ *
+ * This function stops the exection of the VM. All the processes on this VM
+ * will pause. The state of the VM is perserved. We can later resume it again.
+ *
+ * FIXME: No suspension cost occurs. If you want to simulate this too, you want to
+ * use a \ref MSG_file_write() before or after, depending on the exact semantic
+ * of VM save to you.
+ */
+void MSG_vm_save(msg_vm_t vm)
+{
+ simcall_vm_save(vm);
+
+ #ifdef HAVE_TRACING
+ TRACE_msg_vm_save(vm);
+ #endif
+}
+
+
+/** @brief Restore the execution of the VM. All processes on the VM run again.
+ * @ingroup msg_VMs
+ *
+ * FIXME: No restore cost occurs. If you want to simulate this too, you want to
+ * use a \ref MSG_file_read() before or after, depending on the exact semantic
+ * of VM restore to you.
+ */
+void MSG_vm_restore(msg_vm_t vm)
+{
+ simcall_vm_restore(vm);
+
+ #ifdef HAVE_TRACING
+ TRACE_msg_vm_restore(vm);
+ #endif
+}
+
/** @brief Destroy a VM. Destroy the VM object from the simulation.
* @ingroup msg_VMs
ACTION(SIMCALL_VM_SUSPEND, vm_suspend, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t)) sep \
ACTION(SIMCALL_VM_RESUME, vm_resume, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t)) sep \
ACTION(SIMCALL_VM_SHUTDOWN, vm_shutdown, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t)) sep \
+ACTION(SIMCALL_VM_SAVE, vm_save, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t)) sep \
+ACTION(SIMCALL_VM_RESTORE, vm_restore, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t)) sep \
ACTION(SIMCALL_PROCESS_CREATE, process_create, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t*), TSTRING(name), TSPEC(code, xbt_main_func_t), TPTR(data), TSTRING(hostname), TDOUBLE(kill_time), TINT(argc), TSPEC(argv, char**), TSPEC(properties, xbt_dict_t), TINT(auto_restart)) sep \
ACTION(SIMCALL_PROCESS_KILL, process_kill, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
ACTION(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result), TINT(reset_pid)) sep \
/**
* \ingroup simix_vm_management
- * \brief Returns a dict of the properties assigned to a host.
+ * \brief Create a VM on the given physical host.
*
- * \param host A host
- * \return The properties of this host
+ * \param name VM name
+ * \param host Physical host
+ *
+ * \return The host object of the VM
*/
void* simcall_vm_create(const char *name, smx_host_t phys_host){
- /* jump to SIMIX_pre_vm_create() */
+ /* will jump to SIMIX_pre_vm_create() in src/simix/smx_smurf_private.h */
return simcall_BODY_vm_create(name, phys_host);
}
+/**
+ * \ingroup simix_vm_management
+ * \brief Start the given VM to the given physical host
+ *
+ * \param vm VM
+ */
void simcall_vm_start(smx_host_t vm) {
+ /* will jump to SIMIX_pre_vm_get_state in src/simix/smx_smurf_private.h */
simcall_BODY_vm_set_state(vm, msg_vm_state_running);
}
+/**
+ * \ingroup simix_vm_management
+ * \brief Get the state of the given VM
+ *
+ * \param vm VM
+ * \return The state of the VM
+ */
int simcall_vm_get_state(smx_host_t vm)
{
- /* will jump to SIMIX_pre_vm_get_state */
+ /* will jump to SIMIX_pre_vm_get_state in src/simix/smx_smurf_private.h */
return simcall_BODY_vm_get_state(vm);
}
-void simcall_vm_migrate(smx_host_t vm, smx_host_t dst_phys)
+/**
+ * \ingroup simix_vm_management
+ * \brief Get the name of the physical host on which the given VM runs.
+ *
+ * \param vm VM
+ * \return The name of the physical host
+ */
+const char *simcall_vm_get_phys_host(smx_host_t vm)
{
- /* will jump to SIMIX_pre_vm_migrate */
- simcall_BODY_vm_migrate(vm, dst_phys);
+ /* will jump to SIMIX_pre_vm_migrate in src/simix/smx_smurf_private.h */
+ simcall_BODY_vm_get_phys_host(vm);
}
-const char *simcall_vm_get_phys_host(smx_host_t vm)
+/**
+ * \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(smx_host_t vm, smx_host_t host)
{
- /* will jump to SIMIX_pre_vm_migrate */
- simcall_BODY_vm_get_phys_host(vm);
+ /* will jump to SIMIX_pre_vm_migrate in src/simix/smx_smurf_private.h */
+ simcall_BODY_vm_migrate(vm, host);
}
+/**
+ * \ingroup simix_vm_management
+ * \brief Suspend the given VM
+ *
+ * \param vm VM
+ */
void simcall_vm_suspend(smx_host_t vm)
{
- /* will jump to SIMIX_pre_vm_suspend */
+ /* will jump to SIMIX_pre_vm_suspend in src/simix/smx_smurf_private.h */
simcall_BODY_vm_suspend(vm);
}
+/**
+ * \ingroup simix_vm_management
+ * \brief Resume the given VM
+ *
+ * \param vm VM
+ */
void simcall_vm_resume(smx_host_t vm)
{
- /*
- * simcall_BODY_ is defined in src/simix/smx_smurf_private.h.
- * This function will jump to SIMIX_pre_vm_resume.
- **/
+ /* will jump to SIMIX_pre_vm_resume in src/simix/smx_smurf_private.h */
simcall_BODY_vm_resume(vm);
}
+/**
+ * \ingroup simix_vm_management
+ * \brief Save the given VM
+ *
+ * \param vm VM
+ */
+void simcall_vm_save(smx_host_t vm)
+{
+ /* will jump to SIMIX_pre_vm_save in src/simix/smx_smurf_private.h */
+ simcall_BODY_vm_save(vm);
+}
+
+/**
+ * \ingroup simix_vm_management
+ * \brief Restore the given VM
+ *
+ * \param vm VM
+ */
+void simcall_vm_restore(smx_host_t vm)
+{
+ /* will jump to SIMIX_pre_vm_restore in src/simix/smx_smurf_private.h */
+ simcall_BODY_vm_restore(vm);
+}
+
+/**
+ * \ingroup simix_vm_management
+ * \brief Shutdown the given VM
+ *
+ * \param vm VM
+ */
void simcall_vm_shutdown(smx_host_t vm)
{
- /* will jump to SIMIX_pre_vm_shutdown */
+ /* will jump to SIMIX_pre_vm_shutdown in src/simix/smx_smurf_private.h */
simcall_BODY_vm_shutdown(vm);
}
+/**
+ * \ingroup simix_vm_management
+ * \brief Destroy the given VM
+ *
+ * \param vm VM
+ */
void simcall_vm_destroy(smx_host_t vm)
{
- /*
- * simcall_BODY_ is defined in src/simix/smx_smurf_private.h.
- * This function will jump to SIMIX_pre_vm_destroy.
- **/
+ /* will jump to SIMIX_pre_vm_destroy in src/simix/smx_smurf_private.h */
simcall_BODY_vm_destroy(vm);
}
+
/**
* \ingroup simix_process_management
* \brief Creates and runs a new SIMIX process.
return SIMIX_vm_get_state(ind_vm);
}
+
/**
- * \brief Function to migrate a SIMIX VM host. This function stops the exection of the
- * VM. All the processes on this VM will pause. The state of the VM is
- * perserved. We can later resume it again.
+ * \brief Function to migrate a SIMIX VM host.
*
* \param host the vm host to migrate (a smx_host_t)
*/
SIMIX_vm_migrate(ind_vm, ind_dst_pm);
}
+
/**
* \brief Function to get the physical host of the given the SIMIX VM host.
*
*/
const char *SIMIX_vm_get_phys_host(smx_host_t ind_vm)
{
- /* jump to vm_ws_get_phys_host(). this will update the vm location. */
+ /* jump to vm_ws_get_phys_host(). this will return the vm name. */
return surf_vm_workstation_model->extension.vm_workstation.get_phys_host(ind_vm);
}
return SIMIX_vm_get_phys_host(ind_vm);
}
+
/**
* \brief Function to suspend a SIMIX VM host. This function stops the exection of the
* VM. All the processes on this VM will pause. The state of the VM is
- * perserved. We can later resume it again.
+ * preserved on memory. We can later resume it again.
*
* \param host the vm host to suspend (a smx_host_t)
*/
SIMIX_vm_suspend(ind_vm);
}
+
/**
* \brief Function to resume a SIMIX VM host. This function restart the execution of the
* VM. All the processes on this VM will run again.
SIMIX_vm_resume(ind_vm);
}
+
+/**
+ * \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 host the vm host to save (a smx_host_t)
+ */
+void SIMIX_vm_save(smx_host_t ind_vm)
+{
+ /* TODO: check state */
+
+ XBT_DEBUG("%lu processes in the VM", xbt_swag_size(SIMIX_host_priv(ind_vm)->process_list));
+
+ /* TODO: do something at the surf level */
+
+ smx_process_t smx_process, smx_process_safe;
+ xbt_swag_foreach_safe(smx_process, smx_process_safe, SIMIX_host_priv(ind_vm)->process_list) {
+ XBT_DEBUG("save %s", SIMIX_host_get_name(ind_vm));
+ /* FIXME: calling a simcall from the SIMIX layer is strange. */
+ simcall_process_save(smx_process);
+ }
+
+ /* TODO: Using the variable of the MSG layer is not clean. */
+ SIMIX_vm_set_state(ind_vm, msg_vm_state_saved);
+}
+
+void SIMIX_pre_vm_save(smx_simcall_t simcall, smx_host_t ind_vm){
+ SIMIX_vm_save(ind_vm);
+}
+
+
+/**
+ * \brief Function to restore a SIMIX VM host. This function restart the execution of the
+ * VM. All the processes on this VM will run again.
+ *
+ * \param host the vm host to restore (a smx_host_t)
+ */
+void SIMIX_vm_restore(smx_host_t ind_vm)
+{
+ /* TODO: check state */
+
+ XBT_DEBUG("%lu processes in the VM", xbt_swag_size(SIMIX_host_priv(ind_vm)->process_list));
+
+ /* TODO: do something at the surf level */
+
+ smx_process_t smx_process, smx_process_safe;
+ xbt_swag_foreach_safe(smx_process, smx_process_safe, SIMIX_host_priv(ind_vm)->process_list) {
+ XBT_DEBUG("restore %s", SIMIX_host_get_name(ind_vm));
+ /* FIXME: calling a simcall from the SIMIX layer is strange. */
+ simcall_process_restore(smx_process);
+ }
+
+ /* TODO: Using the variable of the MSG layer is not clean. */
+ SIMIX_vm_set_state(ind_vm, msg_vm_state_running);
+}
+
+void SIMIX_pre_vm_restore(smx_simcall_t simcall, smx_host_t ind_vm){
+ SIMIX_vm_restore(ind_vm);
+}
+
+
/**
* \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
- * perserved. We can later start it again.
+ * preserved on memory. We can later start it again.
*
* \param host the vm host to shutdown (a smx_host_t)
*/
SIMIX_vm_shutdown(ind_vm, simcall->issuer);
}
+
/**
* \brief Function to destroy a SIMIX VM host.
*