X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9ceefed14c83a0f6ea5f78e3acafd53181dc4fa1..f9b13d923d31bb0336aeeaab6d5b7ba33812f3f7:/src/kernel/resource/VirtualMachineImpl.cpp diff --git a/src/kernel/resource/VirtualMachineImpl.cpp b/src/kernel/resource/VirtualMachineImpl.cpp index de7fddbd8f..ae03dc316b 100644 --- a/src/kernel/resource/VirtualMachineImpl.cpp +++ b/src/kernel/resource/VirtualMachineImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2022. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -75,11 +75,13 @@ static void add_active_exec(s4u::Exec const& task) } } -static void remove_active_exec(s4u::Activity& task) +static void remove_active_exec(s4u::Activity const& task) { - auto* exec = dynamic_cast(&task); + const auto* exec = dynamic_cast(&task); if (exec == nullptr) return; + if (not exec->is_assigned()) + return; const s4u::VirtualMachine* vm = dynamic_cast(exec->get_host()); if (vm != nullptr) { VirtualMachineImpl* vm_impl = vm->get_vm_impl(); @@ -116,9 +118,9 @@ static void remove_active_activity(kernel::activity::ActivityImpl const& act) VMModel::VMModel(const std::string& name) : HostModel(name) { - s4u::Host::on_state_change.connect(host_state_change); - s4u::Exec::on_start.connect(add_active_exec); - s4u::Activity::on_completion.connect(remove_active_exec); + s4u::Host::on_state_change_cb(host_state_change); + s4u::Exec::on_start_cb(add_active_exec); + s4u::Activity::on_completion_cb(remove_active_exec); activity::ActivityImpl::on_resumed.connect(add_active_activity); activity::ActivityImpl::on_suspended.connect(remove_active_activity); } @@ -193,7 +195,6 @@ VirtualMachineImpl::VirtualMachineImpl(const std::string& name, s4u::VirtualMach /** @brief A physical host does not disappear in the current SimGrid code, but a VM may disappear during a simulation */ void VirtualMachineImpl::vm_destroy() { - s4u::VirtualMachine::on_destruction(*piface_); /* I was already removed from the allVms set if the VM was destroyed cleanly */ auto iter = find(allVms_.begin(), allVms_.end(), piface_); if (iter != allVms_.end()) @@ -204,7 +205,7 @@ void VirtualMachineImpl::vm_destroy() xbt_assert(ret, "Bug: some resource still remains"); } -void VirtualMachineImpl::suspend(smx_actor_t issuer) +void VirtualMachineImpl::suspend(const actor::ActorImpl* issuer) { if (vm_state_ != s4u::VirtualMachine::State::RUNNING) throw VmFailureException(XBT_THROW_POINT, @@ -252,7 +253,7 @@ void VirtualMachineImpl::resume() * * @param issuer the actor requesting the shutdown */ -void VirtualMachineImpl::shutdown(smx_actor_t issuer) +void VirtualMachineImpl::shutdown(actor::ActorImpl* issuer) { if (vm_state_ != s4u::VirtualMachine::State::RUNNING) XBT_VERB("Shutting down the VM %s even if it's not running but in state %s", piface_->get_cname(),