Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to destroy VMs that are not started yet (fix #172)
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 29 May 2017 12:59:15 +0000 (14:59 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 29 May 2017 12:59:15 +0000 (14:59 +0200)
src/plugins/vm/VirtualMachineImpl.cpp

index 6b27d8c..a678568 100644 (file)
@@ -207,8 +207,24 @@ void VirtualMachineImpl::resume()
  */
 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());
+  if (getState() != SURF_VM_STATE_RUNNING) {
+    const char* stateName = "(unknown state)";
+    switch (getState()) {
+      case SURF_VM_STATE_CREATED:
+        stateName = "created, but not yet started";
+        break;
+      case SURF_VM_STATE_SUSPENDED:
+        stateName = "suspended";
+        break;
+      case SURF_VM_STATE_DESTROYED:
+        stateName = "destroyed";
+        break;
+      case SURF_VM_STATE_RUNNING:
+        THROW_IMPOSSIBLE;
+        break;
+    }
+    XBT_VERB("Shuting down the VM %s even if it's not running but %s", piface_->cname(), stateName);
+  }
 
   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));