Re: [PATCH v2 00/14] KVM: selftests: Link with VFIO selftests lib and test device interrupts

David Matlack
2026-04-01T18:52:10Z

On 2026-04-01 11:17 AM, Sean Christopherson wrote:
> On Tue, Mar 31, 2026, Josh Hilke wrote:

> > This test only supports x86. Testing physical device interrupts (-d argument) is
> > only supported for Intel because there are no VFIO selftest drivers for AMD
> > devices.
>
> This needs to be expressed in code and human readable error messages to the user.
> I already knew the basic of what the VFIO selfests are doing, and it still took
> me 5+ minutes to find the DSA driver and probing logic.
>
> Concretely, this code needs to be part of the standard vfio selftests APIs:
>
> device = vfio_pci_device_init(device_bdf, iommu);
>
> has_driver = !!device->driver.ops;
>
> E.g. have vfio_pci_device_init() explicitly return an error (or NULL) if it can't
> init the device driver.

No. Not every VFIO selftest or user of libvfio needs a driver. A driver
is only needed in tests that want to use the driver, i.e. want to call
one of the very obviously named functions:

- vfio_pci_driver_send_msi()
- vfio_pci_driver_memcpy()
- etc.

Requiring a driver for vfio_pci_device_init() to return non-NULL would
significantly reduce our ability to test VFIO on different platforms and
environments.

> The fixtures in vfio_pci_driver_test.c already blindly assume success, so you
> might not need to do much beyond changing main() in that file.

I don't follow. What is the issue with vfio_pci_driver_test.?

> And then, also as a vfio_pci_device_xxx() API, add a helper to print out what
> devices are supported, e.g. so that KVM selftests can do something like:

Agree this would be nice to have. Is this a blocker for this series?

> struct vfio_pci_device *kvm_vfio_device_init(const char *bdf)
> {
> struct vfio_pci_device *device;
> struct iommu *iommu;
>
> iommu = iommu_init(default_iommu_mode);
>
> device = vfio_pci_device_init(bdf, iommu);
> if (!device) {
> vfio_pci_device_print_drivers(stderr);
> TEST_FAIL("No driver found for BDF '%s'", bdf);
> }
> return device;
> }
>
> Because as is, this requires way too much a priori knowledge and magic for
> upstream. The user shouldn't have to dig through code just to understand what
> devices are supported.
>
> Ideally, VFIO selftests would also provide a script, utility, and/or helper to
> identify BDFs for devices it has drivers for. In my experience, binding a device
> to VFIO is trivial. Finding the device in the first place is more annoying.

Agree this would be nice to have. Is this a blocker for this series?