From patchwork Fri May 6 11:24:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 761962 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 p46BOj02025641 for ; Fri, 6 May 2011 11:24:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755333Ab1EFLYo (ORCPT ); Fri, 6 May 2011 07:24:44 -0400 Received: from mail-ww0-f42.google.com ([74.125.82.42]:41120 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755265Ab1EFLYn (ORCPT ); Fri, 6 May 2011 07:24:43 -0400 Received: by wwk4 with SMTP id 4so307884wwk.1 for ; Fri, 06 May 2011 04:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=VNGqyZJER3gqSrPfspPgDUdKucCmdfbEI8q+S65R2AI=; b=pkSWDSLlgSgT1TcoOiTA7AeHNpvvy4QZ53J9MGEPHUQd1KPxdTNW3fXKN1AdHHBet3 ob/Ovvmfy6bgfduPn7Ncajh2PsiQMhq6c7eMe/vbHckjVonC5P1b7Jw1HHJB4CKCUbqk wSNZRPx36GklxB58yXNQFUMeH2g9FuR7afrZA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=KUEUbGROmbBiI1dQUZXylWUbwJmlrfus4O/uZq+UiOWHP6ICwcJOwxOtEvUqC8n9Sn hTY0a+pbPjoAhYW3S1Q9C+YN4N1vzlPcKmF5klPwPoScc3RTisrzQ9CJbfFSj1OeBMsu 5tpXWj7ce19Ccc8ZSuJPK2sVz4cGxMVWGdbZM= Received: by 10.216.5.196 with SMTP id 46mr429204wel.19.1304681081681; Fri, 06 May 2011 04:24:41 -0700 (PDT) Received: from localhost.localdomain ([109.65.211.213]) by mx.google.com with ESMTPS id f52sm1560856wes.35.2011.05.06.04.24.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 06 May 2011 04:24:41 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 2/3] kvm tools: Dynamically add devices when creating mptable Date: Fri, 6 May 2011 14:24:11 +0300 Message-Id: <1304681052-30992-2-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1304681052-30992-1-git-send-email-levinsasha928@gmail.com> References: <1304681052-30992-1-git-send-email-levinsasha928@gmail.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.6 (demeter1.kernel.org [140.211.167.41]); Fri, 06 May 2011 11:24:46 +0000 (UTC) Enumerate registered devices to build a complete and updated mptable containing all registered pci devices. Signed-off-by: Sasha Levin --- tools/kvm/kvm-run.c | 4 ++-- tools/kvm/mptable.c | 30 +++++++++++------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index d5a952f..bb228fe 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -446,8 +446,6 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) rtc__init(); - kvm__setup_bios(kvm); - serial8250__init(kvm); pci__init(); @@ -479,6 +477,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) kvm__start_timer(kvm); + kvm__setup_bios(kvm); + for (i = 0; i < nrcpus; i++) { kvm_cpus[i] = kvm_cpu__init(kvm, i); if (!kvm_cpus[i]) diff --git a/tools/kvm/mptable.c b/tools/kvm/mptable.c index 5a24336..c75d9ce 100644 --- a/tools/kvm/mptable.c +++ b/tools/kvm/mptable.c @@ -3,6 +3,7 @@ #include "kvm/apic.h" #include "kvm/mptable.h" #include "kvm/util.h" +#include "kvm/irq.h" #include #include @@ -87,6 +88,7 @@ void mptable_setup(struct kvm *kvm, unsigned int ncpus) struct mpc_bus *mpc_bus; struct mpc_ioapic *mpc_ioapic; struct mpc_intsrc *mpc_intsrc; + struct rb_node *pci_tree; const int pcibusid = 0; const int isabusid = 1; @@ -186,30 +188,20 @@ void mptable_setup(struct kvm *kvm, unsigned int ncpus) * * Also note we use PCI irqs here, no for ISA bus yet. */ - mpc_intsrc = last_addr; - /* src irq = virtio console irq pin, dst irq = virtio console irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 2, ioapicid, 13); - last_addr = (void *)&mpc_intsrc[1]; - nentries++; + for (pci_tree = irq__get_pci_tree(); pci_tree; pci_tree = rb_next(pci_tree)) { + struct pci_dev *dev = rb_entry(pci_tree, struct pci_dev, node); + struct irq_line *tmp; - /* Currently we define 4 possible virtio-blk devices */ - for (i = 0; i < 4; i++) { - mpc_intsrc = last_addr; + list_for_each_entry(tmp, &dev->lines, node) { + mpc_intsrc = last_addr; - /* src irq = virtio blk irq pin, dst irq = virtio blk irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 1, ioapicid, 9 + i); - last_addr = (void *)&mpc_intsrc[1]; - nentries++; + mptable_add_irq_src(mpc_intsrc, pcibusid, dev->pin, ioapicid, tmp->line); + last_addr = (void *)&mpc_intsrc[1]; + nentries++; + } } - mpc_intsrc = last_addr; - - /* src irq = virtio net irq pin, dst irq = virtio net irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 3, ioapicid, 14); - last_addr = (void *)&mpc_intsrc[1]; - nentries++; - /* * Local IRQs assignment (LINT0, LINT1) */