[libvirt] [PATCH v2] pci: Give an explicit error if device not found

Cole Robinson crobinso at redhat.com
Mon May 17 17:06:23 UTC 2010


v2: Use intended F_OK. Drop devdir param, just check dev->path for device
existence.

Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
 src/util/pci.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/util/pci.c b/src/util/pci.c
index 81193b7..3fcc658 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -1046,6 +1046,13 @@ pciGetDevice(unsigned domain,
     snprintf(dev->path, sizeof(dev->path),
              PCI_SYSFS "devices/%s/config", dev->name);
 
+    if (access(dev->path, F_OK) != 0) {
+        pciReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Device %s not found"), dev->name);
+        pciFreeDevice(dev);
+        return NULL;
+    }
+
     vendor  = pciReadDeviceID(dev, "vendor");
     product = pciReadDeviceID(dev, "device");
 
-- 
1.6.6.1




More information about the libvir-list mailing list