struct dirent *dent;
char *stablepath;
int opentries = 0;
+ int retry = 0;
/* Short circuit if pool has no target, or if its /dev */
if (pool->def->target.path == NULL ||
goto ret_strdup;
/* Skip whole thing for a pool which isn't in /dev
- * so we don't mess will filesystem/dir based pools
+ * so we don't mess filesystem/dir based pools
*/
if (!STRPREFIX(pool->def->target.path, "/dev"))
goto ret_strdup;
/* The pool is pointing somewhere like /dev/disk/by-path
* or /dev/disk/by-id, so we need to check all symlinks in
* the target directory and figure out which one points
- * to this device node
+ * to this device node.
+ *
+ * And it might need some time till the stabe path shows
+ * up, so add timeout to retry here.
*/
+ retry:
while ((dent = readdir(dh)) != NULL) {
if (dent->d_name[0] == '.')
continue;
VIR_FREE(stablepath);
}
+ if (++retry < 100) {
+ usleep(100 * 1000);
+ goto retry;
+ }
+
closedir(dh);
ret_strdup: