From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NUNvz-0000Bh-GP for qemu-devel@nongnu.org; Mon, 11 Jan 2010 12:20:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NUNvu-0008VC-7F for qemu-devel@nongnu.org; Mon, 11 Jan 2010 12:20:06 -0500 Received: from [199.232.76.173] (port=58004 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUNvt-0008Un-PQ for qemu-devel@nongnu.org; Mon, 11 Jan 2010 12:20:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38457) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NUNvs-0007u7-TM for qemu-devel@nongnu.org; Mon, 11 Jan 2010 12:20:01 -0500 Date: Mon, 11 Jan 2010 19:17:03 +0200 From: "Michael S. Tsirkin" Message-ID: <20100111171703.GC11936@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH-RFC 02/13] 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 Signed-off-by: Michael S. Tsirkin --- kvm-all.c | 24 ++++++++++++++++++++++++ kvm.h | 3 +++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index a312654..aa00119 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1113,3 +1113,27 @@ 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, + }; + if (!assigned) + kick.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN; + int r = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &kick); + if (r < 0) + return r; + return 0; +} +#else +int kvm_set_ioeventfd(uint16_t data, uint16_t addr, int fd, bool assigned) +{ + return -ENOSYS; +} +#endif diff --git a/kvm.h b/kvm.h index 672d511..2d723b8 100644 --- a/kvm.h +++ b/kvm.h @@ -14,6 +14,7 @@ #ifndef QEMU_KVM_H #define QEMU_KVM_H +#include #include "config.h" #include "qemu-queue.h" @@ -131,4 +132,6 @@ static inline void cpu_synchronize_state(CPUState *env) } } +int kvm_set_ioeventfd(uint16_t addr, uint16_t data, int fd, bool assigned); + #endif -- 1.6.6.rc1.43.gf55cc