If stopping an instance failed, the configuration would already be gone and other operations depending on it (e.g. migration) would no longer work. With this patch the configuration file is only removed once the instance was succesfully stopped or destroyed.
Signed-off-by: Michael Hanselmann <[email protected]> --- lib/hypervisor/hv_xen.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 623f1bd..626994f 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -272,7 +272,7 @@ class XenHypervisor(hv_base.BaseHypervisor): """ if name is None: name = instance.name - self._RemoveConfigFile(name) + if force: command = [constants.XEN_CMD, "destroy", name] else: @@ -283,6 +283,9 @@ class XenHypervisor(hv_base.BaseHypervisor): raise errors.HypervisorError("Failed to stop instance %s: %s, %s" % (name, result.fail_reason, result.output)) + # Remove configuration file if stopping/starting instance was successful + self._RemoveConfigFile(name) + def RebootInstance(self, instance): """Reboot an instance. -- 1.8.1
