From 5a1c4c690d9181a576844f90b6a50c75caf5f3c1 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 29 May 2017 14:59:15 +0200 Subject: [PATCH] allow to destroy VMs that are not started yet (fix #172) --- src/plugins/vm/VirtualMachineImpl.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 6b27d8ce5d..a678568321 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -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()->process_list; XBT_DEBUG("shutdown VM %s, that contains %d processes", piface_->cname(), xbt_swag_size(process_list)); -- 2.20.1