Enumerate registered devices to build a complete and updated mptable containing all registered pci devices. Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html