Skip to content

Commit 227895e

Browse files
Ricardo KollerMarc Zyngier
authored andcommitted
KVM: selftests: Add kvm_irq_line library function
Add an architecture independent wrapper function for the KVM_IRQ_LINE ioctl. Signed-off-by: Ricardo Koller <[email protected]> Acked-by: Andrew Jones <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 17ce617 commit 227895e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tools/testing/selftests/kvm/include/kvm_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ int _kvm_device_access(int dev_fd, uint32_t group, uint64_t attr,
240240
void *val, bool write);
241241
int kvm_device_access(int dev_fd, uint32_t group, uint64_t attr,
242242
void *val, bool write);
243+
void kvm_irq_line(struct kvm_vm *vm, uint32_t irq, int level);
244+
int _kvm_irq_line(struct kvm_vm *vm, uint32_t irq, int level);
243245

244246
int _vcpu_has_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group,
245247
uint64_t attr);

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,6 +2086,27 @@ int vcpu_access_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group,
20862086
return ret;
20872087
}
20882088

2089+
/*
2090+
* IRQ related functions.
2091+
*/
2092+
2093+
int _kvm_irq_line(struct kvm_vm *vm, uint32_t irq, int level)
2094+
{
2095+
struct kvm_irq_level irq_level = {
2096+
.irq = irq,
2097+
.level = level,
2098+
};
2099+
2100+
return _vm_ioctl(vm, KVM_IRQ_LINE, &irq_level);
2101+
}
2102+
2103+
void kvm_irq_line(struct kvm_vm *vm, uint32_t irq, int level)
2104+
{
2105+
int ret = _kvm_irq_line(vm, irq, level);
2106+
2107+
TEST_ASSERT(ret >= 0, "KVM_IRQ_LINE failed, rc: %i errno: %i", ret, errno);
2108+
}
2109+
20892110
/*
20902111
* VM Dump
20912112
*

0 commit comments

Comments
 (0)