Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
VM: move content from simix to s4u
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 19 Dec 2016 14:14:01 +0000 (15:14 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 19 Dec 2016 23:11:07 +0000 (00:11 +0100)
12 files changed:
include/simgrid/simix.h
src/msg/msg_vm.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/VirtualMachineImpl.hpp
src/simix/libsmx.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in
src/simix/smx_host_private.h
src/simix/smx_vm.cpp

index 5e02fad..7935d29 100644 (file)
@@ -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);
 /******************************* 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);
 
 XBT_PUBLIC(void) simcall_vm_suspend(sg_host_t vm);
 XBT_PUBLIC(void) simcall_vm_shutdown(sg_host_t vm);
 
index 426cf86..4b6514f 100644 (file)
@@ -879,10 +879,10 @@ void MSG_vm_resume(msg_vm_t vm)
  */
 void MSG_vm_save(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<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->save(issuer);
+  });
 
   if (TRACE_msg_vm_is_enabled()) {
     container_t vm_container = PJ_container_get(vm->cname());
 
   if (TRACE_msg_vm_is_enabled()) {
     container_t vm_container = PJ_container_get(vm->cname());
index 66e0ce6..5c4345a 100644 (file)
@@ -166,11 +166,34 @@ void VirtualMachineImpl::resume()
   vmState_ = SURF_VM_STATE_RUNNING;
 }
 
   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<simgrid::simix::Host>()->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;
   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()
 }
 
 void VirtualMachineImpl::restore()
index 387aaa0..ea04c47 100644 (file)
@@ -68,8 +68,8 @@ public:
   /** @brief Resume the VM */
   virtual void resume();
 
   /** @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();
 
   /** @brief Restore the VM (Not yet implemented) */
   virtual void restore();
index e1de859..347fa98 100644 (file)
@@ -183,17 +183,6 @@ void simcall_vm_resume(sg_host_t vm)
   simcall_BODY_vm_resume(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
 /**
  * \ingroup simix_vm_management
  * \brief Shutdown the given VM
index 6635ff8..1c1a353 100644 (file)
@@ -35,13 +35,6 @@ static inline void simcall_vm_shutdown__set__ind_vm(smx_simcall_t simcall, sg_ho
     simgrid::simix::marshal<sg_host_t>(simcall->args[0], arg);
 }
 
     simgrid::simix::marshal<sg_host_t>(simcall->args[0], arg);
 }
 
-static inline sg_host_t simcall_vm_save__get__ind_vm(smx_simcall_t simcall) {
-  return simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]);
-}
-static inline void simcall_vm_save__set__ind_vm(smx_simcall_t simcall, sg_host_t arg) {
-    simgrid::simix::marshal<sg_host_t>(simcall->args[0], arg);
-}
-
 static inline smx_actor_t simcall_process_kill__get__process(smx_simcall_t simcall) {
   return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
 }
 static inline smx_actor_t simcall_process_kill__get__process(smx_simcall_t simcall) {
   return simgrid::simix::unmarshal<smx_actor_t>(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_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);
 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);
index 7073743..b2da1e1 100644 (file)
@@ -53,12 +53,6 @@ inline static void simcall_BODY_vm_shutdown(sg_host_t ind_vm) {
     return simcall<void, sg_host_t>(SIMCALL_VM_SHUTDOWN, ind_vm);
   }
   
     return simcall<void, sg_host_t>(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<void, sg_host_t>(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);
 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);
index 37a4057..50ce031 100644 (file)
@@ -21,7 +21,6 @@ typedef enum {
   SIMCALL_VM_SUSPEND,
   SIMCALL_VM_RESUME,
   SIMCALL_VM_SHUTDOWN,
   SIMCALL_VM_SUSPEND,
   SIMCALL_VM_RESUME,
   SIMCALL_VM_SHUTDOWN,
-  SIMCALL_VM_SAVE,
   SIMCALL_PROCESS_KILL,
   SIMCALL_PROCESS_KILLALL,
   SIMCALL_PROCESS_CLEANUP,
   SIMCALL_PROCESS_KILL,
   SIMCALL_PROCESS_KILLALL,
   SIMCALL_PROCESS_CLEANUP,
index d7e3514..1e2481f 100644 (file)
@@ -26,7 +26,6 @@ const char* simcall_names[] = {
    "SIMCALL_NONE",  "SIMCALL_VM_SUSPEND",
   "SIMCALL_VM_RESUME",
   "SIMCALL_VM_SHUTDOWN",
    "SIMCALL_NONE",  "SIMCALL_VM_SUSPEND",
   "SIMCALL_VM_RESUME",
   "SIMCALL_VM_SHUTDOWN",
-  "SIMCALL_VM_SAVE",
   "SIMCALL_PROCESS_KILL",
   "SIMCALL_PROCESS_KILLALL",
   "SIMCALL_PROCESS_CLEANUP",
   "SIMCALL_PROCESS_KILL",
   "SIMCALL_PROCESS_KILLALL",
   "SIMCALL_PROCESS_CLEANUP",
@@ -116,11 +115,6 @@ case SIMCALL_VM_SHUTDOWN:
       SIMIX_simcall_answer(simcall);
       break;
 
       SIMIX_simcall_answer(simcall);
       break;
 
-case SIMCALL_VM_SAVE:
-      simcall_HANDLER_vm_save(simcall, simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]));
-      SIMIX_simcall_answer(simcall);
-      break;
-
 case SIMCALL_PROCESS_KILL:
       simcall_HANDLER_process_kill(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]));
       SIMIX_simcall_answer(simcall);
 case SIMCALL_PROCESS_KILL:
       simcall_HANDLER_process_kill(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]));
       SIMIX_simcall_answer(simcall);
index b0478e8..66aa969 100644 (file)
@@ -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_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);
 
 void process_kill(smx_actor_t process);
 void process_killall(int reset_pid);
index 9482e44..2a255b6 100644 (file)
@@ -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_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);
 // --
 
 XBT_PRIVATE void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_actor_t issuer);
 // --
 
index 5714078..49115f1 100644 (file)
@@ -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<simgrid::s4u::VirtualMachine*>(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<simgrid::s4u::VirtualMachine*>(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
 /**
  * @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