[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 44/48] hyperv: add support for KVM_HYPERV_EVENTFD
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 44/48] hyperv: add support for KVM_HYPERV_EVENTFD |
Date: |
Thu, 18 Oct 2018 22:32:11 +0200 |
From: Roman Kagan <address@hidden>
When setting up a notifier for Hyper-V event connection, try to use the
KVM-assisted one first, and fall back to userspace handling of the
hypercall if the kernel doesn't provide the requested feature.
Signed-off-by: Roman Kagan <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/hyperv/hyperv.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
index d745016..7a1c1bb 100644
--- a/hw/hyperv/hyperv.c
+++ b/hw/hyperv/hyperv.c
@@ -13,6 +13,7 @@
#include "exec/address-spaces.h"
#include "sysemu/kvm.h"
#include "qemu/bitops.h"
+#include "qemu/error-report.h"
#include "qemu/queue.h"
#include "qemu/rcu.h"
#include "qemu/rcu_queue.h"
@@ -470,7 +471,7 @@ static void __attribute__((constructor)) hv_init(void)
qemu_mutex_init(&handlers_mutex);
}
-int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier)
+static int set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier)
{
int ret;
EventFlagHandler *handler;
@@ -503,6 +504,30 @@ unlock:
return ret;
}
+static bool process_event_flags_userspace;
+
+int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier)
+{
+ if (!process_event_flags_userspace &&
+ !kvm_check_extension(kvm_state, KVM_CAP_HYPERV_EVENTFD)) {
+ process_event_flags_userspace = true;
+
+ warn_report("Hyper-V event signaling is not supported by this kernel; "
+ "using slower userspace hypercall processing");
+ }
+
+ if (!process_event_flags_userspace) {
+ struct kvm_hyperv_eventfd hvevfd = {
+ .conn_id = conn_id,
+ .fd = notifier ? event_notifier_get_fd(notifier) : -1,
+ .flags = notifier ? 0 : KVM_HYPERV_EVENTFD_DEASSIGN,
+ };
+
+ return kvm_vm_ioctl(kvm_state, KVM_HYPERV_EVENTFD, &hvevfd);
+ }
+ return set_event_flag_handler(conn_id, notifier);
+}
+
uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast)
{
uint16_t ret;
--
1.8.3.1
- [Qemu-devel] [PULL 37/48] hyperv:synic: split capability testing and setting, (continued)
- [Qemu-devel] [PULL 37/48] hyperv:synic: split capability testing and setting, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 33/48] hyperv: make hyperv_vp_index inline, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 39/48] hyperv: only add SynIC in compatible configurations, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 34/48] hyperv: factor out arch-independent API into hw/hyperv, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 41/48] hyperv: add synic message delivery, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 30/48] hyperv: make HvSintRoute reference-counted, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 42/48] hyperv: add synic event flag signaling, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 28/48] hyperv: allow passing arbitrary data to sint ack callback, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 31/48] hyperv: rename kvm_hv_sint_route_set_sint, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 40/48] hyperv: make overlay pages for SynIC, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 44/48] hyperv: add support for KVM_HYPERV_EVENTFD,
Paolo Bonzini <=
- [Qemu-devel] [PULL 32/48] hyperv: split hyperv-proto.h into x86 and arch-independent parts, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 36/48] i386: add hyperv-stub for CONFIG_HYPERV=n, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 43/48] hyperv: process SIGNAL_EVENT hypercall, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 46/48] hyperv_testdev: add SynIC message and event testmodes, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 45/48] hyperv: process POST_MESSAGE hypercall, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 47/48] target/i386: kvm: just return after migrate_add_blocker failed, Paolo Bonzini, 2018/10/18
- [Qemu-devel] [PULL 48/48] replay: pass raw icount value to replay_save_clock, Paolo Bonzini, 2018/10/18
- Re: [Qemu-devel] [PULL 00/48] Miscellaneous patches for 2018-10-18, Paolo Bonzini, 2018/10/19