mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-02 09:47:16 +03:00
diskbackend: Drop all pool source matching
It's only used to try and determine if a path actually exists, however in the pool source case there isn't much we can actually do with that info.
This commit is contained in:
parent
0389ab23a7
commit
ba05e1cd43
@ -220,11 +220,10 @@ class VirtualDisk(VirtualDevice):
|
||||
return False
|
||||
|
||||
try:
|
||||
(vol, pool, path_is_pool) = diskbackend.check_if_path_managed(
|
||||
conn, path)
|
||||
(vol, pool) = diskbackend.check_if_path_managed(conn, path)
|
||||
ignore = pool
|
||||
|
||||
if vol or path_is_pool:
|
||||
if vol:
|
||||
return True
|
||||
|
||||
if not conn.is_remote():
|
||||
|
@ -36,7 +36,6 @@ def check_if_path_managed(conn, path):
|
||||
vol = None
|
||||
pool = None
|
||||
verr = None
|
||||
path_is_pool = False
|
||||
|
||||
def lookup_vol_by_path():
|
||||
try:
|
||||
@ -84,15 +83,7 @@ def check_if_path_managed(conn, path):
|
||||
raise ValueError(_("Cannot use storage %(path)s: %(err)s") %
|
||||
{'path' : path, 'err' : verr})
|
||||
|
||||
if not vol:
|
||||
# See if path is a pool source, and allow it through
|
||||
trypool = StoragePool.lookup_pool_by_path(
|
||||
conn, path, use_source=True)
|
||||
if trypool:
|
||||
path_is_pool = True
|
||||
pool = trypool
|
||||
|
||||
return vol, pool, path_is_pool
|
||||
return vol, pool
|
||||
|
||||
|
||||
def _can_auto_manage(path):
|
||||
@ -109,8 +100,7 @@ def manage_path(conn, path):
|
||||
"""
|
||||
If path is not managed, try to create a storage pool to probe the path
|
||||
"""
|
||||
vol, pool, path_is_pool = check_if_path_managed(conn, path)
|
||||
ignore = path_is_pool
|
||||
vol, pool = check_if_path_managed(conn, path)
|
||||
if vol or pool or not _can_auto_manage(path):
|
||||
return vol, pool
|
||||
|
||||
|
@ -236,30 +236,20 @@ class StoragePool(_StorageObject):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def lookup_pool_by_path(conn, path, use_source=False):
|
||||
def lookup_pool_by_path(conn, path):
|
||||
"""
|
||||
Return the first pool with matching matching target path.
|
||||
return the first we find, active or inactive. This iterates over
|
||||
all pools and dumps their xml, so it is NOT quick.
|
||||
|
||||
@use_source: If true, compare against pool source path, not
|
||||
target path.
|
||||
|
||||
@returns: virStoragePool object if found, None otherwise
|
||||
"""
|
||||
if not conn.check_support(conn.SUPPORT_CONN_STORAGE):
|
||||
return None
|
||||
|
||||
def check_pool(pool, path):
|
||||
if use_source:
|
||||
xml_path = pool.source_path
|
||||
else:
|
||||
xml_path = pool.target_path
|
||||
if xml_path is not None and os.path.abspath(xml_path) == path:
|
||||
return True
|
||||
|
||||
for pool in conn.fetch_all_pools():
|
||||
if check_pool(pool, path):
|
||||
xml_path = pool.target_path
|
||||
if xml_path is not None and os.path.abspath(xml_path) == path:
|
||||
return conn.storagePoolLookupByName(pool.name)
|
||||
return None
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user