From: Raghavendra Rao Ananta <rananta@google.com>
To: David Matlack <dmatlack@google.com>,
Alex Williamson <alex@shazbot.org>,
Alex Williamson <alex.williamson@redhat.com>
Cc: Josh Hilke <jrhilke@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Raghavendra Rao Ananta <rananta@google.com>
Subject: [PATCH v2 0/6] vfio: selftest: Add SR-IOV UAPI test
Date: Wed, 10 Dec 2025 18:14:11 +0000 [thread overview]
Message-ID: <20251210181417.3677674-1-rananta@google.com> (raw)
Hello,
This series adds a vfio selftest, vfio_pci_sriov_uapi_test.c, to get some
coverage on SR-IOV UAPI handling. Specifically, it includes the
following cases that iterates over all the iommu modes:
- Setting correct/incorrect/NULL tokens during device init.
- Close the PF device immediately after setting the token.
- Change/override the PF's token after device init.
The test takes care of creating/setting up the VF device, and hence, it
can be executed like any other test, simply by passing the PF's BDF to
run.sh. For example,
$ ./scripts/setup.sh 0000:16:00.1
$ ./scripts/run.sh ./vfio_pci_sriov_uapi_test
TAP version 13
1..45
Starting 45 tests from 15 test cases.
RUN vfio_pci_sriov_uapi_test.vfio_type1_iommu_same_uuid.init_token_match
OK vfio_pci_sriov_uapi_test.vfio_type1_iommu_same_uuid.init_token_match
ok 1 vfio_pci_sriov_uapi_test.vfio_type1_iommu_same_uuid.init_token_match
RUN vfio_pci_sriov_uapi_test.vfio_type1_iommu_same_uuid.pf_early_close
OK vfio_pci_sriov_uapi_test.vfio_type1_iommu_same_uuid.pf_early_close
ok 2 vfio_pci_sriov_uapi_test.vfio_type1_iommu_same_uuid.pf_early_close
RUN vfio_pci_sriov_uapi_test.vfio_type1_iommu_same_uuid.override_token
OK vfio_pci_sriov_uapi_test.vfio_type1_iommu_same_uuid.override_token
[...]
RUN vfio_pci_sriov_uapi_test.iommufd_null_uuid.override_token ...
OK vfio_pci_sriov_uapi_test.iommufd_null_uuid.override_token
ok 45 vfio_pci_sriov_uapi_test.iommufd_null_uuid.override_token
PASSED: 45 / 45 tests passed.
Thank you.
Raghavendra
v2: Suggestions by David Matlack (thank you)
- Introduce snprintf_assert() to check against content trucation.
- Introduce a new sysfs library to handle all the common vfio/pci sysfs
operations.
- Rename vfio_pci_container_get_device_fd() to
vfio_pci_group_get_device_fd().
- Use a fixed size 'arg' array instead of dynamic allocation in
__vfio_pci_group_get_device_fd().
- Exclude vfio_pci_device_init() to accept the 'vf_token' arg.
- Move the vfio_pci_sriov_uapi_test.c global variable to the FIXTURE()
struct or as TEST_F() local variables.
- test_vfio_pci_container_setup() returns 'int' to indicate status.
- Skip the test if nr_vfs != 0.
- Explicitly set "sriov_drivers_autoprobe" for the PF.
- Make sure to bind the VF device to the "vfio-pci" driver.
- Cleanup the things done by FIXTURE_SETUP() in FIXTURE_TEARDOWN().
v1: https://lore.kernel.org/all/20251104003536.3601931-1-rananta@google.com/
Raghavendra Rao Ananta (6):
vfio: selftests: Introduce snprintf_assert()
vfio: selftests: Introduce a sysfs lib
vfio: selftests: Extend container/iommufd setup for passing vf_token
vfio: selftests: Export more vfio_pci functions
vfio: selftests: Add helper to set/override a vf_token
vfio: selftests: Add tests to validate SR-IOV UAPI
tools/testing/selftests/vfio/Makefile | 1 +
.../selftests/vfio/lib/include/libvfio.h | 1 +
.../vfio/lib/include/libvfio/assert.h | 5 +
.../vfio/lib/include/libvfio/sysfs.h | 16 ++
.../lib/include/libvfio/vfio_pci_device.h | 9 +
tools/testing/selftests/vfio/lib/libvfio.mk | 5 +-
tools/testing/selftests/vfio/lib/sysfs.c | 151 ++++++++++++
.../selftests/vfio/lib/vfio_pci_device.c | 135 ++++++++---
.../selftests/vfio/vfio_dma_mapping_test.c | 6 +-
.../selftests/vfio/vfio_pci_device_test.c | 21 +-
.../selftests/vfio/vfio_pci_sriov_uapi_test.c | 215 ++++++++++++++++++
11 files changed, 515 insertions(+), 50 deletions(-)
create mode 100644 tools/testing/selftests/vfio/lib/include/libvfio/sysfs.h
create mode 100644 tools/testing/selftests/vfio/lib/sysfs.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_sriov_uapi_test.c
base-commit: d721f52e31553a848e0e9947ca15a49c5674aef3
--
2.52.0.239.gd5f0c6e74e-goog
next reply other threads:[~2025-12-10 18:14 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 18:14 Raghavendra Rao Ananta [this message]
2025-12-10 18:14 ` [PATCH v2 1/6] vfio: selftests: Introduce snprintf_assert() Raghavendra Rao Ananta
2026-01-07 22:21 ` David Matlack
2025-12-10 18:14 ` [PATCH v2 2/6] vfio: selftests: Introduce a sysfs lib Raghavendra Rao Ananta
2025-12-12 18:27 ` Raghavendra Rao Ananta
2025-12-18 21:52 ` David Matlack
2026-01-07 22:41 ` David Matlack
2026-01-08 21:25 ` Raghavendra Rao Ananta
2025-12-10 18:14 ` [PATCH v2 3/6] vfio: selftests: Extend container/iommufd setup for passing vf_token Raghavendra Rao Ananta
2026-01-07 22:49 ` David Matlack
2026-01-08 21:34 ` Raghavendra Rao Ananta
2025-12-10 18:14 ` [PATCH v2 4/6] vfio: selftests: Export more vfio_pci functions Raghavendra Rao Ananta
2026-01-07 22:55 ` David Matlack
2026-01-07 23:05 ` David Matlack
2026-01-08 21:47 ` Raghavendra Rao Ananta
2025-12-10 18:14 ` [PATCH v2 5/6] vfio: selftests: Add helper to set/override a vf_token Raghavendra Rao Ananta
2026-01-07 22:56 ` David Matlack
2026-01-08 21:45 ` Raghavendra Rao Ananta
2026-01-14 17:12 ` David Matlack
2025-12-10 18:14 ` [PATCH v2 6/6] vfio: selftests: Add tests to validate SR-IOV UAPI Raghavendra Rao Ananta
2025-12-12 18:21 ` Raghavendra Rao Ananta
2025-12-18 23:26 ` David Matlack
2026-01-06 19:47 ` Raghavendra Rao Ananta
2026-02-05 21:51 ` David Matlack
2026-02-23 18:57 ` David Matlack
2026-01-07 23:22 ` David Matlack
2026-01-09 19:05 ` Raghavendra Rao Ananta
2026-01-14 17:09 ` David Matlack
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251210181417.3677674-1-rananta@google.com \
--to=rananta@google.com \
--cc=alex.williamson@redhat.com \
--cc=alex@shazbot.org \
--cc=dmatlack@google.com \
--cc=jrhilke@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome