mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
storage: Split out the stable path check
For virStorageBackendStablePath, in order to make decisions in other code split out the checks regarding whether the pool's target is empty, using /dev, using /dev/, or doesn't start with /dev
This commit is contained in:
parent
093eea9589
commit
9126161d0b
@ -1674,6 +1674,17 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
virStorageBackendPoolPathIsStable(const char *path)
|
||||||
|
{
|
||||||
|
if (path == NULL || STREQ(path, "/dev") || STREQ(path, "/dev/"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!STRPREFIX(path, "/dev"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given a volume path directly in /dev/XXX, iterate over the
|
* Given a volume path directly in /dev/XXX, iterate over the
|
||||||
@ -1703,20 +1714,9 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
|
|||||||
int retry = 0;
|
int retry = 0;
|
||||||
int direrr;
|
int direrr;
|
||||||
|
|
||||||
/* Short circuit if pool has no target, or if its /dev */
|
|
||||||
if (pool->def->target.path == NULL ||
|
|
||||||
STREQ(pool->def->target.path, "/dev") ||
|
|
||||||
STREQ(pool->def->target.path, "/dev/"))
|
|
||||||
goto ret_strdup;
|
|
||||||
|
|
||||||
/* Skip whole thing for a pool which isn't in /dev
|
|
||||||
* so we don't mess filesystem/dir based pools
|
|
||||||
*/
|
|
||||||
if (!STRPREFIX(pool->def->target.path, "/dev"))
|
|
||||||
goto ret_strdup;
|
|
||||||
|
|
||||||
/* Logical pools are under /dev but already have stable paths */
|
/* Logical pools are under /dev but already have stable paths */
|
||||||
if (pool->def->type == VIR_STORAGE_POOL_LOGICAL)
|
if (pool->def->type == VIR_STORAGE_POOL_LOGICAL ||
|
||||||
|
!virStorageBackendPoolPathIsStable(pool->def->target.path))
|
||||||
goto ret_strdup;
|
goto ret_strdup;
|
||||||
|
|
||||||
/* We loop here because /dev/disk/by-{id,path} may not have existed
|
/* We loop here because /dev/disk/by-{id,path} may not have existed
|
||||||
|
@ -187,6 +187,7 @@ int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
|
|||||||
int fd,
|
int fd,
|
||||||
struct stat *sb);
|
struct stat *sb);
|
||||||
|
|
||||||
|
bool virStorageBackendPoolPathIsStable(const char *path);
|
||||||
char *virStorageBackendStablePath(virStoragePoolObjPtr pool,
|
char *virStorageBackendStablePath(virStoragePoolObjPtr pool,
|
||||||
const char *devpath,
|
const char *devpath,
|
||||||
bool loop);
|
bool loop);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user