Populate the always_available_buses list for the PC machines. This will allow qmp-machine-info.py to run in strict mode for x86.
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> --- Changes v1 -> v2: * Use the new machine_class_add_always_available_bus() function, include bus IDs * Report legacy PCI and PCIe on q35 pcie.0 bus * Make sure legacy PCI is reported on i440fx --- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 25 +++++++++++++++++++++++++ hw/i386/pc_q35.c | 21 +++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index a9e64a8..67e41c1 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2298,6 +2298,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) mc->hot_add_cpu = pc_hot_add_cpu; mc->max_cpus = 255; mc->reset = pc_machine_reset; + machine_class_add_always_available_bus(mc, "sysbus", TYPE_SYSTEM_BUS); hc->pre_plug = pc_machine_device_pre_plug_cb; hc->plug = pc_machine_device_plug_cb; hc->unplug_request = pc_machine_device_unplug_request_cb; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index a59bbb9..d0162a9 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -430,11 +430,26 @@ static void pc_xen_hvm_init(MachineState *machine) static void pc_i440fx_machine_options(MachineClass *m) { + MachineBusInfo *pci0; + m->family = "pc_piix"; m->desc = "Standard PC (i440FX + PIIX, 1996)"; m->hot_add_cpu = pc_hot_add_cpu; m->default_machine_opts = "firmware=bios-256k.bin"; m->default_display = "std"; + pci0 = machine_class_add_always_available_bus(m, "pci.0", TYPE_PCI_BUS); + + /* Sanity check to ensure we are reporting only legacy PCI devices as supported */ + assert(pci0->accepted_device_types != NULL && + pci0->accepted_device_types->next == NULL && + !strcmp(pci0->accepted_device_types->value, + INTERFACE_LEGACY_PCI_DEVICE)); + + machine_class_add_always_available_bus(m, "floppy-bus.0", "floppy-bus"); //FIXME: use macro + machine_class_add_always_available_bus(m, "i2c", "i2c-bus"); //FIXME: use macro + machine_class_add_always_available_bus(m, "isa.0", TYPE_ISA_BUS); + machine_class_add_always_available_bus(m, "ide.0", "IDE");//FIXME: use macro + machine_class_add_always_available_bus(m, "ide.1", "IDE");//FIXME: use macro } static void pc_i440fx_2_8_machine_options(MachineClass *m) @@ -1083,6 +1098,10 @@ static void isapc_machine_options(MachineClass *m) m->max_cpus = 1; m->option_rom_has_mr = true; m->rom_file_has_mr = false; + machine_class_add_always_available_bus(m, "floppy-bus.0", "floppy-bus"); //FIXME: use macro + machine_class_add_always_available_bus(m, "isa.0", TYPE_ISA_BUS); + machine_class_add_always_available_bus(m, "ide.0", "IDE");//FIXME: use macro + machine_class_add_always_available_bus(m, "ide.1", "IDE");//FIXME: use macro pcmc->pci_enabled = false; pcmc->has_acpi_build = false; pcmc->smbios_defaults = false; @@ -1102,6 +1121,12 @@ static void xenfv_machine_options(MachineClass *m) m->max_cpus = HVM_MAX_VCPUS; m->default_machine_opts = "accel=xen"; m->hot_add_cpu = pc_hot_add_cpu; + machine_class_add_always_available_bus(m, "floppy-bus.0", "floppy-bus"); //FIXME: use macro + machine_class_add_always_available_bus(m, "i2c", "i2c-bus"); //FIXME: use macro + machine_class_add_always_available_bus(m, "pci.0", TYPE_PCI_BUS); + machine_class_add_always_available_bus(m, "isa.0", TYPE_ISA_BUS); + machine_class_add_always_available_bus(m, "ide.0", "IDE");//FIXME: use macro + machine_class_add_always_available_bus(m, "ide.1", "IDE");//FIXME: use macro } DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index b40d19e..11f918c 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -283,6 +283,9 @@ static void pc_q35_init(MachineState *machine) static void pc_q35_machine_options(MachineClass *m) { + MachineBusInfo *pcie; + strList *new; + m->family = "pc_q35"; m->desc = "Standard PC (Q35 + ICH9, 2009)"; m->hot_add_cpu = pc_hot_add_cpu; @@ -292,6 +295,24 @@ static void pc_q35_machine_options(MachineClass *m) m->no_floppy = 1; m->has_dynamic_sysbus = true; m->max_cpus = 288; + + pcie = machine_class_add_always_available_bus(m, "pcie.0", TYPE_PCIE_BUS); + /* The root bus doesn't use the TYPE_PCIE_BUS default: it also accepts + * legacy PCI devices. + */ + new = g_new0(strList, 1); + new->value = g_strdup(INTERFACE_LEGACY_PCI_DEVICE); + new->next = pcie->accepted_device_types; + pcie->accepted_device_types = new; + + machine_class_add_always_available_bus(m, "i2c", "i2c-bus"); //FIXME: use macro + machine_class_add_always_available_bus(m, "isa.0", TYPE_ISA_BUS); + machine_class_add_always_available_bus(m, "ide.0", "IDE");//FIXME: use macro + machine_class_add_always_available_bus(m, "ide.1", "IDE");//FIXME: use macro + machine_class_add_always_available_bus(m, "ide.2", "IDE");//FIXME: use macro + machine_class_add_always_available_bus(m, "ide.3", "IDE");//FIXME: use macro + machine_class_add_always_available_bus(m, "ide.4", "IDE");//FIXME: use macro + machine_class_add_always_available_bus(m, "ide.5", "IDE");//FIXME: use macro } static void pc_q35_2_8_machine_options(MachineClass *m) -- 2.7.4