xbt_dynar_t vms; // vms on this hypervisor
msg_host_t host; // physical host of this hypervisor
- /* The hypervisor object does not have parameters like the number of CPU
- Ê * cores and the size of memory. These parameters come from those of the
- Ê * physical host.
- Ê **/
+/* The hypervisor object does not have parameters like the number of CPU
+* cores and the size of memory. These parameters come from those of the
+* physical host.
+**/
int overcommit;
} s_msg_hypervisor_t;
*/
XBT_PUBLIC_DATA(surf_model_t) surf_workstation_model;
+/** \ingroup SURF_models
+ * \brief The vm_workstation model
+ *
+ * Note that when you create an API on top of SURF,
+ * the vm_workstation model should be the only one you use
+ * because depending on the platform model, the network model and the CPU model
+ * may not exist.
+ */
+XBT_PUBLIC_DATA(surf_model_t) surf_vm_workstation_model;
+
/** \ingroup SURF_models
* \brief Initializes the platform with a compound workstation model
*
/* msg_vm_t equals to msg_host_t */
simcall_vm_shutdown(vm);
- /* taka: not yet confirmed */
- #ifdef HAVE_TRACING
- TRACE_msg_vm_kill(vm);
- #endif
-
+ // #ifdef HAVE_TRACING
+ // TRACE_msg_vm_(vm);
+ // #endif
}
// vm->location = destination;
//}
//
-///** @brief Immediately suspend the execution of all processes within the given VM.
-// * @ingroup msg_VMs
-// *
-// * 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 suspend to you.
-// */
-//void MSG_vm_suspend(msg_vm_t vm) {
-// unsigned int cpt;
-// msg_process_t process;
-// xbt_dynar_foreach(vm->processes,cpt,process) {
-// XBT_DEBUG("suspend process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
-// MSG_process_suspend(process);
-// }
-//
-// #ifdef HAVE_TRACING
-// TRACE_msg_vm_suspend(vm);
-// #endif
-//}
+
+/** @brief Immediately suspend the execution of all processes within the given VM.
+ * @ingroup msg_VMs
+ *
+ * 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 suspend to you.
+ */
+void MSG_vm_suspend(msg_vm_t vm)
+{
+ simcall_vm_suspend(vm);
+
+ #ifdef HAVE_TRACING
+ TRACE_msg_vm_suspend(vm);
+ #endif
+#if 0
+ unsigned int cpt;
+ msg_process_t process;
+ xbt_dynar_foreach(vm->processes,cpt,process) {
+ XBT_DEBUG("suspend process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
+ MSG_process_suspend(process);
+ }
+#endif
+}
+
//
//
///** @brief Immediately resumes the execution of all processes within the given VM.
// xbt_dynar_free(&new_processes);
//}
//
-///** @brief Destroy a msg_vm_t.
-// * @ingroup msg_VMs
-// */
-//void MSG_vm_destroy(msg_vm_t vm)
-//{
-// simcall_vm_destroy(vm);
-//
-//#if 0
-// unsigned int cpt;
-// msg_process_t process;
-// xbt_dynar_foreach(vm->processes,cpt,process) {
-// //FIXME: Slow ?
-// simdata_process_t simdata = simcall_process_get_data(process);
-// simdata->vm = NULL;
-// }
-//
-// #ifdef HAVE_TRACING
-// TRACE_msg_vm_end(vm);
-// #endif
-//
-//
-// xbt_dynar_free(&vm->processes);
-// xbt_free(vm);
-//#endif
-//}
+
+/** @brief Destroy a VM. Destroy the VM object from the simulation.
+ * @ingroup msg_VMs
+ */
+void MSG_vm_destroy(msg_vm_t vm)
+{
+ /* First, terminate all processes on the VM */
+ simcall_vm_shutdown(vm);
+
+ /* Then, destroy the VM object */
+ simcall_vm_destroy(vm);
+
+ #ifdef HAVE_TRACING
+ TRACE_msg_vm_end(vm);
+ #endif
+
+#if 0
+ unsigned int cpt;
+ msg_process_t process;
+ xbt_dynar_foreach(vm->processes,cpt,process) {
+ //FIXME: Slow ?
+ simdata_process_t simdata = simcall_process_get_data(process);
+ simdata->vm = NULL;
+ }
+
+ xbt_dynar_free(&vm->processes);
+ xbt_free(vm);
+#endif
+}
ACTION(SIMCALL_VM_SET_STATE, vm_set_state, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t), TINT(state)) sep \
ACTION(SIMCALL_VM_GET_STATE, vm_get_state, WITH_ANSWER, TINT(result), TSPEC(ind_vm, smx_host_t)) sep \
ACTION(SIMCALL_VM_DESTROY, vm_destroy, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t)) sep \
+ACTION(SIMCALL_VM_SUSPEND, vm_suspend, 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_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)) sep \
}
void simcall_vm_start(smx_host_t vm) {
+{
+ simcall_BODY_set_vm_state(vm, msg_vm_state_running);
+}
+
+void simcall_vm_suspend(smx_host_t vm)
+{
+ /* will jump to SIMIX_pre_vm_suspend */
+ simcall_BODY_vm_suspend(vm);
+}
- simcall_BODY_set_vm_state(vm, msg_vm_state_running);
+void simcall_vm_shutdown(smx_host_t vm)
+{
+ /* will jump to SIMIX_pre_vm_shutdown */
+ simcall_BODY_vm_shutdown(vm);
}
-void simcall_vm_destroy(smx_host_t 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.
+ **/
simcall_BODY_vm_destroy(vm);
}
return SIMIX_get_vm_state(ind_vm);
}
+/**
+ * \brief Function to suspend 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.
+ *
+ * \param host the vm host to suspend (a smx_host_t)
+ */
+void SIMIX_vm_suspend(smx_host_t host)
+{
+ /* TODO: check state */
+
+ XBT_DEBUG("%lu processes in the VM", xbt_swag_size(SIMIX_host_priv(host)->process_list));
+
+ smx_process_t smx_process, smx_process_safe;
+ xbt_swag_foreach_safe(smx_process, smx_process_safe, SIMIX_host_priv(host)->process_list) {
+ XBT_DEBUG("suspend %s", SIMIX_host_get_name(host));
+ simcall_process_suspend(smx_process);
+ }
+
+ /* TODO: Using the variable of the MSG layer is not clean. */
+ SIMIX_set_vm_state(host, msg_vm_state_suspended);
+}
+
+void SIMIX_pre_vm_suspend(smx_simcall_t simcall, smx_host_t vm){
+ SIMIX_vm_suspend(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.
+ *
+ * \param host the vm host to shutdown (a smx_host_t)
+ */
+void SIMIX_vm_shutdown(smx_host_t host)
+{
+ /* TODO: check state */
+
+ XBT_DEBUG("%lu processes in the VM", xbt_swag_size(SIMIX_host_priv(host)->process_list));
+
+ smx_process_t smx_process, smx_process_safe;
+ xbt_swag_foreach_safe(smx_process, smx_process_safe, SIMIX_host_priv(host)->process_list) {
+ XBT_DEBUG("kill %s", SIMIX_host_get_name(host));
+ simcall_process_kill(smx_process);
+ }
+
+ /* TODO: Using the variable of the MSG layer is not clean. */
+ SIMIX_set_vm_state(host, msg_vm_state_sleeping);
+}
+
+void SIMIX_pre_vm_shutdown(smx_simcall_t simcall, smx_host_t vm){
+ SIMIX_vm_shutdown(vm);
+}
+
/**
* \brief Function to destroy a SIMIX VM host.
*
surf_vm_workstation_model->extension.vm_workstation.destroy(ind_vm);
}
-void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t ind_vm){
- SIMIX_vm_destroy(ind_vm);
+void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t vm){
+ SIMIX_vm_destroy(vm);
}
}
/* there is no element at any level, so delete the key */
- xbt_dict_remove(lib->dict, key)
+ xbt_dict_remove(lib->dict, key);
}
void *xbt_lib_get_or_null(xbt_lib_t lib, const char *key, int level)