mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
Fix selection of network volumes
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@suse.com> (crobinso: rebase, tweak lookup logic)
This commit is contained in:
parent
c0314cad2e
commit
5a7698c799
@ -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:
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user