提交 7fb3902b 编写于 作者: P Peter Krempa

storage: Avoid mangling paths of non-local filesystems when looking up

When looking up a volume by path on a non-local filesystem don't use the
"cleaned" path that might be mangled in such a way that it will differ
from a path provided by a storage backend.

Skip the cleanup step for gluster, sheepdog and RBD.
上级 429bf253
...@@ -1446,42 +1446,66 @@ storageVolLookupByPath(virConnectPtr conn, ...@@ -1446,42 +1446,66 @@ storageVolLookupByPath(virConnectPtr conn,
storageDriverLock(driver); storageDriverLock(driver);
for (i = 0; i < driver->pools.count && !ret; i++) { for (i = 0; i < driver->pools.count && !ret; i++) {
virStoragePoolObjLock(driver->pools.objs[i]); virStoragePoolObjPtr pool = driver->pools.objs[i];
if (virStoragePoolObjIsActive(driver->pools.objs[i])) { virStorageVolDefPtr vol;
virStorageVolDefPtr vol; char *stable_path = NULL;
char *stable_path;
virStoragePoolObjLock(pool);
stable_path = virStorageBackendStablePath(driver->pools.objs[i],
cleanpath,
false);
if (stable_path == NULL) {
/* Don't break the whole lookup process if it fails on
* getting the stable path for some of the pools.
*/
VIR_WARN("Failed to get stable path for pool '%s'",
driver->pools.objs[i]->def->name);
virStoragePoolObjUnlock(driver->pools.objs[i]);
continue;
}
vol = virStorageVolDefFindByPath(driver->pools.objs[i], if (!virStoragePoolObjIsActive(pool)) {
stable_path); virStoragePoolObjUnlock(pool);
VIR_FREE(stable_path); continue;
}
if (vol) { switch ((enum virStoragePoolType) pool->def->type) {
if (virStorageVolLookupByPathEnsureACL(conn, driver->pools.objs[i]->def, vol) < 0) { case VIR_STORAGE_POOL_DIR:
virStoragePoolObjUnlock(driver->pools.objs[i]); case VIR_STORAGE_POOL_FS:
case VIR_STORAGE_POOL_NETFS:
case VIR_STORAGE_POOL_LOGICAL:
case VIR_STORAGE_POOL_DISK:
case VIR_STORAGE_POOL_ISCSI:
case VIR_STORAGE_POOL_SCSI:
case VIR_STORAGE_POOL_MPATH:
stable_path = virStorageBackendStablePath(pool,
cleanpath,
false);
if (stable_path == NULL) {
/* Don't break the whole lookup process if it fails on
* getting the stable path for some of the pools.
*/
VIR_WARN("Failed to get stable path for pool '%s'",
pool->def->name);
virStoragePoolObjUnlock(pool);
continue;
}
break;
case VIR_STORAGE_POOL_GLUSTER:
case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_SHEEPDOG:
case VIR_STORAGE_POOL_LAST:
if (VIR_STRDUP(stable_path, path) < 0) {
virStoragePoolObjUnlock(pool);
goto cleanup; goto cleanup;
} }
break;
}
ret = virGetStorageVol(conn, vol = virStorageVolDefFindByPath(pool, stable_path);
driver->pools.objs[i]->def->name, VIR_FREE(stable_path);
vol->name,
vol->key, if (vol) {
NULL, NULL); if (virStorageVolLookupByPathEnsureACL(conn, pool->def, vol) < 0) {
virStoragePoolObjUnlock(pool);
goto cleanup;
} }
ret = virGetStorageVol(conn, pool->def->name,
vol->name, vol->key,
NULL, NULL);
} }
virStoragePoolObjUnlock(driver->pools.objs[i]);
virStoragePoolObjUnlock(pool);
} }
if (!ret) if (!ret)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册