From: Cole Robinson Date: Fri, 30 Apr 2010 15:44:19 +0000 (-0400) Subject: pci: Give an explicit error if device not found X-Git-Tag: v0.8.2~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5679c844de0a15a38551e2cf46952fc48d62d00f;p=thirdparty%2Flibvirt.git pci: Give an explicit error if device not found v2: Use intended F_OK. Drop devdir param, just check dev->path for device existence. v3: Use virReportSystemError, include dev->path in error message. --- diff --git a/src/util/pci.c b/src/util/pci.c index 81193b7bb1..a1bd8e3033 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");