X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9eee526194338d66601c96c441b53fa37f77c0dd..856f8fd502384979b5029aa67d026df79e5c6d70:/src/plugins/vm/VirtualMachineImpl.cpp diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 07bb1691c9..9e7fa1e32f 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -4,10 +4,10 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/plugins/vm/VirtualMachineImpl.hpp" +#include "src/include/surf/surf.hpp" #include "src/simix/ActorImpl.hpp" #include "src/simix/smx_host_private.hpp" - -#include // xbt_log_no_loc +#include "xbt/asserts.h" // xbt_log_no_loc XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf, "Logging specific to the SURF VM module"); @@ -47,7 +47,7 @@ static void hostStateChange(s4u::Host& host) std::vector trash; /* Find all VMs living on that host */ for (s4u::VirtualMachine* const& vm : VirtualMachineImpl::allVms_) - if (vm->getPm() == &host) + if (vm->get_pm() == &host) trash.push_back(vm); for (s4u::VirtualMachine* vm : trash) vm->shutdown(); @@ -90,9 +90,9 @@ double VMModel::next_occuring_event(double now) surf::Cpu* cpu = ws_vm->pimpl_cpu; double solved_value = - ws_vm->getImpl()->action_->get_variable()->get_value(); // this is X1 in comment above, what - // this VM got in the sharing on the PM - XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->get_cname(), ws_vm->getPm()->get_cname()); + ws_vm->get_impl()->action_->get_variable()->get_value(); // this is X1 in comment above, what + // this VM got in the sharing on the PM + XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->get_cname(), ws_vm->get_pm()->get_cname()); xbt_assert(cpu->get_model() == surf_cpu_model_vm); kernel::lmm::System* vcpu_system = cpu->get_model()->get_maxmin_system(); @@ -135,39 +135,37 @@ VirtualMachineImpl::~VirtualMachineImpl() allVms_.erase(iter); /* Free the cpu_action of the VM. */ - XBT_ATTRIB_UNUSED int ret = action_->unref(); - xbt_assert(ret == 1, "Bug: some resource still remains"); + XBT_ATTRIB_UNUSED bool ret = action_->unref(); + xbt_assert(ret, "Bug: some resource still remains"); } void VirtualMachineImpl::suspend(smx_actor_t issuer) { - if (get_state() != SURF_VM_STATE_RUNNING) + if (get_state() != s4u::VirtualMachine::state::RUNNING) THROWF(vm_error, 0, "Cannot suspend VM %s: it is not running.", piface_->get_cname()); - if (issuer->host == piface_) + if (issuer->host_ == piface_) THROWF(vm_error, 0, "Actor %s cannot suspend the VM %s in which it runs", issuer->get_cname(), piface_->get_cname()); - auto& process_list = piface_->extension()->process_list; XBT_DEBUG("suspend VM(%s), where %zu processes exist", piface_->get_cname(), process_list.size()); action_->suspend(); for (auto& smx_process : process_list) { - XBT_DEBUG("suspend %s", smx_process.name.c_str()); + XBT_DEBUG("suspend %s", smx_process.get_cname()); smx_process.suspend(issuer); } XBT_DEBUG("suspend all processes on the VM done done"); - vm_state_ = SURF_VM_STATE_SUSPENDED; + vm_state_ = s4u::VirtualMachine::state::SUSPENDED; } void VirtualMachineImpl::resume() { - if (get_state() != SURF_VM_STATE_SUSPENDED) + if (get_state() != s4u::VirtualMachine::state::SUSPENDED) THROWF(vm_error, 0, "Cannot resume VM %s: it was not suspended", piface_->get_cname()); - auto& process_list = piface_->extension()->process_list; XBT_DEBUG("Resume VM %s, containing %zu processes.", piface_->get_cname(), process_list.size()); action_->resume(); @@ -177,7 +175,7 @@ void VirtualMachineImpl::resume() smx_process.resume(); } - vm_state_ = SURF_VM_STATE_RUNNING; + vm_state_ = s4u::VirtualMachine::state::RUNNING; } /** @brief Power off a VM. @@ -189,16 +187,16 @@ void VirtualMachineImpl::resume() */ void VirtualMachineImpl::shutdown(smx_actor_t issuer) { - if (get_state() != SURF_VM_STATE_RUNNING) { + if (get_state() != s4u::VirtualMachine::state::RUNNING) { const char* stateName = "(unknown state)"; switch (get_state()) { - case SURF_VM_STATE_CREATED: + case s4u::VirtualMachine::state::CREATED: stateName = "created, but not yet started"; break; - case SURF_VM_STATE_SUSPENDED: + case s4u::VirtualMachine::state::SUSPENDED: stateName = "suspended"; break; - case SURF_VM_STATE_DESTROYED: + case s4u::VirtualMachine::state::DESTROYED: stateName = "destroyed"; break; default: /* SURF_VM_STATE_RUNNING or unexpected values */ @@ -208,16 +206,15 @@ void VirtualMachineImpl::shutdown(smx_actor_t issuer) XBT_VERB("Shutting down the VM %s even if it's not running but %s", piface_->get_cname(), stateName); } - auto& process_list = piface_->extension()->process_list; XBT_DEBUG("shutdown VM %s, that contains %zu processes", piface_->get_cname(), process_list.size()); for (auto& smx_process : process_list) { XBT_DEBUG("kill %s@%s on behalf of %s which shutdown that VM.", smx_process.get_cname(), - smx_process.host->get_cname(), issuer->get_cname()); + smx_process.host_->get_cname(), issuer->get_cname()); SIMIX_process_kill(&smx_process, issuer); } - set_state(SURF_VM_STATE_DESTROYED); + set_state(s4u::VirtualMachine::state::DESTROYED); /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */ } @@ -252,7 +249,8 @@ void VirtualMachineImpl::set_physical_host(s4u::Host* destination) new_cpu_action->set_bound(old_bound); } - xbt_assert(action_->unref() == 1, "Bug: some resource still remains"); + XBT_ATTRIB_UNUSED bool ret = action_->unref(); + xbt_assert(ret, "Bug: some resource still remains"); action_ = new_cpu_action;