[PATCH v2 09/14] KVM: selftests: Make test IRQ count configurable

Josh Hilke
2026-03-31T19:41:43Z

From: David Matlack <dmatlack@google.com>

Add the '-i' flag to vfio_pci_irq_test to allow users to specify the
number of IRQs generated during a test run. This provides flexibility
for quick smoke tests or extended stress testing to uncover rare races
in posted-interrupt logic.

Signed-off-by: David Matlack <dmatlack@google.com>
Signed-off-by: Josh Hilke <jrhilke@google.com>
Co-developed-by: Josh Hilke <jrhilke@google.com>
---
tools/testing/selftests/kvm/vfio_pci_irq_test.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/vfio_pci_irq_test.c b/tools/testing/selftests/kvm/vfio_pci_irq_test.c
index db2dedf4437d..f02d455969bb 100644
--- a/tools/testing/selftests/kvm/vfio_pci_irq_test.c
+++ b/tools/testing/selftests/kvm/vfio_pci_irq_test.c
@@ -125,7 +125,7 @@ static void send_msi(struct vfio_pci_device *device, bool use_device_msi, int ms

static void help(const char *name)
{
- printf("Usage: %s [-a] [-b] [-d] [-e] [-h] segment:bus:device.function\n",
+ printf("Usage: %s [-a] [-b] [-d] [-e] [-h] [-i nr_irqs] segment:bus:device.function\n",
name);
printf("\n");
printf(" -a: Randomly affinitize the device IRQ to different CPUs\n"
@@ -135,6 +135,7 @@ static void help(const char *name)
" it with an eventfd write.\n");
printf(" -e: Destroy and recreate KVM's GSI routing table in between\n"
" some interrupts.\n");
+ printf(" -i: The number of IRQs to generate during the test.\n");
printf("\n");
exit(KSFT_FAIL);
}
@@ -176,7 +177,7 @@ int main(int argc, char **argv)

device_bdf = vfio_selftests_get_bdf(&argc, argv);

- while ((c = getopt(argc, argv, "abdeh")) != -1) {
+ while ((c = getopt(argc, argv, "abdehi:")) != -1) {
switch (c) {
case 'a':
irq_affinity = true;
@@ -190,6 +191,9 @@ int main(int argc, char **argv)
case 'e':
empty = true;
break;
+ case 'i':
+ nr_irqs = atoi_positive("Number of IRQs", optarg);
+ break;
case 'h':
default:
help(argv[0]);
--
2.53.0.1118.gaef5881109-goog