Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert the last vm simcall into s4u code
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 19 Dec 2016 15:42:35 +0000 (16:42 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 19 Dec 2016 23:11:07 +0000 (00:11 +0100)
14 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 [deleted file]
src/xbt/log.c
tools/cmake/DefinePackages.cmake

index 2eb40a7..93176f4 100644 (file)
@@ -257,9 +257,6 @@ XBT_PUBLIC(void) simcall_execution_set_priority(smx_activity_t execution, double
 XBT_PUBLIC(void) simcall_execution_set_bound(smx_activity_t execution, double bound);
 XBT_PUBLIC(e_smx_state_t) simcall_execution_wait(smx_activity_t execution);
 
-/******************************* VM simcalls ********************************/
-XBT_PUBLIC(void) simcall_vm_shutdown(sg_host_t vm);
-
 /**************************** Process simcalls ********************************/
 /* Constructor and Destructor */
 XBT_PUBLIC(smx_actor_t) simcall_process_create(const char *name,
index 6a9bf58..341b4ac 100644 (file)
@@ -237,15 +237,19 @@ void MSG_vm_start(msg_vm_t vm)
   }
 }
 
-/** @brief Immediately kills all processes within the given VM. Any memory that they allocated will be leaked.
+/** @brief Immediately kills all processes within the given VM.
  *  @ingroup msg_VMs
  *
- * FIXME: No extra delay occurs. If you want to simulate this too, you want to use a #MSG_process_sleep() or something.
- *        I'm not quite sure.
+ * Any memory that they allocated will be leaked, unless you used #MSG_process_on_exit().
+ *
+ * No extra delay occurs. If you want to simulate this too, you want to use a #MSG_process_sleep().
  */
 void MSG_vm_shutdown(msg_vm_t vm)
 {
-  simcall_vm_shutdown(vm);
+  smx_actor_t issuer=SIMIX_process_self();
+  simgrid::simix::kernelImmediate([vm,issuer]() {
+    static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->shutdown(issuer);
+  });
 
   // Make sure that the processes in the VM are killed in this scheduling round before processing
   // (eg with the VM destroy)
index 412cbd1..c3f7e05 100644 (file)
@@ -246,6 +246,32 @@ void VirtualMachineImpl::restore()
   }
 }
 
+/** @brief Power off a VM.
+ *
+ * All hosted processes will be killed, but the VM state is preserved on memory.
+ * It can later be restarted.
+ *
+ * @param issuer the actor requesting the shutdown
+ */
+void VirtualMachineImpl::shutdown(smx_actor_t issuer)
+{
+  if (getState() != SURF_VM_STATE_RUNNING)
+    THROWF(vm_error, 0, "Cannot shutdown VM %s: it is not running", piface_->cname());
+
+  xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
+  XBT_DEBUG("shutdown VM %s, that contains %d processes", piface_->cname(), xbt_swag_size(process_list));
+
+  smx_actor_t smx_process, smx_process_safe;
+  xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
+    XBT_DEBUG("kill %s", smx_process->cname());
+    SIMIX_process_kill(smx_process, issuer);
+  }
+
+  setState(SURF_VM_STATE_CREATED);
+
+  /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
+}
+
 /** @brief returns the physical machine on which the VM is running **/
 s4u::Host* VirtualMachineImpl::getPm()
 {
index 8af4347..2c6e95e 100644 (file)
@@ -74,6 +74,9 @@ public:
   /** @brief Restore (read from disk+resume) the VM */
   virtual void restore();
 
+  /** @brief Shutdown the VM */
+  virtual void shutdown(smx_actor_t issuer);
+
   /** @brief Change the physical host on which the given VM is running */
   virtual void setPm(s4u::Host* dest);
 
index dec05d5..c92f4e3 100644 (file)
@@ -161,17 +161,6 @@ e_smx_state_t simcall_execution_wait(smx_activity_t execution)
   return (e_smx_state_t) simcall_BODY_execution_wait(execution);
 }
 
-/**
- * \ingroup simix_vm_management
- * \brief Shutdown the given VM
- *
- * \param vm VM
- */
-void simcall_vm_shutdown(sg_host_t vm)
-{
-  simcall_BODY_vm_shutdown(vm);
-}
-
 /**
  * \ingroup simix_process_management
  * \brief Kills a SIMIX process.
index 8c57448..c4108f4 100644 (file)
  */
 
 #include "src/simix/popping_private.h"
-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]);
-}
-static inline void simcall_vm_shutdown__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]);
 }
@@ -1111,7 +1104,6 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f
 
 /* The prototype of all simcall handlers, automatically generated for you */
 
-XBT_PRIVATE void simcall_HANDLER_vm_shutdown(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);
index f4de963..774b702 100644 (file)
@@ -35,12 +35,6 @@ inline static R simcall(e_smx_simcall_t call, T const&... t)
   return simgrid::simix::unmarshal<R>(self->simcall.result);
 }
   
-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);
-    return simcall<void, sg_host_t>(SIMCALL_VM_SHUTDOWN, 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);
index 168ade7..b10d358 100644 (file)
@@ -18,7 +18,6 @@
  */
 typedef enum {
   SIMCALL_NONE,
-  SIMCALL_VM_SHUTDOWN,
   SIMCALL_PROCESS_KILL,
   SIMCALL_PROCESS_KILLALL,
   SIMCALL_PROCESS_CLEANUP,
index b20e85a..742c404 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_SHUTDOWN",
     "SIMCALL_PROCESS_KILL",
     "SIMCALL_PROCESS_KILLALL",
     "SIMCALL_PROCESS_CLEANUP",
@@ -100,11 +99,6 @@ void SIMIX_simcall_handle(smx_simcall_t simcall, int value) {
   if (simcall->issuer->context->iwannadie && simcall->call != SIMCALL_PROCESS_CLEANUP)
     return;
   switch (simcall->call) {
-case SIMCALL_VM_SHUTDOWN:
-      simcall_HANDLER_vm_shutdown(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);
index 4c86cca..9adf7d2 100644 (file)
@@ -36,8 +36,6 @@
 # ./include/simgrid/simix.h (otherwise you will get a warning at the
 # compilation time)
 
-void vm_shutdown(sg_host_t ind_vm);
-
 void process_kill(smx_actor_t process);
 void process_killall(int reset_pid);
 void process_cleanup(smx_actor_t process) [[nohandler]];
index 8914ea3..0db9188 100644 (file)
@@ -66,10 +66,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_shutdown(sg_host_t ind_vm, smx_actor_t issuer);
-// --
-
 SG_END_DECL()
 
 #endif
diff --git a/src/simix/smx_vm.cpp b/src/simix/smx_vm.cpp
deleted file mode 100644 (file)
index f70e0f7..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (c) 2007-2015. The SimGrid Team. All rights reserved.          */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "mc/mc.h"
-#include "simgrid/s4u/VirtualMachine.hpp"
-#include "smx_private.h"
-#include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include "src/plugins/vm/VmHostExt.hpp"
-#include "src/surf/HostImpl.hpp"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virtual Machines");
-
-/**
- * @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
- * preserved on memory. We can later start it again.
- *
- * @param vm the VM to shutdown (a sg_host_t)
- */
-void SIMIX_vm_shutdown(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("shutdown VM %s, that contains %d processes", vm->cname(), xbt_swag_size(sg_host_simix(vm)->process_list));
-
-  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("kill %s", smx_process->name.c_str());
-    SIMIX_process_kill(smx_process, issuer);
-  }
-
-  /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
-  static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->setState(SURF_VM_STATE_CREATED);
-}
-
-void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t vm)
-{
-  SIMIX_vm_shutdown(vm, simcall->issuer);
-}
index 7b919f0..67c19a8 100644 (file)
@@ -228,7 +228,6 @@ static void xbt_log_connect_categories(void)
   XBT_LOG_CONNECT(simix_process);
   XBT_LOG_CONNECT(simix_popping);
   XBT_LOG_CONNECT(simix_synchro);
-  XBT_LOG_CONNECT(simix_vm);
 
   /* smpi */
   /* SMPI categories are connected in smpi_global.c */
index 8715452..1e3d6be 100644 (file)
@@ -363,7 +363,6 @@ set(SIMIX_SRC
   src/simix/smx_network.cpp
   src/simix/ActorImpl.cpp
   src/simix/smx_synchro.cpp
-  src/simix/smx_vm.cpp
   src/simix/popping.cpp
   src/kernel/activity/ActivityImpl.cpp
   src/kernel/activity/SynchroComm.cpp