[virt-tools-list] [virt-manager PATCH] virtManager: clone: check which storage pools supports volume cloning
Pavel Hrdina
phrdina at redhat.com
Fri Mar 1 11:18:18 UTC 2019
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
Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
virtManager/clone.py | 11 ++++++-----
virtManager/storagepool.py | 4 ++--
virtinst/storage.py | 24 ++++++++++++++++++------
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/virtManager/clone.py b/virtManager/clone.py
index 895d258a..cd991f6b 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 {} storage pool.".format(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
--
2.20.1
More information about the virt-tools-list
mailing list