From patchwork Thu Feb 4 15:29:06 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: 77047 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 o14FWLR2019706 for ; Thu, 4 Feb 2010 15:32:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932261Ab0BDPcT (ORCPT ); Thu, 4 Feb 2010 10:32:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3672 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758231Ab0BDPcR (ORCPT ); Thu, 4 Feb 2010 10:32:17 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o14FWHe2030566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Feb 2010 10:32:17 -0500 Received: from redhat.com (vpn2-9-138.ams2.redhat.com [10.36.9.138]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o14FWFM9025029 for ; Thu, 4 Feb 2010 10:32:16 -0500 Date: Thu, 4 Feb 2010 17:29:06 +0200 From: "Michael S. Tsirkin" To: kvm@vger.kernel.org Subject: [PATCH 18/20] kvm: irqfd support Message-ID: <20100204152906.GS8461@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.17 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:32:21 +0000 (UTC) diff --git a/kvm-all.c b/kvm-all.c index 6dbe480..3c692f6 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1154,4 +1154,23 @@ int kvm_set_ioeventfd(uint16_t addr, uint16_t data, int fd, bool assigned) } #endif +#if defined(KVM_IRQFD) +int kvm_set_irqfd(int gsi, int fd, bool assigned) +{ + struct kvm_irqfd irqfd = { + .fd = fd, + .gsi = gsi, + .flags = assigned ? 0 : KVM_IRQFD_FLAG_DEASSIGN, + }; + int r; + if (!kvm_irqchip_in_kernel()) + return -ENOSYS; + + r = kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd); + if (r < 0) + return r; + return 0; +} +#endif + #include "qemu-kvm.c" diff --git a/kvm.h b/kvm.h index 365d8b1..e762a5b 100644 --- a/kvm.h +++ b/kvm.h @@ -159,4 +159,14 @@ int kvm_set_ioeventfd(uint16_t data, uint16_t addr, int fd, bool assigned) } #endif +#if defined(KVM_IRQFD) && defined(CONFIG_KVM) +int kvm_set_irqfd(int gsi, int fd, bool assigned); +#else +static inline +int kvm_set_irqfd(int gsi, int fd, bool assigned) +{ + return -ENOSYS; +} +#endif + #endif