Re: [PATCH 2/2] vfio: selftests: Automate setting up devices for testing

From: Sean Christopherson

Date: Mon Apr 13 2026 - 11:14:24 EST


On Fri, Apr 10, 2026, David Matlack wrote:
> On 2026-04-09 01:51 AM, Josh Hilke wrote:
> > Update the VFIO selftest setup script to find a device that has a VFIO selftest
> > driver on the system, and set it up (i.e unbind that device from its driver, and
> > then bind that device to VFIO).
>
> I am leaning toward putting this behind an explicit flag (maybe -p for
> pick_device or -a for automatic device setup?) that way we are sure the
> user is ok with letting the script start messing with devices on their
> system.

In the spirit of "do one thing and do it well", I would rather put "discovery" in
a separate script entirely, and then tweak setup.sh as necessary to allow piping
in a BDF from the discovery script.

The mechanics of configuring a device for VFIO (setup.sh) are largely generic,
i.e. not unique to the selftests, whereas print_supported_devices() is very much
tightly coupled to selftests.

And with respect to making sure the user actually wants the script to mess with
their system, the permissions required for each script can and should be different.
`lspci`, and discovery in general, typically doesn't require root, whereas most
systems will be configured to have things like "sriov_numvfs" writable only from
root.