[libvirt] [PATCH v2 4/5] virpci: Don't error on not binded devices

Michal Privoznik mprivozn at redhat.com
Thu Oct 31 11:23:41 UTC 2013


If a PCI deivce is not binded to any driver (e.g. there's yet no PCI
driver in the linux kernel) but still users want to passthru the device
we fail the whole operation as we fail to resolve the 'driver' link
under the PCI device sysfs tree. Obviously, this is not a fatal error
and it shouldn't be error at all.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/util/virpci.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 65d7168..0727085 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1095,10 +1095,16 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
     const char *newDriverName = NULL;
 
     if (virPCIDriverDir(&stubDriverPath, stubDriverName) < 0 ||
-        virPCIFile(&driverLink, dev->name, "driver") < 0 ||
-        virPCIDeviceGetDriverPathAndName(dev, &oldDriverPath,
-                                         &oldDriverName) < 0) {
+        virPCIFile(&driverLink, dev->name, "driver") < 0)
         goto cleanup;
+
+    if (virPCIDeviceGetDriverPathAndName(dev, &oldDriverPath,
+                                         &oldDriverName) < 0) {
+        /* It's okay if device is not binded to any driver. If that's the case,
+         * there's no /sys/bus/pci/devices/.../driver symlink. */
+        if (errno != ENOENT)
+            goto cleanup;
+        virResetLastError();
     }
 
     if (virFileExists(driverLink)) {
-- 
1.8.1.5




More information about the libvir-list mailing list