Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow an actor to destroy its own VM.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 7 May 2021 11:39:11 +0000 (13:39 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 7 May 2021 11:49:34 +0000 (13:49 +0200)
Fix https://github.com/simgrid/simgrid/issues/322

ChangeLog
src/plugins/vm/s4u_VirtualMachine.cpp

index 641e419..414e966 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,7 @@ Documentation:
 Fixed bugs (FG#.. -> FramaGit bugs; FG!.. -> FG merge requests)
  (FG: issues on Framagit; GF: issues on GForge; GH: issues on GitHub)
  - FG#47: Complete and fix tests from teshuite/s4u/activity-lifecycle
+ - GH#322: Issue when an actor kills his host vm
 
 ----------------------------------------------------------------------------
 
index 2a7fcd3..ff4b0ad 100644 (file)
@@ -123,16 +123,28 @@ void VirtualMachine::shutdown()
 
 void VirtualMachine::destroy()
 {
-  /* First, terminate all processes on the VM if necessary */
-  shutdown();
-
-  XBT_DEBUG("destroy %s", get_cname());
-
-  /* Then, destroy the VM object */
-  kernel::actor::simcall([this]() {
-    get_impl()->destroy();
-    delete this;
-  });
+  auto destroy_code = [this]() {
+    /* First, terminate all processes on the VM if necessary */
+    shutdown();
+
+    XBT_DEBUG("destroy %s", get_cname());
+
+    /* Then, destroy the VM object */
+    kernel::actor::simcall([this]() {
+      get_impl()->destroy();
+      delete this;
+    });
+  };
+
+  if (this_actor::get_host() == this) {
+    XBT_VERB("Launch another actor on physical host %s to destroy my own VM: %s", get_pm()->get_cname(), get_cname());
+    simgrid::s4u::Actor::create(get_cname() + std::string("-destroy"), get_pm(), destroy_code);
+    simgrid::s4u::this_actor::yield();
+    XBT_CRITICAL("I should be dead now!");
+    DIE_IMPOSSIBLE;
+  }
+
+  destroy_code();
 }
 
 simgrid::s4u::Host* VirtualMachine::get_pm() const