[virt-tools-list] [virt-manager PATCH] delete: undefine only persistent domain

Pavel Hrdina phrdina at redhat.com
Fri Nov 24 16:41:51 UTC 2017


Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1517119

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---

Pushed under trivial rule.

 virtManager/delete.py | 6 ++++--
 virtManager/domain.py | 3 +++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/virtManager/delete.py b/virtManager/delete.py
index 98df413b..0ebfdeb5 100644
--- a/virtManager/delete.py
+++ b/virtManager/delete.py
@@ -162,6 +162,7 @@ class vmmDeleteDialog(vmmGObjectUI):
     def _async_delete(self, asyncjob, paths):
         storage_errors = []
         details = ""
+        undefine = self.vm.is_persistent()
 
         try:
             if self.vm.is_active():
@@ -181,8 +182,9 @@ class vmmDeleteDialog(vmmGObjectUI):
                                           "".join(traceback.format_exc())))
                 meter.end(0)
 
-            logging.debug("Removing VM '%s'", self.vm.get_name())
-            self.vm.delete()
+            if undefine:
+                logging.debug("Removing VM '%s'", self.vm.get_name())
+                self.vm.delete()
 
         except Exception as e:
             error = (_("Error deleting virtual machine '%s': %s") %
diff --git a/virtManager/domain.py b/virtManager/domain.py
index a1f59e38..183a56c1 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -484,6 +484,9 @@ class vmmDomain(vmmLibvirtObject):
         return bool(self.get_xmlobj().os.loader_ro is True and
                     self.get_xmlobj().os.loader_type == "pflash")
 
+    def is_persistent(self):
+        return bool(self._backend.isPersistent())
+
     ##################
     # Support checks #
     ##################
-- 
2.13.6




More information about the virt-tools-list mailing list