v2: Use intended F_OK. Drop devdir param, just check dev->path for device existence. v3: Use virReportSystemError, include dev->path in error message. Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- src/util/pci.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/util/pci.c b/src/util/pci.c index 81193b7..a1bd8e3 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -1046,6 +1046,14 @@ pciGetDevice(unsigned domain, snprintf(dev->path, sizeof(dev->path), PCI_SYSFS "devices/%s/config", dev->name); + if (access(dev->path, F_OK) != 0) { + virReportSystemError(errno, + _("Device %s not found: could not access %s"), + dev->name, dev->path); + pciFreeDevice(dev); + return NULL; + } + vendor = pciReadDeviceID(dev, "vendor"); product = pciReadDeviceID(dev, "device"); -- 1.6.6.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list