From b9d2f7277242a82702b73e4ccdf63aec98855b5e Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 18 Dec 2017 09:48:42 +0100 Subject: [PATCH 1/1] mv VM shutdown to the plugin simplify MSG_vm_destroy --- include/simgrid/s4u/VirtualMachine.hpp | 1 + src/msg/msg_vm.cpp | 11 +++-------- src/plugins/vm/s4u_VirtualMachine.cpp | 6 ++++++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/simgrid/s4u/VirtualMachine.hpp b/include/simgrid/s4u/VirtualMachine.hpp index 6bcf4f037b..a655e4905e 100644 --- a/include/simgrid/s4u/VirtualMachine.hpp +++ b/include/simgrid/s4u/VirtualMachine.hpp @@ -48,6 +48,7 @@ public: void start(); void suspend(); void resume(); + void shutdown(); bool isMigrating(); diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 2d9e4ab526..34ab03d4a7 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -176,11 +176,10 @@ void MSG_vm_destroy(msg_vm_t vm) THROWF(vm_error, 0, "Cannot destroy VM '%s', which is migrating.", vm->getCname()); /* First, terminate all processes on the VM if necessary */ - if (MSG_vm_is_running(vm)) - MSG_vm_shutdown(vm); + vm->shutdown(); /* Then, destroy the VM object */ - simgrid::simix::kernelImmediate([vm]() { vm->destroy(); }); + vm->destroy(); if (TRACE_msg_vm_is_enabled()) { container_t container = simgrid::instr::Container::byName(vm->getName()); @@ -213,11 +212,7 @@ void MSG_vm_start(msg_vm_t vm) */ void MSG_vm_shutdown(msg_vm_t vm) { - smx_actor_t issuer = SIMIX_process_self(); - simgrid::simix::kernelImmediate([vm, issuer]() { vm->pimpl_vm_->shutdown(issuer); }); - - // Make sure that processes in the VM are killed in this scheduling round before processing (eg with the VM destroy) - MSG_process_sleep(0.); + vm->shutdown(); } static std::string get_mig_process_tx_name(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm) diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 8bda7e7137..3ee05b2aae 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -104,6 +104,12 @@ void VirtualMachine::resume() pimpl_vm_->resume(); } +void VirtualMachine::shutdown() +{ + smx_actor_t issuer = SIMIX_process_self(); + simgrid::simix::kernelImmediate([this, issuer]() { pimpl_vm_->shutdown(issuer); }); +} + bool VirtualMachine::isMigrating() { return pimpl_vm_ && pimpl_vm_->isMigrating; -- 2.20.1