From 13f164230f8da32094edbe9811a81221454d461b Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 19 Dec 2016 15:14:01 +0100 Subject: [PATCH] VM: move content from simix to s4u --- include/simgrid/simix.h | 1 - src/msg/msg_vm.cpp | 8 ++++---- src/plugins/vm/VirtualMachineImpl.cpp | 25 +++++++++++++++++++++++- src/plugins/vm/VirtualMachineImpl.hpp | 4 ++-- src/simix/libsmx.cpp | 11 ----------- src/simix/popping_accessors.h | 8 -------- src/simix/popping_bodies.cpp | 6 ------ src/simix/popping_enum.h | 1 - src/simix/popping_generated.cpp | 6 ------ src/simix/simcalls.in | 1 - src/simix/smx_host_private.h | 2 -- src/simix/smx_vm.cpp | 28 --------------------------- 12 files changed, 30 insertions(+), 71 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 5e02fad5bb..7935d29187 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -260,7 +260,6 @@ XBT_PUBLIC(e_smx_state_t) simcall_execution_wait(smx_activity_t execution); /******************************* VM simcalls ********************************/ // Create the vm_workstation at the SURF level XBT_PUBLIC(void) simcall_vm_resume(sg_host_t vm); -XBT_PUBLIC(void) simcall_vm_save(sg_host_t vm); XBT_PUBLIC(void) simcall_vm_suspend(sg_host_t vm); XBT_PUBLIC(void) simcall_vm_shutdown(sg_host_t vm); diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 426cf86e09..4b6514f687 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -879,10 +879,10 @@ void MSG_vm_resume(msg_vm_t vm) */ void MSG_vm_save(msg_vm_t vm) { - if (MSG_vm_is_migrating(vm)) - THROWF(vm_error, 0, "Cannot save VM '%s', which is migrating.", vm->cname()); - - simcall_vm_save(vm); + smx_actor_t issuer=SIMIX_process_self(); + simgrid::simix::kernelImmediate([vm,issuer]() { + static_cast(vm)->pimpl_vm_->save(issuer); + }); if (TRACE_msg_vm_is_enabled()) { container_t vm_container = PJ_container_get(vm->cname()); diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 66e0ce6440..5c4345ab8c 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -166,11 +166,34 @@ void VirtualMachineImpl::resume() vmState_ = SURF_VM_STATE_RUNNING; } -void VirtualMachineImpl::save() +/** + * @brief Function to save a VM. + * This function is the same as vm_suspend, but the state of the VM is saved to the disk, and not preserved in memory. + * We can later restore it again. + * + * @param vm the vm host to save (a sg_host_t) + */ +void VirtualMachineImpl::save(smx_actor_t issuer) { + if (isMigrating) + THROWF(vm_error, 0, "Cannot save VM %s: it is migrating.", piface_->cname()); + + if (getState() != SURF_VM_STATE_RUNNING) + THROWF(vm_error, 0, "Cannot save VM %s: it is not running.", piface_->cname()); + + xbt_swag_t process_list = piface_->extension()->process_list; + + XBT_DEBUG("Save VM %s, where %d processes exist", piface_->cname(), xbt_swag_size(process_list)); + vmState_ = SURF_VM_STATE_SAVING; action_->suspend(); vmState_ = SURF_VM_STATE_SAVED; + + smx_actor_t smx_process, smx_process_safe; + xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) { + XBT_DEBUG("suspend %s", smx_process->cname()); + SIMIX_process_suspend(smx_process, issuer); + } } void VirtualMachineImpl::restore() diff --git a/src/plugins/vm/VirtualMachineImpl.hpp b/src/plugins/vm/VirtualMachineImpl.hpp index 387aaa0c39..ea04c471f8 100644 --- a/src/plugins/vm/VirtualMachineImpl.hpp +++ b/src/plugins/vm/VirtualMachineImpl.hpp @@ -68,8 +68,8 @@ public: /** @brief Resume the VM */ virtual void resume(); - /** @brief Save the VM (Not yet implemented) */ - virtual void save(); + /** @brief Save the VM */ + virtual void save(smx_actor_t issuer); /** @brief Restore the VM (Not yet implemented) */ virtual void restore(); diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index e1de85955c..347fa98355 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -183,17 +183,6 @@ void simcall_vm_resume(sg_host_t vm) simcall_BODY_vm_resume(vm); } -/** - * \ingroup simix_vm_management - * \brief Save the given VM - * - * \param vm VM - */ -void simcall_vm_save(sg_host_t vm) -{ - simcall_BODY_vm_save(vm); -} - /** * \ingroup simix_vm_management * \brief Shutdown the given VM diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 6635ff8f34..1c1a3532e5 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -35,13 +35,6 @@ static inline void simcall_vm_shutdown__set__ind_vm(smx_simcall_t simcall, sg_ho simgrid::simix::marshal(simcall->args[0], arg); } -static inline sg_host_t simcall_vm_save__get__ind_vm(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline void simcall_vm_save__set__ind_vm(smx_simcall_t simcall, sg_host_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); -} - static inline smx_actor_t simcall_process_kill__get__process(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); } @@ -1134,7 +1127,6 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f XBT_PRIVATE void simcall_HANDLER_vm_suspend(smx_simcall_t simcall, sg_host_t ind_vm); XBT_PRIVATE void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm); -XBT_PRIVATE void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t ind_vm); XBT_PRIVATE void simcall_HANDLER_process_kill(smx_simcall_t simcall, smx_actor_t process); XBT_PRIVATE void simcall_HANDLER_process_killall(smx_simcall_t simcall, int reset_pid); XBT_PRIVATE void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 7073743cba..b2da1e10a7 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -53,12 +53,6 @@ inline static void simcall_BODY_vm_shutdown(sg_host_t ind_vm) { return simcall(SIMCALL_VM_SHUTDOWN, ind_vm); } -inline static void simcall_BODY_vm_save(sg_host_t ind_vm) { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) simcall_HANDLER_vm_save(&SIMIX_process_self()->simcall, ind_vm); - return simcall(SIMCALL_VM_SAVE, ind_vm); - } - inline static void simcall_BODY_process_kill(smx_actor_t process) { /* Go to that function to follow the code flow through the simcall barrier */ if (0) simcall_HANDLER_process_kill(&SIMIX_process_self()->simcall, process); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 37a4057877..50ce0314ae 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -21,7 +21,6 @@ typedef enum { SIMCALL_VM_SUSPEND, SIMCALL_VM_RESUME, SIMCALL_VM_SHUTDOWN, - SIMCALL_VM_SAVE, SIMCALL_PROCESS_KILL, SIMCALL_PROCESS_KILLALL, SIMCALL_PROCESS_CLEANUP, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index d7e3514049..1e2481f350 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -26,7 +26,6 @@ const char* simcall_names[] = { "SIMCALL_NONE", "SIMCALL_VM_SUSPEND", "SIMCALL_VM_RESUME", "SIMCALL_VM_SHUTDOWN", - "SIMCALL_VM_SAVE", "SIMCALL_PROCESS_KILL", "SIMCALL_PROCESS_KILLALL", "SIMCALL_PROCESS_CLEANUP", @@ -116,11 +115,6 @@ case SIMCALL_VM_SHUTDOWN: SIMIX_simcall_answer(simcall); break; -case SIMCALL_VM_SAVE: - simcall_HANDLER_vm_save(simcall, simgrid::simix::unmarshal(simcall->args[0])); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_PROCESS_KILL: simcall_HANDLER_process_kill(simcall, simgrid::simix::unmarshal(simcall->args[0])); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index b0478e8260..66aa969ca9 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -39,7 +39,6 @@ void vm_suspend(sg_host_t ind_vm); void vm_resume(sg_host_t ind_vm) [[nohandler]]; void vm_shutdown(sg_host_t ind_vm); -void vm_save(sg_host_t ind_vm); void process_kill(smx_actor_t process); void process_killall(int reset_pid); diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 9482e444ff..2a255b6b75 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -71,8 +71,6 @@ XBT_PRIVATE void SIMIX_vm_resume(sg_host_t ind_vm); XBT_PRIVATE void SIMIX_vm_suspend(sg_host_t ind_vm, smx_actor_t issuer); // -- -XBT_PRIVATE void SIMIX_vm_save(sg_host_t ind_vm, smx_actor_t issuer); - XBT_PRIVATE void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_actor_t issuer); // -- diff --git a/src/simix/smx_vm.cpp b/src/simix/smx_vm.cpp index 5714078042..49115f1753 100644 --- a/src/simix/smx_vm.cpp +++ b/src/simix/smx_vm.cpp @@ -71,34 +71,6 @@ void SIMIX_vm_resume(sg_host_t vm) } } -/** - * @brief Function to save a SIMIX VM host. - * This function is the same as vm_suspend, but the state of the VM is saved to the disk, and not preserved on memory. - * We can later restore it again. - * - * @param vm the vm host to save (a sg_host_t) - */ -void SIMIX_vm_save(sg_host_t vm, smx_actor_t issuer) -{ - if (static_cast(vm)->pimpl_vm_->getState() != SURF_VM_STATE_RUNNING) - THROWF(vm_error, 0, "VM(%s) is not running", vm->cname()); - - XBT_DEBUG("save VM(%s), where %d processes exist", vm->cname(), xbt_swag_size(sg_host_simix(vm)->process_list)); - - static_cast(vm)->pimpl_vm_->save(); - - 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("suspend %s", smx_process->cname()); - SIMIX_process_suspend(smx_process, issuer); - } -} - -void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t vm) -{ - SIMIX_vm_save(vm, simcall->issuer); -} - /** * @brief Function to shutdown a SIMIX VM host. This function powers off the * VM. All the processes on this VM will be killed. But, the state of the VM is -- 2.20.1