From patchwork Mon Mar 2 08:29:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 9507 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n228Ttbd011346 for ; Mon, 2 Mar 2009 08:29:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756252AbZCBI3v (ORCPT ); Mon, 2 Mar 2009 03:29:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756553AbZCBI3v (ORCPT ); Mon, 2 Mar 2009 03:29:51 -0500 Received: from mga02.intel.com ([134.134.136.20]:54584 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756252AbZCBI3n (ORCPT ); Mon, 2 Mar 2009 03:29:43 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 02 Mar 2009 00:24:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,288,1233561600"; d="scan'208";a="390802288" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.13.189]) by orsmga002.jf.intel.com with ESMTP; 02 Mar 2009 00:38:15 -0800 Received: from yasker by syang10-desktop with local (Exim 4.69) (envelope-from ) id 1Le3Wo-0001oP-2D; Mon, 02 Mar 2009 16:29:34 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti , Anthony Liguori Cc: kvm@vger.kernel.org, Sheng Yang Subject: [PATCH 06/10] kvm: libkvm: allocate unused gsi for irq routing Date: Mon, 2 Mar 2009 16:29:29 +0800 Message-Id: <1235982573-6932-7-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.5.6.3 In-Reply-To: <1235982573-6932-1-git-send-email-sheng@linux.intel.com> References: <1235982573-6932-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 Notice here is a simple solution, can be replaced later. Signed-off-by: Sheng Yang --- libkvm/kvm-common.h | 1 + libkvm/libkvm.c | 10 ++++++++++ libkvm/libkvm.h | 8 ++++++++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h index de1ada2..70a95c2 100644 --- a/libkvm/kvm-common.h +++ b/libkvm/kvm-common.h @@ -66,6 +66,7 @@ struct kvm_context { #ifdef KVM_CAP_IRQ_ROUTING struct kvm_irq_routing *irq_routes; int nr_allocated_irq_routes; + int max_used_gsi; #endif }; diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index 050eacd..58ac995 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -1256,6 +1256,9 @@ int kvm_add_routing_entry(kvm_context_t kvm, new->type = entry->type; new->flags = entry->flags; new->u = entry->u; + + if (entry->gsi > kvm->max_used_gsi) + kvm->max_used_gsi = entry->gsi; return 0; #else return -ENOSYS; @@ -1359,3 +1362,10 @@ int kvm_commit_irq_routes(kvm_context_t kvm) return -ENOSYS; #endif } + +int kvm_get_irq_route_gsi(kvm_context_t kvm) +{ + return (kvm->max_used_gsi >= KVM_IOAPIC_NUM_PINS) ? + (kvm->max_used_gsi + 1) : KVM_IOAPIC_NUM_PINS; +} + diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h index d9b3ce1..65c4e75 100644 --- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -833,4 +833,12 @@ int kvm_del_routing_entry(kvm_context_t kvm, */ int kvm_commit_irq_routes(kvm_context_t kvm); +/*! + * \brief Get unused GSI number for irq routing table + * + * Get unused GSI number for irq routing table + * + * \param kvm Pointer to the current kvm_context + */ +int kvm_get_irq_route_gsi(kvm_context_t kvm); #endif