Re: [PATCH 3/3] KVM: selftests: Use VFIO selftests library to pick IOMMU mode in IRQ test
From: David Matlack
Date: Mon Nov 02 2026 - 17:05:34 EST
On 2026-11-02 07:35 AM, Sean Christopherson wrote:
> On Mon, Nov 02, 2026, Sean Christopherson wrote:
> > On Thu, Oct 29, 2026, David Matlack wrote:
> > > static void help(const char *name)
> > > {
> > > printf("Usage: %s [-a] [-d <segment:bus:device.function>] [-e] [-h] [-i nr_irqs] [-m] [-n] [-t iommu_type] [-v nr_vcpus] [-x]\n", name);
> > > @@ -266,8 +250,7 @@ int main(int argc, char **argv)
> > > }
> > >
> > > if (device_bdf) {
> > > - if (!iommu_type)
> > > - iommu_type = probe_iommu_type();
> > > + TEST_REQUIRE(iommu_mode_is_available(iommu_type));
> >
> > This is very unhelpful when neither IOMMUFD nor VFIO is available, especially
> > why the user doesn't explicitly provide the desired mode:
> >
> > # ./irq_test -d 0000:6f:01.0 -i 10000
> > Random seed: 0x79d386bd
> > 1..0 # SKIP - Requirement not met: iommu_mode_is_available(iommu_type)
Agreed, that is not very helpful. I've added a
iommu_mode_unavailable_msg() helper to libvfio, which returns the reason
a given mode (or any mode, if NULL) is not available. So irq_test would
have:
__TEST_REQUIRE(iommu_mode_is_available(iommu_type), "%s",
iommu_mode_unavailable_msg(iommu_type));
which gives:
# ./irq_test -d 0000:01:00.0 -t iommufd
1..0 # SKIP - IOMMU mode 'iommufd' is not available
# ./irq_test -d 0000:01:00.0
1..0 # SKIP - No IOMMU mode is available. Is VFIO (or IOMMUFD) loaded and enabled?
> Side topic, it would be nice if iommu_mode_lookup() printed out the known modes
> when this is hit:
>
> VFIO_FAIL("Unrecognized IOMMU mode: %s\n", iommu_mode);
Will do in v2. And I will also use the same helper to print out the list
of known modes in irq_test -h.