[PATCH v4 11/19] KVM: selftests: Make number of IRQs configurable in IRQ test
From: Josh Hilke
Date: Fri May 29 2026 - 20:29:38 EST
From: David Matlack <dmatlack@xxxxxxxxxx>
Add a '-i' flag to tools/testing/selftests/kvm/irq_test.c to allow users
to specify the number of IRQs generated during a test run.
Co-developed-by: Josh Hilke <jrhilke@xxxxxxxxxx>
Signed-off-by: Josh Hilke <jrhilke@xxxxxxxxxx>
Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
---
tools/testing/selftests/kvm/irq_test.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/irq_test.c b/tools/testing/selftests/kvm/irq_test.c
index 72b9106216ed..e79b66c050ff 100644
--- a/tools/testing/selftests/kvm/irq_test.c
+++ b/tools/testing/selftests/kvm/irq_test.c
@@ -123,13 +123,14 @@ static void kvm_clear_gsi_routes(struct kvm_vm *vm)
static void help(const char *name)
{
- printf("Usage: %s [-a] [-b] [-c] [-d <segment:bus:device.function>] [-h]\n", name);
+ printf("Usage: %s [-a] [-b] [-c] [-d <segment:bus:device.function>] [-h] [-i nr_irqs]\n", name);
printf("\n");
printf("Tests KVM IRQ injection via irqfd using an emulated eventfd.\n");
printf("-a Randomly affinitize the device's host IRQ to different physical CPUs throughout the test\n");
printf("-b Block vCPUs (e.g. HLT) instead of spinning in guest-mode\n");
printf("-c Destroy and recreate KVM's GSI routing table in between some interrupts\n");
printf("-d Use a VFIO device to send MSI-X interrupts instead of using an emulated eventfd\n");
+ printf("-i The number of IRQs to generate during the test\n");
printf("\n");
exit(KSFT_FAIL);
}
@@ -162,7 +163,7 @@ int main(int argc, char **argv)
struct iommu *iommu;
struct kvm_vm *vm;
- while ((c = getopt(argc, argv, "abcd:h")) != -1) {
+ while ((c = getopt(argc, argv, "abcd:hi:")) != -1) {
switch (c) {
case 'a':
irq_affinity = true;
@@ -176,6 +177,9 @@ int main(int argc, char **argv)
case 'c':
clear_routes = true;
break;
+ case 'i':
+ nr_irqs = atoi_positive("Number of IRQs", optarg);
+ break;
case 'h':
default:
help(argv[0]);
--
2.54.0.929.g9b7fa37559-goog