hv_xen: Remove config after shutdown was successful
authorMichael Hanselmann <hansmi@google.com>
Thu, 24 Jan 2013 13:29:18 +0000 (14:29 +0100)
committerMichael Hanselmann <hansmi@google.com>
Thu, 24 Jan 2013 13:35:39 +0000 (14:35 +0100)
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 <hansmi@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

lib/hypervisor/hv_xen.py

index 623f1bd..626994f 100644 (file)
@@ -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.