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

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