*
* Typically target.path is one of the /dev/disk/by-XXX dirs
* with stable paths.
+ *
+ * If 'wait' is true, we use a timeout loop to give dynamic paths
+ * a change to appear.
*/
char *
virStorageBackendStablePath(virStoragePoolObjPtr pool,
- const char *devpath)
+ const char *devpath,
+ bool wait)
{
DIR *dh;
struct dirent *dent;
reopen:
if ((dh = opendir(pool->def->target.path)) == NULL) {
opentries++;
- if (errno == ENOENT && opentries < 50) {
+ if (wait && errno == ENOENT && opentries < 50) {
usleep(100 * 1000);
goto reopen;
}
* the target directory and figure out which one points
* to this device node.
*
- * And it might need some time till the stabe path shows
+ * And it might need some time till the stable path shows
* up, so add timeout to retry here.
*/
retry:
VIR_FREE(stablepath);
}
- if (++retry < 100) {
+ if (wait && ++retry < 100) {
usleep(100 * 1000);
goto retry;
}
* dir every time its run. Should figure out a more efficient
* way of doing this...
*/
- vol->target.path = virStorageBackendStablePath(pool, devpath);
+ vol->target.path = virStorageBackendStablePath(pool, devpath, true);
VIR_FREE(devpath);
if (vol->target.path == NULL)
return -1;
const char *stable_path;
stable_path = virStorageBackendStablePath(driver->pools.objs[i],
- cleanpath);
+ 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.