From: Takahiro Hirofuchi Date: Thu, 31 Jan 2013 21:44:29 +0000 (+0100) Subject: fix msg_vm_shutdown X-Git-Tag: v3_11_beta~297^2^2~114^2~5 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/696a185839cb7e7b4974f9dfd05d6e1ed3101815 fix msg_vm_shutdown --- diff --git a/include/msg/datatypes.h b/include/msg/datatypes.h index 755d900632..e5b3ea12ec 100644 --- a/include/msg/datatypes.h +++ b/include/msg/datatypes.h @@ -93,10 +93,10 @@ typedef struct msg_hypervisor { 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; diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index ad6a474fea..aebd0c3ba6 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -164,11 +164,9 @@ void MSG_vm_shutdown(msg_vm_t vm) /* 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 - } diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index f9cad2c50d..79a9fb12f6 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -292,6 +292,12 @@ void simcall_vm_start(smx_host_t 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) { /* will jump to SIMIX_pre_vm_destroy */ diff --git a/src/simix/smx_vm.c b/src/simix/smx_vm.c index 8d82b17f5b..7429d96d40 100644 --- a/src/simix/smx_vm.c +++ b/src/simix/smx_vm.c @@ -81,6 +81,33 @@ int SIMIX_pre_vm_state(smx_host_t vm){ 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. *