[libvirt] [PATCH v2 4/5] virpci: Don't error on not binded devices
Martin Kletzander
mkletzan at redhat.com
Mon Nov 4 14:59:18 UTC 2013
On Thu, Oct 31, 2013 at 11:23:41AM +0000, Michal Privoznik wrote:
s/not binded/unbinded/ in $SUBJ
> 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
>
If you don't use the result of this function, you don't need to call
it at all, because there is no code utilizing those
oldDriver{Path,Name} variables.
ACK if you remove the call to the function completely.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131104/c7c026ae/attachment-0001.sig>
More information about the libvir-list
mailing list