From 30e53e313b361eadd271dd83184627f43d480491 Mon Sep 17 00:00:00 2001 From: Samuel Lepetit Date: Wed, 4 Jul 2012 16:31:46 +0200 Subject: [PATCH] Add MSG_vm_reboot --- include/msg/msg.h | 2 ++ src/msg/msg_vm.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) 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 */ -- 2.20.1