From patchwork Wed Mar 17 13:04:49 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: 86329 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 o2HD8H2t024721 for ; Wed, 17 Mar 2010 13:08:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754788Ab0CQNIP (ORCPT ); Wed, 17 Mar 2010 09:08:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27573 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754366Ab0CQNIO (ORCPT ); Wed, 17 Mar 2010 09:08:14 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2HD8D3q021645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Mar 2010 09:08:14 -0400 Received: from redhat.com (vpn1-6-114.ams2.redhat.com [10.36.6.114]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o2HD8C5A014062 for ; Wed, 17 Mar 2010 09:08:13 -0400 Date: Wed, 17 Mar 2010 15:04:49 +0200 From: "Michael S. Tsirkin" To: kvm@vger.kernel.org Subject: [PATCHv6 2/4] kvm: irqfd support Message-ID: <58f5c94c30df0844152954ddb171526a9b6d19a2.1268831034.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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]); Wed, 17 Mar 2010 13:08:17 +0000 (UTC) diff --git a/kvm-all.c b/kvm-all.c index 7b05462..1a15662 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1200,5 +1200,24 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign) } #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_enabled() || !kvm_irqchip_in_kernel()) + return -ENOSYS; + + r = kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd); + if (r < 0) + return r; + return 0; +} +#endif + #undef PAGE_SIZE #include "qemu-kvm.c" diff --git a/kvm.h b/kvm.h index 0951380..72dcaca 100644 --- a/kvm.h +++ b/kvm.h @@ -180,4 +180,14 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign) } #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