mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Only initialize/cleanup libpciaccess once
libpciaccess has many bugs in its pci_system_init/cleanup functions that makes calling them multiple times unwise. eg it will double close() FDs, and leak other FDs. * src/node_device/node_device_udev.c: Only initialize libpciaccess once
This commit is contained in:
parent
28209ca05e
commit
2215050edd
@ -363,18 +363,10 @@ static int udevTranslatePCIIds(unsigned int vendor,
|
|||||||
char **vendor_string,
|
char **vendor_string,
|
||||||
char **product_string)
|
char **product_string)
|
||||||
{
|
{
|
||||||
int ret = -1, pciret;
|
int ret = -1;
|
||||||
struct pci_id_match m;
|
struct pci_id_match m;
|
||||||
const char *vendor_name = NULL, *device_name = NULL;
|
const char *vendor_name = NULL, *device_name = NULL;
|
||||||
|
|
||||||
if ((pciret = pci_system_init()) != 0) {
|
|
||||||
char ebuf[256];
|
|
||||||
VIR_INFO("Failed to initialize libpciaccess: %s",
|
|
||||||
virStrerror(pciret, ebuf, sizeof ebuf));
|
|
||||||
ret = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
m.vendor_id = vendor;
|
m.vendor_id = vendor;
|
||||||
m.device_id = product;
|
m.device_id = product;
|
||||||
m.subvendor_id = PCI_MATCH_ANY;
|
m.subvendor_id = PCI_MATCH_ANY;
|
||||||
@ -406,9 +398,6 @@ static int udevTranslatePCIIds(unsigned int vendor,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pci_system_cleanup returns void */
|
|
||||||
pci_system_cleanup();
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
@ -1426,6 +1415,9 @@ static int udevDeviceMonitorShutdown(void)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pci_system_cleanup returns void */
|
||||||
|
pci_system_cleanup();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1593,6 +1585,15 @@ static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
|
|||||||
udevPrivate *priv = NULL;
|
udevPrivate *priv = NULL;
|
||||||
struct udev *udev = NULL;
|
struct udev *udev = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int pciret;
|
||||||
|
|
||||||
|
if ((pciret = pci_system_init()) != 0) {
|
||||||
|
char ebuf[256];
|
||||||
|
VIR_INFO("Failed to initialize libpciaccess: %s",
|
||||||
|
virStrerror(pciret, ebuf, sizeof ebuf));
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(priv) < 0) {
|
if (VIR_ALLOC(priv) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
|
Loading…
Reference in New Issue
Block a user