mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
nodedev: Move device enumumeration out of nodeStateInitialize
Let's move the udevEnumerateDevices into a thread to "speed up" the initialization process. If the enumeration fails we can set the Quit flag to ensure that udevEventHandleCallback will not run. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
68cdad8785
commit
9f0ae0b18e
@ -1891,6 +1891,25 @@ udevSetupSystemDev(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nodeStateInitializeEnumerate(void *opaque)
|
||||
{
|
||||
struct udev *udev = opaque;
|
||||
udevEventDataPtr priv = driver->privateData;
|
||||
|
||||
/* Populate with known devices */
|
||||
if (udevEnumerateDevices(udev) != 0)
|
||||
goto error;
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
virObjectLock(priv);
|
||||
priv->threadQuit = true;
|
||||
virObjectUnlock(priv);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
udevPCITranslateInit(bool privileged ATTRIBUTE_UNUSED)
|
||||
{
|
||||
@ -1922,6 +1941,7 @@ nodeStateInitialize(bool privileged,
|
||||
{
|
||||
udevEventDataPtr priv = NULL;
|
||||
struct udev *udev = NULL;
|
||||
virThread enumThread;
|
||||
|
||||
if (VIR_ALLOC(driver) < 0)
|
||||
return -1;
|
||||
@ -2002,9 +2022,12 @@ nodeStateInitialize(bool privileged,
|
||||
if (udevSetupSystemDev() != 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Populate with known devices */
|
||||
if (udevEnumerateDevices(udev) != 0)
|
||||
if (virThreadCreate(&enumThread, false, nodeStateInitializeEnumerate,
|
||||
udev) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("failed to create udev enumerate thread"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user