From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nd17d-0003c9-OG for qemu-devel@nongnu.org; Thu, 04 Feb 2010 07:47:49 -0500 Received: from [199.232.76.173] (port=55428 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nd17d-0003bm-8h for qemu-devel@nongnu.org; Thu, 04 Feb 2010 07:47:49 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nd17b-0007lF-LV for qemu-devel@nongnu.org; Thu, 04 Feb 2010 07:47:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54255) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nd17b-0007l5-6V for qemu-devel@nongnu.org; Thu, 04 Feb 2010 07:47:47 -0500 Date: Thu, 4 Feb 2010 14:44:34 +0200 From: "Michael S. Tsirkin" Message-ID: <20100204124434.GE22559@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH 04/15] kvm: add API to set ioeventfd List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori , qemu-devel@nongnu.org This adds API to set ioeventfd to kvm, as well as stubs for non-eventfd case, making it possible for users to use this API without ifdefs. Signed-off-by: Michael S. Tsirkin --- kvm-all.c | 20 ++++++++++++++++++++ kvm.h | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index a312654..beaba6d 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1113,3 +1113,23 @@ void kvm_remove_all_breakpoints(CPUState *current_env) { } #endif /* !KVM_CAP_SET_GUEST_DEBUG */ + +#ifdef KVM_IOEVENTFD +int kvm_set_ioeventfd(uint16_t addr, uint16_t data, int fd, bool assigned) +{ + struct kvm_ioeventfd kick = { + .datamatch = data, + .addr = addr, + .len = 2, + .flags = KVM_IOEVENTFD_FLAG_DATAMATCH | KVM_IOEVENTFD_FLAG_PIO, + .fd = fd, + }; + int r; + if (!assigned) + kick.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN; + r = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &kick); + if (r < 0) + return r; + return 0; +} +#endif diff --git a/kvm.h b/kvm.h index 672d511..a8a86e7 100644 --- a/kvm.h +++ b/kvm.h @@ -14,10 +14,16 @@ #ifndef QEMU_KVM_H #define QEMU_KVM_H +#include +#include #include "config.h" #include "qemu-queue.h" #ifdef CONFIG_KVM +#include +#endif + +#ifdef CONFIG_KVM extern int kvm_allowed; #define kvm_enabled() (kvm_allowed) @@ -131,4 +137,14 @@ static inline void cpu_synchronize_state(CPUState *env) } } +#if defined(KVM_IOEVENTFD) && defined(CONFIG_KVM) +int kvm_set_ioeventfd(uint16_t addr, uint16_t data, int fd, bool assigned); +#else +static inline +int kvm_set_ioeventfd(uint16_t data, uint16_t addr, int fd, bool assigned) +{ + return -ENOSYS; +} +#endif + #endif -- 1.6.6.144.g5c3af