diff --git a/configure.in b/configure.in index 30929ee618..5359433a1f 100644 --- a/configure.in +++ b/configure.in @@ -115,11 +115,17 @@ AC_PATH_PROG([DNSMASQ], [dnsmasq], [dnsmasq], [/sbin:/usr/sbin:/usr/local/sbin:$PATH]) AC_PATH_PROG([BRCTL], [brctl], [brctl], [/sbin:/usr/sbin:/usr/local/sbin:$PATH]) +AC_PATH_PROG([UDEVADM], [udevadm], [], + [/sbin:/usr/sbin:/usr/local/sbin:$PATH]) AC_DEFINE_UNQUOTED([DNSMASQ],["$DNSMASQ"], [Location or name of the dnsmasq program]) AC_DEFINE_UNQUOTED([BRCTL],["$BRCTL"], [Location or name of the brctl program (see bridge-utils)]) +if test -n "$UDEVADM"; then + AC_DEFINE_UNQUOTED([UDEVADM],["$UDEVADM"], + [Location or name of the udevadm program]) +fi dnl Specific dir for HTML output ? AC_ARG_WITH([html-dir], [AC_HELP_STRING([--with-html-dir=path], diff --git a/src/storage_backend.c b/src/storage_backend.c index 9266e5cdc6..6b4fa818cb 100644 --- a/src/storage_backend.c +++ b/src/storage_backend.c @@ -270,6 +270,27 @@ virStorageBackendUpdateVolInfoFD(virConnectPtr conn, return 0; } +#ifdef UDEVADM +void virStorageBackendWaitForDevices(virConnectPtr conn) +{ + const char *const settleprog[] = { UDEVADM, "settle", NULL }; + int exitstatus; + + if (access(UDEVADM, X_OK) != 0) + return; + + /* + * NOTE: we ignore errors here; this is just to make sure that any device + * nodes that are being created finish before we try to scan them. + * If this fails for any reason, we still have the backup of polling for + * 5 seconds for device nodes. + */ + virRun(conn, settleprog, &exitstatus); +} +#else +void virStorageBackendWaitForDevices(virConnectPtr conn ATTRIBUTE_UNUSED) {} +#endif + /* * Given a volume path directly in /dev/XXX, iterate over the * entries in the directory pool->def->target.path and find the diff --git a/src/storage_backend.h b/src/storage_backend.h index 7904d9d061..06f6979ad9 100644 --- a/src/storage_backend.h +++ b/src/storage_backend.h @@ -69,6 +69,8 @@ int virStorageBackendUpdateVolInfoFD(virConnectPtr conn, int fd, int withCapacity); +void virStorageBackendWaitForDevices(virConnectPtr conn); + char *virStorageBackendStablePath(virConnectPtr conn, virStoragePoolObjPtr pool, const char *devpath); diff --git a/src/storage_backend_disk.c b/src/storage_backend_disk.c index 458e30773c..127e02c4a3 100644 --- a/src/storage_backend_disk.c +++ b/src/storage_backend_disk.c @@ -262,6 +262,8 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn, VIR_FREE(pool->def->source.devices[0].freeExtents); pool->def->source.devices[0].nfreeExtent = 0; + virStorageBackendWaitForDevices(conn); + return virStorageBackendDiskReadPartitions(conn, pool, NULL); } diff --git a/src/storage_backend_iscsi.c b/src/storage_backend_iscsi.c index 54a6409e0a..b347fa9308 100644 --- a/src/storage_backend_iscsi.c +++ b/src/storage_backend_iscsi.c @@ -603,6 +603,8 @@ virStorageBackendISCSIRefreshPool(virConnectPtr conn, pool->def->allocation = pool->def->capacity = pool->def->available = 0; + virStorageBackendWaitForDevices(conn); + if ((session = virStorageBackendISCSISession(conn, pool)) == NULL) goto cleanup; if (virStorageBackendISCSIRescanLUNs(conn, pool, session) < 0) diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c index ee8e8f84d2..a358c43206 100644 --- a/src/storage_backend_logical.c +++ b/src/storage_backend_logical.c @@ -470,6 +470,8 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn, }; int exitstatus; + virStorageBackendWaitForDevices(conn); + /* Get list of all logical volumes */ if (virStorageBackendLogicalFindLVs(conn, pool, NULL) < 0) { virStoragePoolObjClearVols(pool);