From patchwork Thu Feb 4 15:27:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 77034 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o14FV3NQ016508 for ; Thu, 4 Feb 2010 15:31:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932766Ab0BDPbA (ORCPT ); Thu, 4 Feb 2010 10:31:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15273 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932221Ab0BDPa7 (ORCPT ); Thu, 4 Feb 2010 10:30:59 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o14FUxIw020856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Feb 2010 10:30:59 -0500 Received: from redhat.com (vpn2-9-138.ams2.redhat.com [10.36.9.138]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o14FUvFS005108 for ; Thu, 4 Feb 2010 10:30:58 -0500 Date: Thu, 4 Feb 2010 17:27:48 +0200 From: "Michael S. Tsirkin" To: kvm@vger.kernel.org Subject: [PATCH 05/20] kvm: add API to set ioeventfd Message-ID: <20100204152748.GF8461@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 04 Feb 2010 15:31:04 +0000 (UTC) diff --git a/kvm-all.c b/kvm-all.c index 51273e4..6dbe480 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1134,4 +1134,24 @@ 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 + #include "qemu-kvm.c" diff --git a/kvm.h b/kvm.h index 7b33177..365d8b1 100644 --- a/kvm.h +++ b/kvm.h @@ -14,6 +14,8 @@ #ifndef QEMU_KVM_H #define QEMU_KVM_H +#include +#include #include "config.h" #include "qemu-queue.h" #include "qemu-kvm.h" @@ -21,6 +23,10 @@ #ifdef KVM_UPSTREAM #ifdef CONFIG_KVM +#include +#endif + +#ifdef CONFIG_KVM extern int kvm_allowed; #define kvm_enabled() (kvm_allowed) @@ -143,4 +149,14 @@ static inline void cpu_synchronize_state(CPUState *env) #endif +#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