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;
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)
{
/* will jump to SIMIX_pre_vm_destroy */
return SIMIX_get_vm_state(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(smx_host)->process_list));
+
+ xbt_swag_foreach_safe(smx_process, SIMIX_host_priv(smx_host)->process_list) {
+ XBT_DEBUG("kill %s", SIMIX_host_get_name(smx_host));
+ simcall_process_kill(smx_process);
+ }
+
+ /* TODO: Using the variable of the MSG layer is not clean. */
+ SIMIX_set_vm_state(vm, 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.
*