From patchwork Wed Oct 20 08:26:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 267971 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9K8PjFs025895 for ; Wed, 20 Oct 2010 08:25:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751956Ab0JTIZl (ORCPT ); Wed, 20 Oct 2010 04:25:41 -0400 Received: from mga03.intel.com ([143.182.124.21]:61694 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751676Ab0JTIZa (ORCPT ); Wed, 20 Oct 2010 04:25:30 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 20 Oct 2010 01:25:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.57,354,1283756400"; d="scan'208";a="338231136" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.13.14]) by azsmga001.ch.intel.com with ESMTP; 20 Oct 2010 01:25:28 -0700 Received: from yasker by syang10-desktop with local (Exim 4.71) (envelope-from ) id 1P8U0J-0007jT-AB; Wed, 20 Oct 2010 16:26:35 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, "Michael S. Tsirkin" , Sheng Yang Subject: [PATCH 5/8] KVM: Add kvm_get_irq_routing_entry() func Date: Wed, 20 Oct 2010 16:26:29 +0800 Message-Id: <1287563192-29685-6-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1287563192-29685-1-git-send-email-sheng@linux.intel.com> References: <1287563192-29685-1-git-send-email-sheng@linux.intel.com> 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 (demeter1.kernel.org [140.211.167.41]); Wed, 20 Oct 2010 08:25:45 +0000 (UTC) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7f9e4b7..30f83cd 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -614,6 +614,8 @@ int kvm_set_irq_routing(struct kvm *kvm, const struct kvm_irq_routing_entry *entries, unsigned nr, unsigned flags); +struct kvm_kernel_irq_routing_entry *kvm_get_irq_routing_entry(struct kvm *kvm, + int gsi); void kvm_free_irq_routing(struct kvm *kvm); #else diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 8edca91..80ced8c 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -421,6 +421,26 @@ out: return r; } +struct kvm_kernel_irq_routing_entry *kvm_get_irq_routing_entry(struct kvm *kvm, + int gsi) +{ + int count = 0; + struct kvm_kernel_irq_routing_entry *ei = NULL; + struct kvm_irq_routing_table *irq_rt; + struct hlist_node *n; + + rcu_read_lock(); + irq_rt = rcu_dereference(kvm->irq_routing); + if (gsi < irq_rt->nr_rt_entries) + hlist_for_each_entry(ei, n, &irq_rt->map[gsi], link) + count++; + rcu_read_unlock(); + if (count == 1) + return ei; + + return NULL; +} + #define IOAPIC_ROUTING_ENTRY(irq) \ { .gsi = irq, .type = KVM_IRQ_ROUTING_IRQCHIP, \ .u.irqchip.irqchip = KVM_IRQCHIP_IOAPIC, .u.irqchip.pin = (irq) }