From: Samuel Lepetit Date: Wed, 4 Jul 2012 14:31:46 +0000 (+0200) Subject: Add MSG_vm_reboot X-Git-Tag: v3_8~336 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/30e53e313b361eadd271dd83184627f43d480491 Add MSG_vm_reboot --- diff --git a/include/msg/msg.h b/include/msg/msg.h index 843c881e6e..192c44faba 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -340,6 +340,8 @@ XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm); // Simulate the fact of reading th XBT_PUBLIC(void) MSG_vm_shutdown(msg_vm_t vm); // killall +XBT_PUBLIC(void) MSG_vm_reboot(msg_vm_t vm); + XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm); XBT_PUBLIC(xbt_dynar_t) MSG_vms_as_dynar(void); diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index 4b9e0ad518..0dc2439aa9 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -157,7 +157,27 @@ void MSG_vm_shutdown(msg_vm_t vm) MSG_process_kill(process); } } +/** + * \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); + } +} /** @brief Destroy a msg_vm_t. * @ingroup msg_VMs */