[virt-tools-list] [PATCH] Fix selection of network volumes
Jim Fehlig
jfehlig at suse.com
Tue Oct 9 20:30:09 UTC 2018
When creating a new VM and selecting a volume from a network-based
storage pool such as rbd, the volume is not recognized as network-based
and is treated as a volume from a directory storage pool.
This patch adds a method to check if the volume's path points to a
network-based volume, then uses the method to avoid actions like
setting unix file permissions on the volume, which doesn't make
sense for a network-based volume.
Signed-off-by: Jim Fehlig <jfehlig at suse.com>
---
virtinst/devices/disk.py | 4 ++++
virtinst/diskbackend.py | 18 +++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py
index 75a31f46..35302236 100644
--- a/virtinst/devices/disk.py
+++ b/virtinst/devices/disk.py
@@ -274,6 +274,10 @@ class DeviceDisk(Device):
if conn.is_remote() or not conn.is_qemu_system():
return None, []
+ # No need to check network volumes
+ if diskbackend.path_is_network_vol(conn, path):
+ return None, []
+
user = None
try:
for secmodel in conn.caps.host.secmodels:
diff --git a/virtinst/diskbackend.py b/virtinst/diskbackend.py
index 877eaec6..c54ed921 100644
--- a/virtinst/diskbackend.py
+++ b/virtinst/diskbackend.py
@@ -144,7 +144,7 @@ def manage_path(conn, path):
if not path:
return None, None
- if not path_is_url(path):
+ if not path_is_network_vol(conn, path) and not path_is_url(path):
path = os.path.abspath(path)
vol, pool = check_if_path_managed(conn, path)
if vol or pool or not _can_auto_manage(path):
@@ -176,6 +176,22 @@ def path_is_url(path):
return bool(re.match(r"[a-zA-Z]+(\+[a-zA-Z]+)?://.*", path))
+def path_is_network_vol(conn, path):
+ """
+ Detect if path is a network volume such as rbd, gluster, etc
+ """
+ if not path:
+ return False
+
+ vol, ignore = _lookup_vol_by_path(conn, path)
+ if vol:
+ voltype, ignore, ignore = vol.info()
+ if voltype == libvirt.VIR_STORAGE_VOL_NETWORK:
+ return True
+
+ return False
+
+
def _get_dev_type(path, vol_xml, vol_object, pool_xml, remote):
"""
Try to get device type for volume.
--
2.18.0
More information about the virt-tools-list
mailing list