From 35844b5c0f5a9e9437b966611f1e624a1c724b2b Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 19 Dec 2016 12:15:36 +0100 Subject: [PATCH] move content from MSG_VM to s4u::VM --- include/simgrid/s4u/VirtualMachine.hpp | 1 + src/msg/msg_vm.cpp | 18 ++---------------- src/plugins/vm/VirtualMachineImpl.cpp | 14 ++++++++++++++ src/plugins/vm/s4u_VirtualMachine.cpp | 4 ++++ 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/simgrid/s4u/VirtualMachine.hpp b/include/simgrid/s4u/VirtualMachine.hpp index de3ecc0fdf..7ee8659d1c 100644 --- a/include/simgrid/s4u/VirtualMachine.hpp +++ b/include/simgrid/s4u/VirtualMachine.hpp @@ -53,6 +53,7 @@ public: void parameters(vm_params_t params); void setParameters(vm_params_t params); double getRamsize(); + simgrid::s4u::Host* pm(); /* FIXME: protect me */ simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr; diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 86c8380d89..426cf86e09 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -901,21 +901,7 @@ void MSG_vm_save(msg_vm_t vm) void MSG_vm_restore(msg_vm_t vm) { simgrid::simix::kernelImmediate([vm]() { - simgrid::s4u::VirtualMachine* typedVm = static_cast(vm); - - if (typedVm->pimpl_vm_->getState() != SURF_VM_STATE_SAVED) - THROWF(vm_error, 0, "VM(%s) was not saved", vm->cname()); - - XBT_DEBUG("restore VM(%s), where %d processes exist", vm->cname(), xbt_swag_size(sg_host_simix(vm)->process_list)); - - /* jump to vm_ws_restore() */ - typedVm->pimpl_vm_->restore(); - - smx_actor_t smx_process, smx_process_safe; - xbt_swag_foreach_safe(smx_process, smx_process_safe, sg_host_simix(vm)->process_list) { - XBT_DEBUG("resume %s", smx_process->name.c_str()); - SIMIX_process_resume(smx_process); - } + static_cast(vm)->pimpl_vm_->restore(); }); if (TRACE_msg_vm_is_enabled()) { @@ -930,7 +916,7 @@ void MSG_vm_restore(msg_vm_t vm) */ msg_host_t MSG_vm_get_pm(msg_vm_t vm) { - return static_cast(vm)->pimpl_vm_->getPm(); + return static_cast(vm)->pm(); } /** @brief Set a CPU bound for a given VM. diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index a34c8a3e00..66e0ce6440 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -6,6 +6,8 @@ #include "src/plugins/vm/VirtualMachineImpl.hpp" #include "simgrid/s4u/VirtualMachine.hpp" +#include "src/simix/ActorImpl.hpp" +#include "src/simix/smx_host_private.h" #include @@ -173,9 +175,21 @@ void VirtualMachineImpl::save() void VirtualMachineImpl::restore() { + if (getState() != SURF_VM_STATE_SAVED) + THROWF(vm_error, 0, "Cannot restore VM %s: it was not saved", piface_->cname()); + + xbt_swag_t process_list = piface_->extension()->process_list; + XBT_DEBUG("Restore VM %s, where %d processes exist", piface_->cname(), xbt_swag_size(process_list)); + vmState_ = SURF_VM_STATE_RESTORING; action_->resume(); vmState_ = SURF_VM_STATE_RUNNING; + + smx_actor_t smx_process, smx_process_safe; + xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) { + XBT_DEBUG("resume %s", smx_process->cname()); + SIMIX_process_resume(smx_process); + } } /** @brief returns the physical machine on which the VM is running **/ diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 86a184feb8..05d21f9ecd 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -68,6 +68,10 @@ double VirtualMachine::getRamsize() { return pimpl_vm_->params_.ramsize; } +simgrid::s4u::Host* VirtualMachine::pm() +{ + return pimpl_vm_->getPm(); +} /** @brief Retrieve a copy of the parameters of that VM/PM * @details The ramsize and overcommit fields are used on the PM too */ -- 2.20.1