From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org
Cc: mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com,
prasadjoshi124@gmail.com, kvm@vger.kernel.org,
Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH 2/3] kvm tools: Dynamically add devices when creating mptable
Date: Fri, 6 May 2011 14:24:11 +0300 [thread overview]
Message-ID: <1304681052-30992-2-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1304681052-30992-1-git-send-email-levinsasha928@gmail.com>
Enumerate registered devices to build a complete
and updated mptable containing all registered pci
devices.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
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 <linux/kernel.h>
#include <string.h>
@@ -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)
*/
--
1.7.5.rc3
next prev parent reply other threads:[~2011-05-06 11:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-06 11:24 [PATCH 1/3] kvm tools: Introduce IRQ registry Sasha Levin
2011-05-06 11:24 ` Sasha Levin [this message]
2011-05-06 11:24 ` [PATCH 3/3] kvm tools: Convert virtio devices to use " Sasha Levin
2011-05-06 11:56 ` Ingo Molnar
2011-05-06 16:50 ` Sasha Levin
2011-05-06 19:16 ` Ingo Molnar
2011-05-07 9:13 ` [PATCH 1/3] kvm tools: Introduce " Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1304681052-30992-2-git-send-email-levinsasha928@gmail.com \
--to=levinsasha928@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
--cc=prasadjoshi124@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox