mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +00:00
Currently libvirt can race with udev
creation of /dev/disk/by-{id,path}, so if we fail to open the directory, retry up to 5 seconds. This is only likely to happen on hosts that are: 1) diskless (so /dev/disk/by-{id,path} doesn't exist already), and 2) slow, and/or heavily loaded (meaning that udev can take some time to create the /dev nodes). Signed-off-by: Chris Lalancette <clalance@redhat.com>
This commit is contained in:
parent
431d40fa9c
commit
d20d6b1bb0
@ -1,3 +1,7 @@
|
|||||||
|
Fri Nov 28 08:40:00 CET 2008 Chris Lalancette <clalance@redhat.com>
|
||||||
|
* src/storage_backend.c: Wait up to 5 seconds for
|
||||||
|
/dev/disk/by-{id,path} to exist in virStorageBackendStablePath
|
||||||
|
|
||||||
Thu Nov 27 17:15:10 CET 2008 Daniel Veillard <veillard@redhat.com>
|
Thu Nov 27 17:15:10 CET 2008 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* src/xen_unified.c: use preferably xend method to update
|
* src/xen_unified.c: use preferably xend method to update
|
||||||
|
@ -291,6 +291,7 @@ virStorageBackendStablePath(virConnectPtr conn,
|
|||||||
DIR *dh;
|
DIR *dh;
|
||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
char *stablepath;
|
char *stablepath;
|
||||||
|
int opentries = 0;
|
||||||
|
|
||||||
/* Short circuit if pool has no target, or if its /dev */
|
/* Short circuit if pool has no target, or if its /dev */
|
||||||
if (pool->def->target.path == NULL ||
|
if (pool->def->target.path == NULL ||
|
||||||
@ -304,12 +305,17 @@ virStorageBackendStablePath(virConnectPtr conn,
|
|||||||
if (!STRPREFIX(pool->def->target.path, "/dev"))
|
if (!STRPREFIX(pool->def->target.path, "/dev"))
|
||||||
goto ret_strdup;
|
goto ret_strdup;
|
||||||
|
|
||||||
/* The pool is pointing somewhere like /dev/disk/by-path
|
/* We loop here because /dev/disk/by-{id,path} may not have existed
|
||||||
* or /dev/disk/by-id, so we need to check all symlinks in
|
* before we started this operation, so we have to give it some time to
|
||||||
* the target directory and figure out which one points
|
* get created.
|
||||||
* to this device node
|
|
||||||
*/
|
*/
|
||||||
|
reopen:
|
||||||
if ((dh = opendir(pool->def->target.path)) == NULL) {
|
if ((dh = opendir(pool->def->target.path)) == NULL) {
|
||||||
|
opentries++;
|
||||||
|
if (errno == ENOENT && opentries < 50) {
|
||||||
|
usleep(100 * 1000);
|
||||||
|
goto reopen;
|
||||||
|
}
|
||||||
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot read dir %s: %s"),
|
_("cannot read dir %s: %s"),
|
||||||
pool->def->target.path,
|
pool->def->target.path,
|
||||||
@ -317,6 +323,11 @@ virStorageBackendStablePath(virConnectPtr conn,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
*/
|
||||||
while ((dent = readdir(dh)) != NULL) {
|
while ((dent = readdir(dh)) != NULL) {
|
||||||
if (dent->d_name[0] == '.')
|
if (dent->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user