kvm: Introduce kvm_irqchip_add/remove_irqfd
Add services to associate an eventfd file descriptor as input with an IRQ line as output. Such a line can be an input pin of an in-kernel irqchip or a virtual line returned by kvm_irqchip_add_route. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
e7b2030862
commit
39853bbc49
30
kvm-all.c
30
kvm-all.c
@ -1108,6 +1108,21 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
|
|||||||
return virq;
|
return virq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign)
|
||||||
|
{
|
||||||
|
struct kvm_irqfd irqfd = {
|
||||||
|
.fd = fd,
|
||||||
|
.gsi = virq,
|
||||||
|
.flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!kvm_irqchip_in_kernel()) {
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return kvm_vm_ioctl(s, KVM_IRQFD, &irqfd);
|
||||||
|
}
|
||||||
|
|
||||||
#else /* !KVM_CAP_IRQ_ROUTING */
|
#else /* !KVM_CAP_IRQ_ROUTING */
|
||||||
|
|
||||||
static void kvm_init_irq_routing(KVMState *s)
|
static void kvm_init_irq_routing(KVMState *s)
|
||||||
@ -1123,8 +1138,23 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
|
|||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign)
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
#endif /* !KVM_CAP_IRQ_ROUTING */
|
#endif /* !KVM_CAP_IRQ_ROUTING */
|
||||||
|
|
||||||
|
int kvm_irqchip_add_irqfd(KVMState *s, int fd, int virq)
|
||||||
|
{
|
||||||
|
return kvm_irqchip_assign_irqfd(s, fd, virq, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int kvm_irqchip_remove_irqfd(KVMState *s, int fd, int virq)
|
||||||
|
{
|
||||||
|
return kvm_irqchip_assign_irqfd(s, fd, virq, false);
|
||||||
|
}
|
||||||
|
|
||||||
static int kvm_irqchip_create(KVMState *s)
|
static int kvm_irqchip_create(KVMState *s)
|
||||||
{
|
{
|
||||||
QemuOptsList *list = qemu_find_opts("machine");
|
QemuOptsList *list = qemu_find_opts("machine");
|
||||||
|
10
kvm-stub.c
10
kvm-stub.c
@ -140,3 +140,13 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
|
|||||||
void kvm_irqchip_release_virq(KVMState *s, int virq)
|
void kvm_irqchip_release_virq(KVMState *s, int virq)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int kvm_irqchip_add_irqfd(KVMState *s, int fd, int virq)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int kvm_irqchip_remove_irqfd(KVMState *s, int fd, int virq)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
3
kvm.h
3
kvm.h
@ -215,4 +215,7 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign);
|
|||||||
|
|
||||||
int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg);
|
int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg);
|
||||||
void kvm_irqchip_release_virq(KVMState *s, int virq);
|
void kvm_irqchip_release_virq(KVMState *s, int virq);
|
||||||
|
|
||||||
|
int kvm_irqchip_add_irqfd(KVMState *s, int fd, int virq);
|
||||||
|
int kvm_irqchip_remove_irqfd(KVMState *s, int fd, int virq);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user