Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert another VM simcall into a s4u method
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 19 Dec 2016 14:38:57 +0000 (15:38 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 19 Dec 2016 23:11:07 +0000 (00:11 +0100)
include/simgrid/simix.h
src/msg/msg_vm.cpp
src/plugins/vm/VirtualMachineImpl.cpp
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 7935d29..8d06139 100644 (file)
@@ -258,8 +258,6 @@ XBT_PUBLIC(void) simcall_execution_set_bound(smx_activity_t execution, double bo
 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_suspend(sg_host_t vm);
 XBT_PUBLIC(void) simcall_vm_shutdown(sg_host_t vm);
 
index 4b6514f..2f3b93d 100644 (file)
@@ -323,11 +323,9 @@ static int migration_rx_fun(int argc, char *argv[])
     /* precopy migration makes the VM temporally paused */
     xbt_assert(vm->pimpl_vm_->getState() == SURF_VM_STATE_SUSPENDED);
 
-    /* jump to vm_ws_xigrate(). this will update the vm location. */
+    /* Update the vm location and resume it */
     vm->pimpl_vm_->migrate(dst_pm);
-
-    /* Resume the VM */
-    SIMIX_vm_resume(vm);
+    vm->pimpl_vm_->resume();
   });
 
   {
@@ -723,7 +721,7 @@ static int migration_tx_fun(int argc, char *argv[])
   catch(xbt_ex& e) {
     //hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
     // Stop the dirty page tracking an return (there is no memory space to release)
-    simcall_vm_resume(ms->vm);
+    static_cast<simgrid::s4u::VirtualMachine*>(ms->vm)->pimpl_vm_->resume();
     return 0;
   }
 
@@ -858,7 +856,7 @@ void MSG_vm_suspend(msg_vm_t vm)
  */
 void MSG_vm_resume(msg_vm_t vm)
 {
-  simcall_vm_resume(vm);
+  static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->resume();
 
   if (TRACE_msg_vm_is_enabled()) {
     container_t vm_container = PJ_container_get(vm->cname());
index 5c4345a..74d2ea7 100644 (file)
@@ -162,7 +162,20 @@ void VirtualMachineImpl::suspend()
 
 void VirtualMachineImpl::resume()
 {
+  if (getState() != SURF_VM_STATE_SUSPENDED)
+    THROWF(vm_error, 0, "Cannot resume VM %s: it was not suspended", piface_->cname());
+
+  xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
+  XBT_DEBUG("Resume VM %s, containing %d processes.", piface_->cname(), xbt_swag_size(process_list));
+
   action_->resume();
+
+  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);
+  }
+
   vmState_ = SURF_VM_STATE_RUNNING;
 }
 
@@ -171,7 +184,7 @@ void VirtualMachineImpl::resume()
  * 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)
+ * @param issuer the process requesting this operation
  */
 void VirtualMachineImpl::save(smx_actor_t issuer)
 {
index 347fa98..5afac82 100644 (file)
@@ -172,17 +172,6 @@ void simcall_vm_suspend(sg_host_t vm)
   simcall_BODY_vm_suspend(vm);
 }
 
-/**
- * \ingroup simix_vm_management
- * \brief Resume the given VM
- *
- * \param vm VM
- */
-void simcall_vm_resume(sg_host_t vm)
-{
-  simcall_BODY_vm_resume(vm);
-}
-
 /**
  * \ingroup simix_vm_management
  * \brief Shutdown the given VM
index 1c1a353..70ef173 100644 (file)
@@ -21,13 +21,6 @@ static inline void simcall_vm_suspend__set__ind_vm(smx_simcall_t simcall, sg_hos
     simgrid::simix::marshal<sg_host_t>(simcall->args[0], arg);
 }
 
-static inline sg_host_t simcall_vm_resume__get__ind_vm(smx_simcall_t simcall) {
-  return simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]);
-}
-static inline void simcall_vm_resume__set__ind_vm(smx_simcall_t simcall, sg_host_t arg) {
-    simgrid::simix::marshal<sg_host_t>(simcall->args[0], arg);
-}
-
 static inline sg_host_t simcall_vm_shutdown__get__ind_vm(smx_simcall_t simcall) {
   return simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]);
 }
index b2da1e1..78d1a92 100644 (file)
@@ -41,12 +41,6 @@ inline static void simcall_BODY_vm_suspend(sg_host_t ind_vm) {
     return simcall<void, sg_host_t>(SIMCALL_VM_SUSPEND, ind_vm);
   }
   
-inline static void simcall_BODY_vm_resume(sg_host_t ind_vm) {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_vm_resume(ind_vm);
-    return simcall<void, sg_host_t>(SIMCALL_VM_RESUME, ind_vm);
-  }
-  
 inline static void simcall_BODY_vm_shutdown(sg_host_t ind_vm) {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) simcall_HANDLER_vm_shutdown(&SIMIX_process_self()->simcall, ind_vm);
index 50ce031..f7effdb 100644 (file)
@@ -19,7 +19,6 @@
 typedef enum {
   SIMCALL_NONE,
   SIMCALL_VM_SUSPEND,
-  SIMCALL_VM_RESUME,
   SIMCALL_VM_SHUTDOWN,
   SIMCALL_PROCESS_KILL,
   SIMCALL_PROCESS_KILLALL,
index 1e2481f..1608173 100644 (file)
@@ -24,7 +24,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);
 /** @brief Simcalls' names (generated from src/simix/simcalls.in) */
 const char* simcall_names[] = {
    "SIMCALL_NONE",  "SIMCALL_VM_SUSPEND",
-  "SIMCALL_VM_RESUME",
   "SIMCALL_VM_SHUTDOWN",
   "SIMCALL_PROCESS_KILL",
   "SIMCALL_PROCESS_KILLALL",
@@ -105,11 +104,6 @@ case SIMCALL_VM_SUSPEND:
       SIMIX_simcall_answer(simcall);
       break;
 
-case SIMCALL_VM_RESUME:
-      SIMIX_vm_resume(simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]));
-      SIMIX_simcall_answer(simcall);
-      break;
-
 case SIMCALL_VM_SHUTDOWN:
       simcall_HANDLER_vm_shutdown(simcall, simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]));
       SIMIX_simcall_answer(simcall);
index 66aa969..c8de23a 100644 (file)
@@ -37,7 +37,6 @@
 # compilation time)
 
 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 process_kill(smx_actor_t process);
index 2a255b6..cc6e697 100644 (file)
@@ -67,8 +67,6 @@ XBT_PRIVATE void SIMIX_execution_finish(simgrid::kernel::activity::Exec *exec);
 XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, const char *category);
 
 /* vm related stuff */
-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_shutdown(sg_host_t ind_vm, smx_actor_t issuer);
index 49115f1..ffea838 100644 (file)
@@ -47,30 +47,6 @@ void simcall_HANDLER_vm_suspend(smx_simcall_t simcall, sg_host_t vm)
   XBT_DEBUG("simcall_HANDLER_vm_suspend done");
 }
 
-
-/**
- * @brief Function to resume a SIMIX VM host. This function restart the execution of the
- * VM. All the processes on this VM will run again.
- *
- * @param vm the vm host to resume (a sg_host_t)
- */
-void SIMIX_vm_resume(sg_host_t vm)
-{
-  if (static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getState() != SURF_VM_STATE_SUSPENDED)
-    THROWF(vm_error, 0, "VM(%s) was not suspended", vm->cname());
-
-  XBT_DEBUG("resume VM(%s), where %d processes exist", vm->cname(), xbt_swag_size(sg_host_simix(vm)->process_list));
-
-  /* jump to vm_ws_resume() */
-  static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->resume();
-
-  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);
-  }
-}
-
 /**
  * @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