Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
inline 2 more VM functions, and kill a simcall
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 20 Nov 2016 16:59:16 +0000 (17:59 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 20 Nov 2016 16:59:16 +0000 (17:59 +0100)
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 13bbba3..95f8dfa 100644 (file)
@@ -295,7 +295,23 @@ void simcall_vm_save(sg_host_t vm)
  */
 void simcall_vm_restore(sg_host_t vm)
 {
  */
 void simcall_vm_restore(sg_host_t vm)
 {
-  simcall_BODY_vm_restore(vm);
+  simgrid::simix::kernelImmediate([vm]() {
+    if (SIMIX_vm_get_state(vm) != SURF_VM_STATE_SAVED)
+      THROWF(vm_error, 0, "VM(%s) was not saved", vm->name().c_str());
+
+    XBT_DEBUG("restore VM(%s), where %d processes exist", vm->name().c_str(),
+              xbt_swag_size(sg_host_simix(vm)->process_list));
+
+    /* jump to vm_ws_restore() */
+    static_cast<simgrid::s4u::VirtualMachine*>(vm)->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);
+    }
+  });
 }
 
 /**
 }
 
 /**
@@ -317,7 +333,24 @@ void simcall_vm_shutdown(sg_host_t vm)
  */
 void simcall_vm_destroy(sg_host_t vm)
 {
  */
 void simcall_vm_destroy(sg_host_t vm)
 {
-  simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_destroy, vm));
+  simgrid::simix::kernelImmediate([vm]() {
+    /* this code basically performs a similar thing like SIMIX_host_destroy() */
+    XBT_DEBUG("destroy %s", vm->name().c_str());
+
+    /* FIXME: this is really strange that everything fails if the next line is removed.
+     * This is as if we shared these data with the PM, which definitely should not be the case...
+     *
+     * We need to test that suspending a VM does not suspends the processes running on its PM, for example.
+     * Or we need to simplify this code enough to make it actually readable (but this sounds harder than testing)
+     */
+    vm->extension_set<simgrid::simix::Host>(nullptr);
+
+    /* Don't free these things twice: they are the ones of my physical host */
+    vm->pimpl_cpu     = nullptr;
+    vm->pimpl_netcard = nullptr;
+
+    vm->destroy();
+  });
 }
 
 /**
 }
 
 /**
index b7d2284..4601e40 100644 (file)
@@ -42,13 +42,6 @@ static inline void simcall_vm_save__set__ind_vm(smx_simcall_t simcall, sg_host_t
     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_restore__get__ind_vm(smx_simcall_t simcall) {
-  return simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]);
-}
-static inline void simcall_vm_restore__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]);
 }
@@ -215,13 +208,11 @@ static inline double simcall_execution_parallel_start__get__rate(smx_simcall_t s
 static inline void simcall_execution_parallel_start__set__rate(smx_simcall_t simcall, double arg) {
     simgrid::simix::marshal<double>(simcall->args[6], arg);
 }
 static inline void simcall_execution_parallel_start__set__rate(smx_simcall_t simcall, double arg) {
     simgrid::simix::marshal<double>(simcall->args[6], arg);
 }
-static inline double simcall_execution_parallel_start__get__timeout(smx_simcall_t simcall)
-{
+static inline double simcall_execution_parallel_start__get__timeout(smx_simcall_t simcall) {
   return simgrid::simix::unmarshal<double>(simcall->args[7]);
 }
   return simgrid::simix::unmarshal<double>(simcall->args[7]);
 }
-static inline void simcall_execution_parallel_start__set__timeout(smx_simcall_t simcall, double arg)
-{
-  simgrid::simix::marshal<double>(simcall->args[7], arg);
+static inline void simcall_execution_parallel_start__set__timeout(smx_simcall_t simcall, double arg) {
+    simgrid::simix::marshal<double>(simcall->args[7], arg);
 }
 static inline smx_activity_t simcall_execution_parallel_start__get__result(smx_simcall_t simcall){
     return simgrid::simix::unmarshal<smx_activity_t>(simcall->result);
 }
 static inline smx_activity_t simcall_execution_parallel_start__get__result(smx_simcall_t simcall){
     return simgrid::simix::unmarshal<smx_activity_t>(simcall->result);
index de6f794..8986295 100644 (file)
@@ -43,8 +43,7 @@ inline static void simcall_BODY_vm_suspend(sg_host_t 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 */
   
 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);
+    if (0) SIMIX_vm_resume(ind_vm);
     return simcall<void, sg_host_t>(SIMCALL_VM_RESUME, ind_vm);
   }
   
     return simcall<void, sg_host_t>(SIMCALL_VM_RESUME, ind_vm);
   }
   
@@ -60,13 +59,6 @@ inline static void simcall_BODY_vm_save(sg_host_t ind_vm) {
     return simcall<void, sg_host_t>(SIMCALL_VM_SAVE, ind_vm);
   }
   
     return simcall<void, sg_host_t>(SIMCALL_VM_SAVE, ind_vm);
   }
   
-inline static void simcall_BODY_vm_restore(sg_host_t ind_vm) {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0)
-      SIMIX_vm_restore(ind_vm);
-    return simcall<void, sg_host_t>(SIMCALL_VM_RESTORE, 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);
@@ -93,8 +85,7 @@ inline static void simcall_BODY_process_suspend(smx_actor_t process) {
   
 inline static void simcall_BODY_process_resume(smx_actor_t process) {
     /* Go to that function to follow the code flow through the simcall barrier */
   
 inline static void simcall_BODY_process_resume(smx_actor_t process) {
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0)
-      SIMIX_process_resume(process);
+    if (0) SIMIX_process_resume(process);
     return simcall<void, smx_actor_t>(SIMCALL_PROCESS_RESUME, process);
   }
   
     return simcall<void, smx_actor_t>(SIMCALL_PROCESS_RESUME, process);
   }
   
@@ -127,17 +118,11 @@ inline static smx_activity_t simcall_BODY_execution_start(const char* name, doub
     if (0) simcall_HANDLER_execution_start(&SIMIX_process_self()->simcall, name, flops_amount, priority, bound);
     return simcall<smx_activity_t, const char*, double, double, double>(SIMCALL_EXECUTION_START, name, flops_amount, priority, bound);
   }
     if (0) simcall_HANDLER_execution_start(&SIMIX_process_self()->simcall, name, flops_amount, priority, bound);
     return simcall<smx_activity_t, const char*, double, double, double>(SIMCALL_EXECUTION_START, name, flops_amount, priority, bound);
   }
-
-  inline static smx_activity_t simcall_BODY_execution_parallel_start(const char* name, int host_nb,
-                                                                     sg_host_t* host_list, double* flops_amount,
-                                                                     double* bytes_amount, double amount, double rate,
-                                                                     double timeout)
-  {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0)
-      SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, timeout);
-    return simcall<smx_activity_t, const char*, int, sg_host_t*, double*, double*, double, double, double>(
-        SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, timeout);
+  
+inline static smx_activity_t simcall_BODY_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double amount, double rate, double timeout) {
+    /* Go to that function to follow the code flow through the simcall barrier */
+    if (0) SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, timeout);
+    return simcall<smx_activity_t, const char*, int, sg_host_t*, double*, double*, double, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, timeout);
   }
   
 inline static void simcall_BODY_execution_cancel(smx_activity_t execution) {
   }
   
 inline static void simcall_BODY_execution_cancel(smx_activity_t execution) {
index ffd838e..cd8d89d 100644 (file)
@@ -22,7 +22,6 @@ typedef enum {
   SIMCALL_VM_RESUME,
   SIMCALL_VM_SHUTDOWN,
   SIMCALL_VM_SAVE,
   SIMCALL_VM_RESUME,
   SIMCALL_VM_SHUTDOWN,
   SIMCALL_VM_SAVE,
-  SIMCALL_VM_RESTORE,
   SIMCALL_PROCESS_KILL,
   SIMCALL_PROCESS_KILLALL,
   SIMCALL_PROCESS_CLEANUP,
   SIMCALL_PROCESS_KILL,
   SIMCALL_PROCESS_KILLALL,
   SIMCALL_PROCESS_CLEANUP,
index 872041e..43c6d26 100644 (file)
@@ -27,7 +27,6 @@ const char* simcall_names[] = {
   "SIMCALL_VM_RESUME",
   "SIMCALL_VM_SHUTDOWN",
   "SIMCALL_VM_SAVE",
   "SIMCALL_VM_RESUME",
   "SIMCALL_VM_SHUTDOWN",
   "SIMCALL_VM_SAVE",
-  "SIMCALL_VM_RESTORE",
   "SIMCALL_PROCESS_KILL",
   "SIMCALL_PROCESS_KILLALL",
   "SIMCALL_PROCESS_CLEANUP",
   "SIMCALL_PROCESS_KILL",
   "SIMCALL_PROCESS_KILLALL",
   "SIMCALL_PROCESS_CLEANUP",
@@ -109,9 +108,9 @@ case SIMCALL_VM_SUSPEND:
       break;
 
 case SIMCALL_VM_RESUME:
       break;
 
 case SIMCALL_VM_RESUME:
-  SIMIX_vm_resume(simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]));
-  SIMIX_simcall_answer(simcall);
-  break;
+      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]));
 
 case SIMCALL_VM_SHUTDOWN:
       simcall_HANDLER_vm_shutdown(simcall, simgrid::simix::unmarshal<sg_host_t>(simcall->args[0]));
@@ -123,11 +122,6 @@ case SIMCALL_VM_SAVE:
       SIMIX_simcall_answer(simcall);
       break;
 
       SIMIX_simcall_answer(simcall);
       break;
 
-case SIMCALL_VM_RESTORE:
-  SIMIX_vm_restore(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);
@@ -148,9 +142,9 @@ case SIMCALL_PROCESS_SUSPEND:
       break;
 
 case SIMCALL_PROCESS_RESUME:
       break;
 
 case SIMCALL_PROCESS_RESUME:
-  SIMIX_process_resume(simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]));
-  SIMIX_simcall_answer(simcall);
-  break;
+      SIMIX_process_resume(simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]));
+      SIMIX_simcall_answer(simcall);
+      break;
 
 case SIMCALL_PROCESS_SET_HOST:
       simcall_HANDLER_process_set_host(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]));
 
 case SIMCALL_PROCESS_SET_HOST:
       simcall_HANDLER_process_set_host(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]));
@@ -176,15 +170,9 @@ case SIMCALL_EXECUTION_START:
       break;
 
 case SIMCALL_EXECUTION_PARALLEL_START:
       break;
 
 case SIMCALL_EXECUTION_PARALLEL_START:
-  simgrid::simix::marshal<smx_activity_t>(
-      simcall->result,
-      SIMIX_execution_parallel_start(
-          simgrid::simix::unmarshal<const char*>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1]),
-          simgrid::simix::unmarshal<sg_host_t*>(simcall->args[2]), simgrid::simix::unmarshal<double*>(simcall->args[3]),
-          simgrid::simix::unmarshal<double*>(simcall->args[4]), simgrid::simix::unmarshal<double>(simcall->args[5]),
-          simgrid::simix::unmarshal<double>(simcall->args[6]), simgrid::simix::unmarshal<double>(simcall->args[7])));
-  SIMIX_simcall_answer(simcall);
-  break;
+      simgrid::simix::marshal<smx_activity_t>(simcall->result, SIMIX_execution_parallel_start(simgrid::simix::unmarshal<const char*>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1]), simgrid::simix::unmarshal<sg_host_t*>(simcall->args[2]), simgrid::simix::unmarshal<double*>(simcall->args[3]), simgrid::simix::unmarshal<double*>(simcall->args[4]), simgrid::simix::unmarshal<double>(simcall->args[5]), simgrid::simix::unmarshal<double>(simcall->args[6]), simgrid::simix::unmarshal<double>(simcall->args[7])));
+      SIMIX_simcall_answer(simcall);
+      break;
 
 case SIMCALL_EXECUTION_CANCEL:
       SIMIX_execution_cancel(simgrid::simix::unmarshal<smx_activity_t>(simcall->args[0]));
 
 case SIMCALL_EXECUTION_CANCEL:
       SIMIX_execution_cancel(simgrid::simix::unmarshal<smx_activity_t>(simcall->args[0]));
index 887b1b6..1aa78dd 100644 (file)
@@ -40,7 +40,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 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 vm_restore(sg_host_t ind_vm) [[nohandler]];
 
 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 16a099a..0e0d387 100644 (file)
@@ -67,16 +67,12 @@ 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_set_category(smx_activity_t synchro, const char *category);
 
 /* vm related stuff */
-XBT_PRIVATE void SIMIX_vm_destroy(sg_host_t ind_vm);
-// --
 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_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_restore(sg_host_t ind_vm);
-// --
 XBT_PRIVATE void SIMIX_vm_start(sg_host_t ind_vm);
 
 XBT_PRIVATE void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_actor_t issuer);
 XBT_PRIVATE void SIMIX_vm_start(sg_host_t ind_vm);
 
 XBT_PRIVATE void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_actor_t issuer);
index f6d3396..cd04a97 100644 (file)
@@ -183,30 +183,6 @@ void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t vm)
   SIMIX_vm_save(vm, simcall->issuer);
 }
 
   SIMIX_vm_save(vm, simcall->issuer);
 }
 
-/**
- * @brief Function to restore 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 restore (a sg_host_t)
- */
-void SIMIX_vm_restore(sg_host_t vm)
-{
-  if (SIMIX_vm_get_state(vm) != SURF_VM_STATE_SAVED)
-    THROWF(vm_error, 0, "VM(%s) was not saved", vm->name().c_str());
-
-  XBT_DEBUG("restore VM(%s), where %d processes exist",
-      vm->name().c_str(), xbt_swag_size(sg_host_simix(vm)->process_list));
-
-  /* jump to vm_ws_restore() */
-  static_cast<simgrid::s4u::VirtualMachine*>(vm)->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);
-  }
-}
-
 /**
  * @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
@@ -236,28 +212,3 @@ void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t vm)
 {
   SIMIX_vm_shutdown(vm, simcall->issuer);
 }
 {
   SIMIX_vm_shutdown(vm, simcall->issuer);
 }
-
-/**
- * @brief Function to destroy a SIMIX VM host.
- *
- * @param vm the vm host to destroy (a sg_host_t)
- */
-void SIMIX_vm_destroy(sg_host_t vm)
-{
-  /* this code basically performs a similar thing like SIMIX_host_destroy() */
-  XBT_DEBUG("destroy %s", vm->name().c_str());
-
-  /* FIXME: this is really strange that everything fails if the next line is removed.
-   * This is as if we shared these data with the PM, which definitely should not be the case...
-   *
-   * We need to test that suspending a VM does not suspends the processes running on its PM, for example.
-   * Or we need to simplify this code enough to make it actually readable (but this sounds harder than testing)
-   */
-  vm->extension_set<simgrid::simix::Host>(nullptr);
-
-  /* Don't free these things twice: they are the ones of my physical host */
-  vm->pimpl_cpu = nullptr;
-  vm->pimpl_netcard = nullptr;
-
-  vm->destroy();
-}