]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: automatically bind to a vfio variant driver, if available
authorLaine Stump <laine@redhat.com>
Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)
committerLaine Stump <laine@redhat.com>
Mon, 8 Jan 2024 06:00:11 +0000 (01:00 -0500)
commit82e2fac297105f554f57fb589002933231b4f711
tree3f1870aec9cbf957494cdc02192a1b9d6ed1f912
parent8b93d78c8325f1fba5db98848350f3db43f5e7d5
qemu: automatically bind to a vfio variant driver, if available

Rather than always binding to the vfio-pci driver, use the new
function virPCIDeviceFindBestVFIOVariant() to see if the running
kernel has a VFIO variant driver available that is a better match for
the device, and if one is found, use that instead.

virPCIDeviceFindBestVFIOVariant() function reads the modalias file for
the given device from sysfs, then looks through
/lib/modules/${kernel_release}/modules.alias for the vfio_pci alias
that matches with the least number of wildcard ('*') fields.

The appropriate "VFIO variant" driver for a device will be the PCI
driver implemented by the discovered module - these drivers are
compatible with (and provide the entire API of) the standard vfio-pci
driver, but have additional device-specific APIs that can be useful
for, e.g., saving/restoring state for migration.

If a specific driver is named (using <driver model='blah'/> in the
device XML), that will still be used rather than searching
modules.alias; this makes it possible to force binding of vfio-pci if
there is an issue with the auto-selected variant driver.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/libvirt_private.syms
src/util/virpci.c
src/util/virpci.h
tests/virpcimock.c