mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Assign node device driver private data earlier
This commit is contained in:
parent
c8afb4e1ec
commit
fa89f6c4a3
@ -1499,14 +1499,16 @@ static int nodeStateCleanup(void)
|
|||||||
|
|
||||||
priv = driver->privateData;
|
priv = driver->privateData;
|
||||||
|
|
||||||
if (priv->watch != -1)
|
if (priv) {
|
||||||
virEventRemoveHandle(priv->watch);
|
if (priv->watch != -1)
|
||||||
|
virEventRemoveHandle(priv->watch);
|
||||||
|
|
||||||
udev_monitor = DRV_STATE_UDEV_MONITOR(driver);
|
udev_monitor = DRV_STATE_UDEV_MONITOR(driver);
|
||||||
|
|
||||||
if (udev_monitor != NULL) {
|
if (udev_monitor != NULL) {
|
||||||
udev = udev_monitor_get_udev(udev_monitor);
|
udev = udev_monitor_get_udev(udev_monitor);
|
||||||
udev_monitor_unref(udev_monitor);
|
udev_monitor_unref(udev_monitor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (udev != NULL)
|
if (udev != NULL)
|
||||||
@ -1726,12 +1728,11 @@ static int nodeStateInitialize(bool privileged,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
driver->privateData = priv;
|
||||||
nodeDeviceLock();
|
nodeDeviceLock();
|
||||||
|
|
||||||
if (udevPCITranslateInit(privileged) < 0) {
|
if (udevPCITranslateInit(privileged) < 0)
|
||||||
VIR_FREE(priv);
|
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev.html#udev-new
|
* http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev.html#udev-new
|
||||||
@ -1747,16 +1748,12 @@ static int nodeStateInitialize(bool privileged,
|
|||||||
|
|
||||||
priv->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
|
priv->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
|
||||||
if (priv->udev_monitor == NULL) {
|
if (priv->udev_monitor == NULL) {
|
||||||
VIR_FREE(priv);
|
|
||||||
VIR_ERROR(_("udev_monitor_new_from_netlink returned NULL"));
|
VIR_ERROR(_("udev_monitor_new_from_netlink returned NULL"));
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
udev_monitor_enable_receiving(priv->udev_monitor);
|
udev_monitor_enable_receiving(priv->udev_monitor);
|
||||||
|
|
||||||
/* udev can be retrieved from udev_monitor */
|
|
||||||
driver->privateData = priv;
|
|
||||||
|
|
||||||
/* We register the monitor with the event callback so we are
|
/* We register the monitor with the event callback so we are
|
||||||
* notified by udev of device changes before we enumerate existing
|
* notified by udev of device changes before we enumerate existing
|
||||||
* devices because libvirt will simply recreate the device if we
|
* devices because libvirt will simply recreate the device if we
|
||||||
|
Loading…
Reference in New Issue
Block a user