[PATCH v3 11/16] KVM: selftests: Configure number of IRQs
From: Josh Hilke
Date: Tue Apr 21 2026 - 19:24:03 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 3671f5ce4cc8..9efb7e655623 100644
--- a/tools/testing/selftests/kvm/irq_test.c
+++ b/tools/testing/selftests/kvm/irq_test.c
@@ -120,13 +120,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);
}
@@ -159,7 +160,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;
@@ -173,6 +174,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.rc2.533.g4f5dca5207-goog