virt-manager/26a433fc-virtManager-clone-check-which-storage-pools-supports-volume-cloning.patch

97 lines
3.6 KiB
Diff
Raw Normal View History

Subject: virtManager: clone: check which storage pools supports volume cloning
From: Pavel Hrdina phrdina@redhat.com Thu Feb 28 11:47:40 2019 +0100
Date: Mon Mar 4 13:23:45 2019 +0100:
Git: 26a433fc421b7c23e02deb8fe84cdedc21fd8f95
When cloning a guest in virt-manager the GUI shows a list of disks and
select default cloning policy for every disk. For storage pools where
we know that cloning is not possible we should not select that option
as default one.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1463066
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
diff --git a/virtManager/clone.py b/virtManager/clone.py
index 895d258a..4148fca0 100644
--- a/virtManager/clone.py
+++ b/virtManager/clone.py
@@ -64,6 +64,11 @@ def can_we_clone(conn, vol, path):
elif not os.path.exists(path):
msg = _("Path does not exist.")
+ else:
+ pool = vol.get_parent_pool()
+ if not pool.supports_volume_creation(clone=True):
+ msg = _("Cannot clone %s storage pool.") % pool.get_type()
+
if msg:
ret = False
@@ -94,12 +99,8 @@ def do_we_default(conn, vol, path, ro, shared, devtype):
if vol:
pool_type = vol.get_parent_pool().get_type()
- if pool_type == virtinst.StoragePool.TYPE_SCSI:
- info = append_str(info, _("SCSI device"))
- elif pool_type == virtinst.StoragePool.TYPE_DISK:
+ if pool_type == virtinst.StoragePool.TYPE_DISK:
info = append_str(info, _("Disk device"))
- elif pool_type == virtinst.StoragePool.TYPE_ISCSI:
- info = append_str(info, _("iSCSI share"))
if shared:
info = append_str(info, _("Shareable"))
diff --git a/virtManager/storagepool.py b/virtManager/storagepool.py
index bf79b161..d0d26cc2 100644
--- a/virtManager/storagepool.py
+++ b/virtManager/storagepool.py
@@ -238,8 +238,8 @@ class vmmStoragePool(vmmLibvirtObject):
def can_change_alloc(self):
typ = self.get_type()
return (typ in [StoragePool.TYPE_LOGICAL, StoragePool.TYPE_ZFS])
- def supports_volume_creation(self):
- return self.get_xmlobj().supports_volume_creation()
+ def supports_volume_creation(self, clone=False):
+ return self.get_xmlobj().supports_volume_creation(clone=clone)
def get_type(self):
return self.get_xmlobj().type
diff --git a/virtinst/storage.py b/virtinst/storage.py
index 5781e4a7..3249c454 100644
--- a/virtinst/storage.py
+++ b/virtinst/storage.py
@@ -395,13 +395,25 @@ class StoragePool(_StorageObject):
return self.type in users[propname]
return hasattr(self, propname)
- def supports_volume_creation(self):
- return self.type in [
- StoragePool.TYPE_DIR, StoragePool.TYPE_FS,
- StoragePool.TYPE_NETFS, StoragePool.TYPE_LOGICAL,
+ def supports_volume_creation(self, clone=False):
+ """
+ Returns if pool supports volume creation. If @clone is set to True
+ returns if pool supports volume cloning (virVolCreateXMLFrom).
+ """
+ supported = [
+ StoragePool.TYPE_DIR,
+ StoragePool.TYPE_FS,
+ StoragePool.TYPE_NETFS,
StoragePool.TYPE_DISK,
- StoragePool.TYPE_RBD, StoragePool.TYPE_SHEEPDOG,
- StoragePool.TYPE_ZFS]
+ StoragePool.TYPE_LOGICAL,
+ StoragePool.TYPE_RBD,
+ ]
+ if not clone:
+ supported.extend([
+ StoragePool.TYPE_SHEEPDOG,
+ StoragePool.TYPE_ZFS,
+ ])
+ return self.type in supported
def get_disk_type(self):
if (self.type == StoragePool.TYPE_DISK or