Re: [PATCH] Fix selection of network volumes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/09/2018 04:30 PM, Jim Fehlig wrote:
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@xxxxxxxx>
---
  virtinst/devices/disk.py |  4 ++++
  virtinst/diskbackend.py  | 18 +++++++++++++++++-
  2 files changed, 21 insertions(+), 1 deletion(-)


In the process of testing this I moved some code around so I needed to rebase. I also changed the is_network_vol check to use the volume XML cache for fetch_all_vols rather than do a libvirt API lookup+vol.info() check... the libvirt test driver doesn't fill in accurate voltype data in vol.info so I couldn't test that method, plus the cache should be faster in general

Updated patch is attached but not pushed, can you verify it still works for you?

Thanks,
Cole
diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py
index 38f3f3a8..9f471f2a 100644
--- a/virtinst/devices/disk.py
+++ b/virtinst/devices/disk.py
@@ -176,6 +176,8 @@ class DeviceDisk(Device):
             return searchdata
         if diskbackend.path_is_url(path):
             return searchdata
+        if diskbackend.path_is_network_vol(conn, path):
+            return searchdata
 
         user, uid = conn.caps.host.get_qemu_baselabel()
         if not user:
diff --git a/virtinst/diskbackend.py b/virtinst/diskbackend.py
index f1ea0c0b..b9340585 100644
--- a/virtinst/diskbackend.py
+++ b/virtinst/diskbackend.py
@@ -145,7 +145,7 @@ def manage_path(conn, path):
     if not path:
         return None, None
 
-    if not path_is_url(path):
+    if not path_is_url(path) and not path_is_network_vol(conn, path):
         path = os.path.abspath(path)
     vol, pool = _check_if_path_managed(conn, path)
     if vol or pool or not _can_auto_manage(path):
@@ -177,6 +177,19 @@ 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
+
+    for volxml in conn.fetch_all_vols():
+        if volxml.target_path == path:
+            return volxml.type == "network"
+    return False
+
+
 def _get_dev_type(path, vol_xml, vol_object, pool_xml, remote):
     """
     Try to get device type for volume.
_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list

[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux