]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
pci: Give an explicit error if device not found
authorCole Robinson <crobinso@redhat.com>
Fri, 30 Apr 2010 15:44:19 +0000 (11:44 -0400)
committerCole Robinson <crobinso@redhat.com>
Mon, 17 May 2010 19:01:59 +0000 (15:01 -0400)
v2: Use intended F_OK. Drop devdir param, just check dev->path for device
existence.

v3: Use virReportSystemError, include dev->path in error message.

src/util/pci.c

index 81193b7bb11e1995f30fc8e4c2b6359be097f443..a1bd8e30331753cfbd8242cf37890ac453ef08aa 100644 (file)
@@ -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");