mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00: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;
|
||||
|
||||
if (priv->watch != -1)
|
||||
virEventRemoveHandle(priv->watch);
|
||||
if (priv) {
|
||||
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) {
|
||||
udev = udev_monitor_get_udev(udev_monitor);
|
||||
udev_monitor_unref(udev_monitor);
|
||||
if (udev_monitor != NULL) {
|
||||
udev = udev_monitor_get_udev(udev_monitor);
|
||||
udev_monitor_unref(udev_monitor);
|
||||
}
|
||||
}
|
||||
|
||||
if (udev != NULL)
|
||||
@ -1726,12 +1728,11 @@ static int nodeStateInitialize(bool privileged,
|
||||
return -1;
|
||||
}
|
||||
|
||||
driver->privateData = priv;
|
||||
nodeDeviceLock();
|
||||
|
||||
if (udevPCITranslateInit(privileged) < 0) {
|
||||
VIR_FREE(priv);
|
||||
if (udevPCITranslateInit(privileged) < 0)
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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");
|
||||
if (priv->udev_monitor == NULL) {
|
||||
VIR_FREE(priv);
|
||||
VIR_ERROR(_("udev_monitor_new_from_netlink returned NULL"));
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
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
|
||||
* notified by udev of device changes before we enumerate existing
|
||||
* devices because libvirt will simply recreate the device if we
|
||||
|
Loading…
Reference in New Issue
Block a user