提交 2215050e 编写于 作者: D Daniel P. Berrange

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
上级 28209ca0
......@@ -363,18 +363,10 @@ static int udevTranslatePCIIds(unsigned int vendor,
char **vendor_string,
char **product_string)
{
int ret = -1, pciret;
int ret = -1;
struct pci_id_match m;
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.device_id = product;
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;
out:
......@@ -1426,6 +1415,9 @@ static int udevDeviceMonitorShutdown(void)
ret = -1;
}
/* pci_system_cleanup returns void */
pci_system_cleanup();
return ret;
}
......@@ -1593,6 +1585,15 @@ static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
udevPrivate *priv = NULL;
struct udev *udev = NULL;
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) {
virReportOOMError();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册