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 <mpriv...@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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list