From b176f1f30ac1534c1e299bd01cfe35e4c517c084 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 19 Apr 2019 10:35:14 +0200 Subject: [PATCH] fix GH#133 When a host is turned off, also shutwdown and turn off the VMs hosted by this host. This is a rather crude patch that implies to browse the whole list of existing VMs. A better solution requires a bit more work and time --- src/s4u/s4u_Host.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 46d86bbf9e..a99e6a8680 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -7,6 +7,8 @@ #include "simgrid/s4u/Actor.hpp" #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Exec.hpp" +#include "simgrid/s4u/VirtualMachine.hpp" +#include "src/plugins/vm/VirtualMachineImpl.hpp" #include "src/simix/smx_private.hpp" #include "src/surf/HostImpl.hpp" @@ -98,6 +100,11 @@ void Host::turn_off() { if (is_on()) { simix::simcall([this] { + for (VirtualMachine* const& vm : vm::VirtualMachineImpl::allVms_) + if (vm->get_pm() == this) { + vm->shutdown(); + vm->turn_off(); + } this->pimpl_cpu->turn_off(); this->pimpl_->turn_off(); -- 2.20.1