storage: fix search_pool_containing_dir()
Canonicalize both directories, resolving symlink components. Compare with commonpath() instead of startswith(), because /foo doesn't contain /foobar.
This commit is contained in:
parent
f0ee73e63f
commit
d33bd3f2b6
@ -884,17 +884,21 @@ def search_pool_containing_dir(pools, dir_path):
|
||||
This is useful for implementing Pool.included_in method
|
||||
'''
|
||||
|
||||
real_dir_path = os.path.realpath(dir_path)
|
||||
|
||||
# prefer filesystem pools
|
||||
for pool in pools:
|
||||
if hasattr(pool, 'dir_path'):
|
||||
if dir_path.startswith(pool.dir_path):
|
||||
pool_real_dir_path = os.path.realpath(pool.dir_path)
|
||||
if os.path.commonpath([pool_real_dir_path, real_dir_path]) == \
|
||||
pool_real_dir_path:
|
||||
return pool
|
||||
|
||||
# then look for lvm
|
||||
for pool in pools:
|
||||
if hasattr(pool, 'thin_pool') and hasattr(pool, 'volume_group'):
|
||||
if (pool.volume_group, pool.thin_pool) == \
|
||||
DirectoryThinPool.thin_pool(dir_path):
|
||||
DirectoryThinPool.thin_pool(real_dir_path):
|
||||
return pool
|
||||
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user