Blame SOURCES/virt-manager-virtManager-clone-build-default-clone-path-if-we-know-how.patch

3d61c0
From 99ec53b6e43323373623d2e93d5ef06436350e5d Mon Sep 17 00:00:00 2001
3d61c0
Message-Id: <99ec53b6e43323373623d2e93d5ef06436350e5d@dist-git>
3d61c0
From: Pavel Hrdina <phrdina@redhat.com>
3d61c0
Date: Tue, 5 Mar 2019 10:16:06 +0100
3d61c0
Subject: [PATCH] virtManager: clone: build default clone path if we know how
3d61c0
3d61c0
Function do_we_default returns only if we want to default to clone disk
3d61c0
even if we know how to create default clone path.  Only in case that the
3d61c0
storage pool is TYPE_DISK we don't know how to create default path and
3d61c0
we cannot default to clone that disk.  In all other cases as ReadOnly
3d61c0
disk or Shareable and so on we can prepare the default path for user if
3d61c0
they decide to clone it.
3d61c0
3d61c0
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1565106
3d61c0
3d61c0
Reviewed-by: Cole Robinson <crobinso@redhat.com>
3d61c0
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3d61c0
(cherry picked from commit a02fc0d02272ade8aea851be4e0f7c7ec38de2fe)
3d61c0
Reviewed-by: Cole Robinson <crobinso@redhat.com>
3d61c0
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3d61c0
---
3d61c0
 virtManager/clone.py | 10 ++++++----
3d61c0
 1 file changed, 6 insertions(+), 4 deletions(-)
3d61c0
3d61c0
diff --git a/virtManager/clone.py b/virtManager/clone.py
3d61c0
index eb74be5b..501683ff 100644
3d61c0
--- a/virtManager/clone.py
3d61c0
+++ b/virtManager/clone.py
3d61c0
@@ -102,6 +102,7 @@ def do_we_default(conn, vol, path, ro, shared, devtype):
3d61c0
     """ Returns (do we clone by default?, info string if not)"""
3d61c0
     ignore = conn
3d61c0
     info = ""
3d61c0
+    can_default = True
3d61c0
 
3d61c0
     def append_str(str1, str2, delim=", "):
3d61c0
         if not str2:
3d61c0
@@ -124,11 +125,12 @@ def do_we_default(conn, vol, path, ro, shared, devtype):
3d61c0
         pool_type = vol.get_parent_pool().get_type()
3d61c0
         if pool_type == virtinst.StoragePool.TYPE_DISK:
3d61c0
             info = append_str(info, _("Disk device"))
3d61c0
+            can_default = False
3d61c0
 
3d61c0
     if shared:
3d61c0
         info = append_str(info, _("Shareable"))
3d61c0
 
3d61c0
-    return (not info, info)
3d61c0
+    return (not info, info, can_default)
3d61c0
 
3d61c0
 
3d61c0
 class vmmCloneVM(vmmGObjectUI):
3d61c0
@@ -383,8 +385,8 @@ class vmmCloneVM(vmmGObjectUI):
3d61c0
             skip_targets.remove(force_target)
3d61c0
 
3d61c0
             vol = self.conn.get_vol_by_path(path)
3d61c0
-            default, definfo = do_we_default(self.conn, vol, path, ro, shared,
3d61c0
-                                             devtype)
3d61c0
+            default, definfo, can_default = do_we_default(self.conn, vol, path,
3d61c0
+                                                          ro, shared, devtype)
3d61c0
 
3d61c0
             def storage_add(failinfo=None):
3d61c0
                 # pylint: disable=cell-var-from-loop
3d61c0
@@ -419,7 +421,7 @@ class vmmCloneVM(vmmGObjectUI):
3d61c0
             storage_row[STORAGE_INFO_CAN_CLONE] = True
3d61c0
 
3d61c0
             # If we cannot create default clone_path don't even try to do that
3d61c0
-            if not default:
3d61c0
+            if not can_default:
3d61c0
                 storage_add()
3d61c0
                 continue
3d61c0
 
3d61c0
-- 
3d61c0
2.20.1
3d61c0