compat: remove remaining PC_COMPAT macros

Use static arrays instead.  I decided to rename the conflicting
pc_compat_2_1() function with pc_compat_2_1_fn().

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
Marc-André Lureau 2018-12-12 21:57:53 +04:00
parent a1c3c562e2
commit a310e653ce
3 changed files with 267 additions and 258 deletions

View File

@ -72,6 +72,7 @@
#include "qapi/visitor.h"
#include "qom/cpu.h"
#include "hw/nmi.h"
#include "hw/usb.h"
#include "hw/i386/intel_iommu.h"
#include "hw/net/ne2000-isa.h"
@ -551,6 +552,237 @@ GlobalProperty pc_compat_2_1[] = {
};
const size_t pc_compat_2_1_len = G_N_ELEMENTS(pc_compat_2_1);
GlobalProperty pc_compat_2_0[] = {
PC_CPU_MODEL_IDS("2.0.0")
{
.driver = "virtio-scsi-pci",
.property = "any_layout",
.value = "off",
},{
.driver = "PIIX4_PM",
.property = "memory-hotplug-support",
.value = "off",
},
{
.driver = "apic",
.property = "version",
.value = stringify(0x11),
},
{
.driver = "nec-usb-xhci",
.property = "superspeed-ports-first",
.value = "off",
},
{
.driver = "nec-usb-xhci",
.property = "force-pcie-endcap",
.value = "on",
},
{
.driver = "pci-serial",
.property = "prog_if",
.value = stringify(0),
},
{
.driver = "pci-serial-2x",
.property = "prog_if",
.value = stringify(0),
},
{
.driver = "pci-serial-4x",
.property = "prog_if",
.value = stringify(0),
},
{
.driver = "virtio-net-pci",
.property = "guest_announce",
.value = "off",
},
{
.driver = "ICH9-LPC",
.property = "memory-hotplug-support",
.value = "off",
},{
.driver = "xio3130-downstream",
.property = COMPAT_PROP_PCP,
.value = "off",
},{
.driver = "ioh3420",
.property = COMPAT_PROP_PCP,
.value = "off",
},
};
const size_t pc_compat_2_0_len = G_N_ELEMENTS(pc_compat_2_0);
GlobalProperty pc_compat_1_7[] = {
PC_CPU_MODEL_IDS("1.7.0")
{
.driver = TYPE_USB_DEVICE,
.property = "msos-desc",
.value = "no",
},
{
.driver = "PIIX4_PM",
.property = "acpi-pci-hotplug-with-bridge-support",
.value = "off",
},
{
.driver = "hpet",
.property = HPET_INTCAP,
.value = stringify(4),
},
};
const size_t pc_compat_1_7_len = G_N_ELEMENTS(pc_compat_1_7);
GlobalProperty pc_compat_1_6[] = {
PC_CPU_MODEL_IDS("1.6.0")
{
.driver = "e1000",
.property = "mitigation",
.value = "off",
},{
.driver = "qemu64-" TYPE_X86_CPU,
.property = "model",
.value = stringify(2),
},{
.driver = "qemu32-" TYPE_X86_CPU,
.property = "model",
.value = stringify(3),
},{
.driver = "i440FX-pcihost",
.property = "short_root_bus",
.value = stringify(1),
},{
.driver = "q35-pcihost",
.property = "short_root_bus",
.value = stringify(1),
},
};
const size_t pc_compat_1_6_len = G_N_ELEMENTS(pc_compat_1_6);
GlobalProperty pc_compat_1_5[] = {
PC_CPU_MODEL_IDS("1.5.0")
{
.driver = "Conroe-" TYPE_X86_CPU,
.property = "model",
.value = stringify(2),
},{
.driver = "Conroe-" TYPE_X86_CPU,
.property = "min-level",
.value = stringify(2),
},{
.driver = "Penryn-" TYPE_X86_CPU,
.property = "model",
.value = stringify(2),
},{
.driver = "Penryn-" TYPE_X86_CPU,
.property = "min-level",
.value = stringify(2),
},{
.driver = "Nehalem-" TYPE_X86_CPU,
.property = "model",
.value = stringify(2),
},{
.driver = "Nehalem-" TYPE_X86_CPU,
.property = "min-level",
.value = stringify(2),
},{
.driver = "virtio-net-pci",
.property = "any_layout",
.value = "off",
},{
.driver = TYPE_X86_CPU,
.property = "pmu",
.value = "on",
},{
.driver = "i440FX-pcihost",
.property = "short_root_bus",
.value = stringify(0),
},{
.driver = "q35-pcihost",
.property = "short_root_bus",
.value = stringify(0),
},
};
const size_t pc_compat_1_5_len = G_N_ELEMENTS(pc_compat_1_5);
GlobalProperty pc_compat_1_4[] = {
PC_CPU_MODEL_IDS("1.4.0")
{
.driver = "scsi-hd",
.property = "discard_granularity",
.value = stringify(0),
},{
.driver = "scsi-cd",
.property = "discard_granularity",
.value = stringify(0),
},{
.driver = "scsi-disk",
.property = "discard_granularity",
.value = stringify(0),
},{
.driver = "ide-hd",
.property = "discard_granularity",
.value = stringify(0),
},{
.driver = "ide-cd",
.property = "discard_granularity",
.value = stringify(0),
},{
.driver = "ide-drive",
.property = "discard_granularity",
.value = stringify(0),
},{
.driver = "virtio-blk-pci",
.property = "discard_granularity",
.value = stringify(0),
},{
.driver = "virtio-serial-pci",
.property = "vectors",
/* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */
.value = stringify(0xFFFFFFFF),
},{
.driver = "virtio-net-pci",
.property = "ctrl_guest_offloads",
.value = "off",
},{
.driver = "e1000",
.property = "romfile",
.value = "pxe-e1000.rom",
},{
.driver = "ne2k_pci",
.property = "romfile",
.value = "pxe-ne2k_pci.rom",
},{
.driver = "pcnet",
.property = "romfile",
.value = "pxe-pcnet.rom",
},{
.driver = "rtl8139",
.property = "romfile",
.value = "pxe-rtl8139.rom",
},{
.driver = "virtio-net-pci",
.property = "romfile",
.value = "pxe-virtio.rom",
},{
.driver = "486-" TYPE_X86_CPU,
.property = "model",
.value = stringify(0),
},
{
.driver = "n270" "-" TYPE_X86_CPU,
.property = "movbe",
.value = "off",
},
{
.driver = "Westmere" "-" TYPE_X86_CPU,
.property = "pclmulqdq",
.value = "off",
},
};
const size_t pc_compat_1_4_len = G_N_ELEMENTS(pc_compat_1_4);
void gsi_handler(void *opaque, int n, int level)
{
GSIState *s = opaque;

View File

@ -329,35 +329,35 @@ static void pc_compat_2_1_fn(MachineState *machine)
x86_cpu_change_kvm_default("svm", NULL);
}
static void pc_compat_2_0(MachineState *machine)
static void pc_compat_2_0_fn(MachineState *machine)
{
pc_compat_2_1_fn(machine);
}
static void pc_compat_1_7(MachineState *machine)
static void pc_compat_1_7_fn(MachineState *machine)
{
pc_compat_2_0(machine);
pc_compat_2_0_fn(machine);
x86_cpu_change_kvm_default("x2apic", NULL);
}
static void pc_compat_1_6(MachineState *machine)
static void pc_compat_1_6_fn(MachineState *machine)
{
pc_compat_1_7(machine);
pc_compat_1_7_fn(machine);
}
static void pc_compat_1_5(MachineState *machine)
static void pc_compat_1_5_fn(MachineState *machine)
{
pc_compat_1_6(machine);
pc_compat_1_6_fn(machine);
}
static void pc_compat_1_4(MachineState *machine)
static void pc_compat_1_4_fn(MachineState *machine)
{
pc_compat_1_5(machine);
pc_compat_1_5_fn(machine);
}
static void pc_compat_1_3(MachineState *machine)
{
pc_compat_1_4(machine);
pc_compat_1_4_fn(machine);
enable_compat_apic_id_mode();
}
@ -609,13 +609,10 @@ DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1_fn,
static void pc_i440fx_2_0_machine_options(MachineClass *m)
{
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
static GlobalProperty compat[] = {
PC_COMPAT_2_0
};
pc_i440fx_2_1_machine_options(m);
m->hw_version = "2.0.0";
compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
compat_props_add(m->compat_props, pc_compat_2_0, pc_compat_2_0_len);
pcmc->smbios_legacy_mode = true;
pcmc->has_reserved_memory = false;
/* This value depends on the actual DSDT and SSDT compiled into
@ -638,73 +635,59 @@ static void pc_i440fx_2_0_machine_options(MachineClass *m)
pcmc->acpi_data_size = 0x10000;
}
DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0_fn,
pc_i440fx_2_0_machine_options);
static void pc_i440fx_1_7_machine_options(MachineClass *m)
{
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
static GlobalProperty compat[] = {
PC_COMPAT_1_7
};
pc_i440fx_2_0_machine_options(m);
m->hw_version = "1.7.0";
m->default_machine_opts = NULL;
m->option_rom_has_mr = true;
compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
compat_props_add(m->compat_props, pc_compat_1_7, pc_compat_1_7_len);
pcmc->smbios_defaults = false;
pcmc->gigabyte_align = false;
pcmc->legacy_acpi_table_size = 6414;
}
DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7_fn,
pc_i440fx_1_7_machine_options);
static void pc_i440fx_1_6_machine_options(MachineClass *m)
{
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
static GlobalProperty compat[] = {
PC_COMPAT_1_6
};
pc_i440fx_1_7_machine_options(m);
m->hw_version = "1.6.0";
m->rom_file_has_mr = false;
compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
compat_props_add(m->compat_props, pc_compat_1_6, pc_compat_1_6_len);
pcmc->has_acpi_build = false;
}
DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6,
DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6_fn,
pc_i440fx_1_6_machine_options);
static void pc_i440fx_1_5_machine_options(MachineClass *m)
{
static GlobalProperty compat[] = {
PC_COMPAT_1_5
};
pc_i440fx_1_6_machine_options(m);
m->hw_version = "1.5.0";
compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
compat_props_add(m->compat_props, pc_compat_1_5, pc_compat_1_5_len);
}
DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5,
DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5_fn,
pc_i440fx_1_5_machine_options);
static void pc_i440fx_1_4_machine_options(MachineClass *m)
{
static GlobalProperty compat[] = {
PC_COMPAT_1_4
};
pc_i440fx_1_5_machine_options(m);
m->hw_version = "1.4.0";
m->hot_add_cpu = NULL;
compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
compat_props_add(m->compat_props, pc_compat_1_4, pc_compat_1_4_len);
}
DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4_fn,
pc_i440fx_1_4_machine_options);
static void pc_i440fx_1_3_machine_options(MachineClass *m)

View File

@ -335,6 +335,21 @@ extern const size_t pc_compat_2_2_len;
extern GlobalProperty pc_compat_2_1[];
extern const size_t pc_compat_2_1_len;
extern GlobalProperty pc_compat_2_0[];
extern const size_t pc_compat_2_0_len;
extern GlobalProperty pc_compat_1_7[];
extern const size_t pc_compat_1_7_len;
extern GlobalProperty pc_compat_1_6[];
extern const size_t pc_compat_1_6_len;
extern GlobalProperty pc_compat_1_5[];
extern const size_t pc_compat_1_5_len;
extern GlobalProperty pc_compat_1_4[];
extern const size_t pc_compat_1_4_len;
/* Helper for setting model-id for CPU models that changed model-id
* depending on QEMU versions up to QEMU 2.4.
*/
@ -355,227 +370,6 @@ extern const size_t pc_compat_2_1_len;
.value = "QEMU Virtual CPU version " v,\
},
#define PC_COMPAT_2_0 \
PC_CPU_MODEL_IDS("2.0.0") \
{\
.driver = "virtio-scsi-pci",\
.property = "any_layout",\
.value = "off",\
},{\
.driver = "PIIX4_PM",\
.property = "memory-hotplug-support",\
.value = "off",\
},\
{\
.driver = "apic",\
.property = "version",\
.value = stringify(0x11),\
},\
{\
.driver = "nec-usb-xhci",\
.property = "superspeed-ports-first",\
.value = "off",\
},\
{\
.driver = "nec-usb-xhci",\
.property = "force-pcie-endcap",\
.value = "on",\
},\
{\
.driver = "pci-serial",\
.property = "prog_if",\
.value = stringify(0),\
},\
{\
.driver = "pci-serial-2x",\
.property = "prog_if",\
.value = stringify(0),\
},\
{\
.driver = "pci-serial-4x",\
.property = "prog_if",\
.value = stringify(0),\
},\
{\
.driver = "virtio-net-pci",\
.property = "guest_announce",\
.value = "off",\
},\
{\
.driver = "ICH9-LPC",\
.property = "memory-hotplug-support",\
.value = "off",\
},{\
.driver = "xio3130-downstream",\
.property = COMPAT_PROP_PCP,\
.value = "off",\
},{\
.driver = "ioh3420",\
.property = COMPAT_PROP_PCP,\
.value = "off",\
},
#define PC_COMPAT_1_7 \
PC_CPU_MODEL_IDS("1.7.0") \
{\
.driver = TYPE_USB_DEVICE,\
.property = "msos-desc",\
.value = "no",\
},\
{\
.driver = "PIIX4_PM",\
.property = "acpi-pci-hotplug-with-bridge-support",\
.value = "off",\
},\
{\
.driver = "hpet",\
.property = HPET_INTCAP,\
.value = stringify(4),\
},
#define PC_COMPAT_1_6 \
PC_CPU_MODEL_IDS("1.6.0") \
{\
.driver = "e1000",\
.property = "mitigation",\
.value = "off",\
},{\
.driver = "qemu64-" TYPE_X86_CPU,\
.property = "model",\
.value = stringify(2),\
},{\
.driver = "qemu32-" TYPE_X86_CPU,\
.property = "model",\
.value = stringify(3),\
},{\
.driver = "i440FX-pcihost",\
.property = "short_root_bus",\
.value = stringify(1),\
},{\
.driver = "q35-pcihost",\
.property = "short_root_bus",\
.value = stringify(1),\
},
#define PC_COMPAT_1_5 \
PC_CPU_MODEL_IDS("1.5.0") \
{\
.driver = "Conroe-" TYPE_X86_CPU,\
.property = "model",\
.value = stringify(2),\
},{\
.driver = "Conroe-" TYPE_X86_CPU,\
.property = "min-level",\
.value = stringify(2),\
},{\
.driver = "Penryn-" TYPE_X86_CPU,\
.property = "model",\
.value = stringify(2),\
},{\
.driver = "Penryn-" TYPE_X86_CPU,\
.property = "min-level",\
.value = stringify(2),\
},{\
.driver = "Nehalem-" TYPE_X86_CPU,\
.property = "model",\
.value = stringify(2),\
},{\
.driver = "Nehalem-" TYPE_X86_CPU,\
.property = "min-level",\
.value = stringify(2),\
},{\
.driver = "virtio-net-pci",\
.property = "any_layout",\
.value = "off",\
},{\
.driver = TYPE_X86_CPU,\
.property = "pmu",\
.value = "on",\
},{\
.driver = "i440FX-pcihost",\
.property = "short_root_bus",\
.value = stringify(0),\
},{\
.driver = "q35-pcihost",\
.property = "short_root_bus",\
.value = stringify(0),\
},
#define PC_COMPAT_1_4 \
PC_CPU_MODEL_IDS("1.4.0") \
{\
.driver = "scsi-hd",\
.property = "discard_granularity",\
.value = stringify(0),\
},{\
.driver = "scsi-cd",\
.property = "discard_granularity",\
.value = stringify(0),\
},{\
.driver = "scsi-disk",\
.property = "discard_granularity",\
.value = stringify(0),\
},{\
.driver = "ide-hd",\
.property = "discard_granularity",\
.value = stringify(0),\
},{\
.driver = "ide-cd",\
.property = "discard_granularity",\
.value = stringify(0),\
},{\
.driver = "ide-drive",\
.property = "discard_granularity",\
.value = stringify(0),\
},{\
.driver = "virtio-blk-pci",\
.property = "discard_granularity",\
.value = stringify(0),\
},{\
.driver = "virtio-serial-pci",\
.property = "vectors",\
/* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
.value = stringify(0xFFFFFFFF),\
},{ \
.driver = "virtio-net-pci", \
.property = "ctrl_guest_offloads", \
.value = "off", \
},{\
.driver = "e1000",\
.property = "romfile",\
.value = "pxe-e1000.rom",\
},{\
.driver = "ne2k_pci",\
.property = "romfile",\
.value = "pxe-ne2k_pci.rom",\
},{\
.driver = "pcnet",\
.property = "romfile",\
.value = "pxe-pcnet.rom",\
},{\
.driver = "rtl8139",\
.property = "romfile",\
.value = "pxe-rtl8139.rom",\
},{\
.driver = "virtio-net-pci",\
.property = "romfile",\
.value = "pxe-virtio.rom",\
},{\
.driver = "486-" TYPE_X86_CPU,\
.property = "model",\
.value = stringify(0),\
},\
{\
.driver = "n270" "-" TYPE_X86_CPU,\
.property = "movbe",\
.value = "off",\
},\
{\
.driver = "Westmere" "-" TYPE_X86_CPU,\
.property = "pclmulqdq",\
.value = "off",\
},
#define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
{ \