Blob Blame History Raw
From 99ec53b6e43323373623d2e93d5ef06436350e5d Mon Sep 17 00:00:00 2001
Message-Id: <99ec53b6e43323373623d2e93d5ef06436350e5d@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Tue, 5 Mar 2019 10:16:06 +0100
Subject: [PATCH] virtManager: clone: build default clone path if we know how

Function do_we_default returns only if we want to default to clone disk
even if we know how to create default clone path.  Only in case that the
storage pool is TYPE_DISK we don't know how to create default path and
we cannot default to clone that disk.  In all other cases as ReadOnly
disk or Shareable and so on we can prepare the default path for user if
they decide to clone it.

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

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit a02fc0d02272ade8aea851be4e0f7c7ec38de2fe)
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 virtManager/clone.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/virtManager/clone.py b/virtManager/clone.py
index eb74be5b..501683ff 100644
--- a/virtManager/clone.py
+++ b/virtManager/clone.py
@@ -102,6 +102,7 @@ def do_we_default(conn, vol, path, ro, shared, devtype):
     """ Returns (do we clone by default?, info string if not)"""
     ignore = conn
     info = ""
+    can_default = True
 
     def append_str(str1, str2, delim=", "):
         if not str2:
@@ -124,11 +125,12 @@ def do_we_default(conn, vol, path, ro, shared, devtype):
         pool_type = vol.get_parent_pool().get_type()
         if pool_type == virtinst.StoragePool.TYPE_DISK:
             info = append_str(info, _("Disk device"))
+            can_default = False
 
     if shared:
         info = append_str(info, _("Shareable"))
 
-    return (not info, info)
+    return (not info, info, can_default)
 
 
 class vmmCloneVM(vmmGObjectUI):
@@ -383,8 +385,8 @@ class vmmCloneVM(vmmGObjectUI):
             skip_targets.remove(force_target)
 
             vol = self.conn.get_vol_by_path(path)
-            default, definfo = do_we_default(self.conn, vol, path, ro, shared,
-                                             devtype)
+            default, definfo, can_default = do_we_default(self.conn, vol, path,
+                                                          ro, shared, devtype)
 
             def storage_add(failinfo=None):
                 # pylint: disable=cell-var-from-loop
@@ -419,7 +421,7 @@ class vmmCloneVM(vmmGObjectUI):
             storage_row[STORAGE_INFO_CAN_CLONE] = True
 
             # If we cannot create default clone_path don't even try to do that
-            if not default:
+            if not can_default:
                 storage_add()
                 continue
 
-- 
2.20.1