From df410675e5fad55e056fb505cba3a62cac13c411 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Mon, 25 Jun 2012 09:40:39 -0600 Subject: kvm: Don't abort on kvm_irqchip_add_msi_route() Anyone using these functions has to be prepared that irqchip support may not be present. It shouldn't be up to the core code to determine whether this is a fatal error. Currently code written as: virq = kvm_irqchip_add_msi_route(...) if (virq < 0) { } else { } works on x86 with and without kvm irqchip enabled, works without kvm support compiled in, but aborts() on !x86 with kvm support. Signed-off-by: Alex Williamson Acked-by: Jan Kiszka Signed-off-by: Marcelo Tosatti --- kvm-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kvm-all.c') diff --git a/kvm-all.c b/kvm-all.c index f8e432841f..a0c33b38de 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1142,7 +1142,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg) { - abort(); + return -ENOSYS; } static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign) -- cgit v1.2.1 From 753d5e14c4cd9e545242971c5d149fe5da0a5ba1 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 5 Jul 2012 17:16:27 +0200 Subject: memory: pass EventNotifier, not eventfd Under Win32, EventNotifiers will not have event_notifier_get_fd, so we cannot call it in common code such as hw/virtio-pci.c. Pass a pointer to the notifier, and only retrieve the file descriptor in kvm-specific code. Signed-off-by: Paolo Bonzini Signed-off-by: Avi Kivity --- kvm-all.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'kvm-all.c') diff --git a/kvm-all.c b/kvm-all.c index a0c33b38de..5a386b45f9 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -32,6 +32,7 @@ #include "bswap.h" #include "memory.h" #include "exec-memory.h" +#include "event_notifier.h" /* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD @@ -800,23 +801,29 @@ static void kvm_io_ioeventfd_del(MemoryRegionSection *section, static void kvm_eventfd_add(MemoryListener *listener, MemoryRegionSection *section, - bool match_data, uint64_t data, int fd) + bool match_data, uint64_t data, + EventNotifier *e) { if (section->address_space == get_system_memory()) { - kvm_mem_ioeventfd_add(section, match_data, data, fd); + kvm_mem_ioeventfd_add(section, match_data, data, + event_notifier_get_fd(e)); } else { - kvm_io_ioeventfd_add(section, match_data, data, fd); + kvm_io_ioeventfd_add(section, match_data, data, + event_notifier_get_fd(e)); } } static void kvm_eventfd_del(MemoryListener *listener, MemoryRegionSection *section, - bool match_data, uint64_t data, int fd) + bool match_data, uint64_t data, + EventNotifier *e) { if (section->address_space == get_system_memory()) { - kvm_mem_ioeventfd_del(section, match_data, data, fd); + kvm_mem_ioeventfd_del(section, match_data, data, + event_notifier_get_fd(e)); } else { - kvm_io_ioeventfd_del(section, match_data, data, fd); + kvm_io_ioeventfd_del(section, match_data, data, + event_notifier_get_fd(e)); } } -- cgit v1.2.1 From 15b2bd1847239fe0b4a1041b69a631741d2e273a Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 5 Jul 2012 17:16:30 +0200 Subject: virtio: move common irqfd handling out of virtio-pci All transports can use the same event handler for the irqfd, though the exact mechanics of the assignment will be specific. Note that there are three states: handled by the kernel, handled in userspace, disabled. This also lets virtio use event_notifier_set_handler. Signed-off-by: Paolo Bonzini Signed-off-by: Avi Kivity --- kvm-all.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'kvm-all.c') diff --git a/kvm-all.c b/kvm-all.c index 5a386b45f9..add24a14a9 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1163,11 +1163,21 @@ int kvm_irqchip_add_irqfd(KVMState *s, int fd, int virq) return kvm_irqchip_assign_irqfd(s, fd, virq, true); } +int kvm_irqchip_add_irq_notifier(KVMState *s, EventNotifier *n, int virq) +{ + return kvm_irqchip_add_irqfd(s, event_notifier_get_fd(n), virq); +} + int kvm_irqchip_remove_irqfd(KVMState *s, int fd, int virq) { return kvm_irqchip_assign_irqfd(s, fd, virq, false); } +int kvm_irqchip_remove_irq_notifier(KVMState *s, EventNotifier *n, int virq) +{ + return kvm_irqchip_remove_irqfd(s, event_notifier_get_fd(n), virq); +} + static int kvm_irqchip_create(KVMState *s) { QemuOptsList *list = qemu_find_opts("machine"); -- cgit v1.2.1