From 865906f7fdadd2732441ab158787f81f6a212bfe Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Fri, 15 May 2015 14:18:56 -0300 Subject: pc: Don't use QEMUMachine anymore Now that we have a DEFINE_PC_MACHINE helper macro that just requires an initialization function, it is trivial to convert them to register a QOM machine class directly, instead of using QEMUMachine. Signed-off-by: Eduardo Habkost Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 44 ++++++++++++++++++++++---------------------- hw/i386/pc_q35.c | 20 ++++++++++---------- include/hw/i386/pc.h | 22 +++++++++++++++------- 3 files changed, 47 insertions(+), 39 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 89f55d7..052fca2 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -518,7 +518,7 @@ static void pc_xen_hvm_init(MachineState *machine) #endif -static void pc_i440fx_machine_options(QEMUMachine *m) +static void pc_i440fx_machine_options(MachineClass *m) { pc_default_machine_options(m); m->family = "pc_piix"; @@ -526,7 +526,7 @@ static void pc_i440fx_machine_options(QEMUMachine *m) m->hot_add_cpu = pc_hot_add_cpu; } -static void pc_i440fx_2_4_machine_options(QEMUMachine *m) +static void pc_i440fx_2_4_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->default_machine_opts = "firmware=bios-256k.bin"; @@ -539,7 +539,7 @@ DEFINE_PC_MACHINE(v2_4, "pc-i440fx-2.4", pc_init_pci, pc_i440fx_2_4_machine_options) -static void pc_i440fx_2_3_machine_options(QEMUMachine *m) +static void pc_i440fx_2_3_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->alias = NULL; @@ -551,7 +551,7 @@ DEFINE_PC_MACHINE(v2_3, "pc-i440fx-2.3", pc_init_pci_2_3, pc_i440fx_2_3_machine_options); -static void pc_i440fx_2_2_machine_options(QEMUMachine *m) +static void pc_i440fx_2_2_machine_options(MachineClass *m) { pc_i440fx_2_3_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); @@ -561,7 +561,7 @@ DEFINE_PC_MACHINE(v2_2, "pc-i440fx-2.2", pc_init_pci_2_2, pc_i440fx_2_2_machine_options); -static void pc_i440fx_2_1_machine_options(QEMUMachine *m) +static void pc_i440fx_2_1_machine_options(MachineClass *m) { pc_i440fx_2_2_machine_options(m); m->default_display = NULL; @@ -573,7 +573,7 @@ DEFINE_PC_MACHINE(v2_1, "pc-i440fx-2.1", pc_init_pci_2_1, -static void pc_i440fx_2_0_machine_options(QEMUMachine *m) +static void pc_i440fx_2_0_machine_options(MachineClass *m) { pc_i440fx_2_1_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); @@ -583,7 +583,7 @@ DEFINE_PC_MACHINE(v2_0, "pc-i440fx-2.0", pc_init_pci_2_0, pc_i440fx_2_0_machine_options); -static void pc_i440fx_1_7_machine_options(QEMUMachine *m) +static void pc_i440fx_1_7_machine_options(MachineClass *m) { pc_i440fx_2_0_machine_options(m); m->default_machine_opts = NULL; @@ -594,7 +594,7 @@ DEFINE_PC_MACHINE(v1_7, "pc-i440fx-1.7", pc_init_pci_1_7, pc_i440fx_1_7_machine_options); -static void pc_i440fx_1_6_machine_options(QEMUMachine *m) +static void pc_i440fx_1_6_machine_options(MachineClass *m) { pc_i440fx_1_7_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); @@ -604,7 +604,7 @@ DEFINE_PC_MACHINE(v1_6, "pc-i440fx-1.6", pc_init_pci_1_6, pc_i440fx_1_6_machine_options); -static void pc_i440fx_1_5_machine_options(QEMUMachine *m) +static void pc_i440fx_1_5_machine_options(MachineClass *m) { pc_i440fx_1_6_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); @@ -614,7 +614,7 @@ DEFINE_PC_MACHINE(v1_5, "pc-i440fx-1.5", pc_init_pci_1_5, pc_i440fx_1_5_machine_options); -static void pc_i440fx_1_4_machine_options(QEMUMachine *m) +static void pc_i440fx_1_4_machine_options(MachineClass *m) { pc_i440fx_1_5_machine_options(m); m->hot_add_cpu = NULL; @@ -646,7 +646,7 @@ DEFINE_PC_MACHINE(v1_4, "pc-i440fx-1.4", pc_init_pci_1_4, }, -static void pc_i440fx_1_3_machine_options(QEMUMachine *m) +static void pc_i440fx_1_3_machine_options(MachineClass *m) { pc_i440fx_1_4_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_1_3); @@ -684,7 +684,7 @@ DEFINE_PC_MACHINE(v1_3, "pc-1.3", pc_init_pci_1_3, .value = "off",\ }, -static void pc_i440fx_1_2_machine_options(QEMUMachine *m) +static void pc_i440fx_1_2_machine_options(MachineClass *m) { pc_i440fx_1_3_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_1_2); @@ -726,7 +726,7 @@ DEFINE_PC_MACHINE(v1_2, "pc-1.2", pc_init_pci_1_2, .value = "off",\ }, -static void pc_i440fx_1_1_machine_options(QEMUMachine *m) +static void pc_i440fx_1_1_machine_options(MachineClass *m) { pc_i440fx_1_2_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_1_1); @@ -756,7 +756,7 @@ DEFINE_PC_MACHINE(v1_1, "pc-1.1", pc_init_pci_1_2, .value = "no",\ }, -static void pc_i440fx_1_0_machine_options(QEMUMachine *m) +static void pc_i440fx_1_0_machine_options(MachineClass *m) { pc_i440fx_1_1_machine_options(m); m->hw_version = "1.0"; @@ -770,7 +770,7 @@ DEFINE_PC_MACHINE(v1_0, "pc-1.0", pc_init_pci_1_2, #define PC_COMPAT_0_15 \ PC_COMPAT_1_0 -static void pc_i440fx_0_15_machine_options(QEMUMachine *m) +static void pc_i440fx_0_15_machine_options(MachineClass *m) { pc_i440fx_1_0_machine_options(m); m->hw_version = "0.15"; @@ -809,7 +809,7 @@ DEFINE_PC_MACHINE(v0_15, "pc-0.15", pc_init_pci_1_2, .value = stringify(2),\ }, -static void pc_i440fx_0_14_machine_options(QEMUMachine *m) +static void pc_i440fx_0_14_machine_options(MachineClass *m) { pc_i440fx_0_15_machine_options(m); m->hw_version = "0.14"; @@ -844,7 +844,7 @@ DEFINE_PC_MACHINE(v0_14, "pc-0.14", pc_init_pci_1_2, .value = stringify(0),\ }, -static void pc_i440fx_0_13_machine_options(QEMUMachine *m) +static void pc_i440fx_0_13_machine_options(MachineClass *m) { pc_i440fx_0_14_machine_options(m); m->hw_version = "0.13"; @@ -879,7 +879,7 @@ DEFINE_PC_MACHINE(v0_13, "pc-0.13", pc_init_pci_no_kvmclock, .value = "1",\ }, -static void pc_i440fx_0_12_machine_options(QEMUMachine *m) +static void pc_i440fx_0_12_machine_options(MachineClass *m) { pc_i440fx_0_13_machine_options(m); m->hw_version = "0.12"; @@ -910,7 +910,7 @@ DEFINE_PC_MACHINE(v0_12, "pc-0.12", pc_init_pci_no_kvmclock, .value = "0.11",\ }, -static void pc_i440fx_0_11_machine_options(QEMUMachine *m) +static void pc_i440fx_0_11_machine_options(MachineClass *m) { pc_i440fx_0_12_machine_options(m); m->hw_version = "0.11"; @@ -945,7 +945,7 @@ DEFINE_PC_MACHINE(v0_11, "pc-0.11", pc_init_pci_no_kvmclock, .value = "0.10",\ }, -static void pc_i440fx_0_10_machine_options(QEMUMachine *m) +static void pc_i440fx_0_10_machine_options(MachineClass *m) { pc_i440fx_0_11_machine_options(m); m->hw_version = "0.10"; @@ -956,7 +956,7 @@ DEFINE_PC_MACHINE(v0_10, "pc-0.10", pc_init_pci_no_kvmclock, pc_i440fx_0_10_machine_options); -static void isapc_machine_options(QEMUMachine *m) +static void isapc_machine_options(MachineClass *m) { pc_common_machine_options(m); m->desc = "ISA-only PC"; @@ -968,7 +968,7 @@ DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa, #ifdef CONFIG_XEN -static void xenfv_machine_options(QEMUMachine *m) +static void xenfv_machine_options(MachineClass *m) { pc_common_machine_options(m); m->desc = "Xen Fully-virtualized PC"; diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index dcd728c..6a9fe58 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -414,7 +414,7 @@ static void pc_q35_init_1_4(MachineState *machine) pc_q35_init(machine); } -static void pc_q35_machine_options(QEMUMachine *m) +static void pc_q35_machine_options(MachineClass *m) { pc_default_machine_options(m); m->family = "pc_q35"; @@ -423,7 +423,7 @@ static void pc_q35_machine_options(QEMUMachine *m) m->units_per_default_bus = 1; } -static void pc_q35_2_4_machine_options(QEMUMachine *m) +static void pc_q35_2_4_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->default_machine_opts = "firmware=bios-256k.bin"; @@ -435,7 +435,7 @@ DEFINE_PC_MACHINE(v2_4, "pc-q35-2.4", pc_q35_init, pc_q35_2_4_machine_options); -static void pc_q35_2_3_machine_options(QEMUMachine *m) +static void pc_q35_2_3_machine_options(MachineClass *m) { pc_q35_2_4_machine_options(m); m->alias = NULL; @@ -446,7 +446,7 @@ DEFINE_PC_MACHINE(v2_3, "pc-q35-2.3", pc_q35_init_2_3, pc_q35_2_3_machine_options); -static void pc_q35_2_2_machine_options(QEMUMachine *m) +static void pc_q35_2_2_machine_options(MachineClass *m) { pc_q35_2_3_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); @@ -456,7 +456,7 @@ DEFINE_PC_MACHINE(v2_2, "pc-q35-2.2", pc_q35_init_2_2, pc_q35_2_2_machine_options); -static void pc_q35_2_1_machine_options(QEMUMachine *m) +static void pc_q35_2_1_machine_options(MachineClass *m) { pc_q35_2_2_machine_options(m); m->default_display = NULL; @@ -467,7 +467,7 @@ DEFINE_PC_MACHINE(v2_1, "pc-q35-2.1", pc_q35_init_2_1, pc_q35_2_1_machine_options); -static void pc_q35_2_0_machine_options(QEMUMachine *m) +static void pc_q35_2_0_machine_options(MachineClass *m) { pc_q35_2_1_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); @@ -477,7 +477,7 @@ DEFINE_PC_MACHINE(v2_0, "pc-q35-2.0", pc_q35_init_2_0, pc_q35_2_0_machine_options); -static void pc_q35_1_7_machine_options(QEMUMachine *m) +static void pc_q35_1_7_machine_options(MachineClass *m) { pc_q35_2_0_machine_options(m); m->default_machine_opts = NULL; @@ -488,7 +488,7 @@ DEFINE_PC_MACHINE(v1_7, "pc-q35-1.7", pc_q35_init_1_7, pc_q35_1_7_machine_options); -static void pc_q35_1_6_machine_options(QEMUMachine *m) +static void pc_q35_1_6_machine_options(MachineClass *m) { pc_q35_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); @@ -498,7 +498,7 @@ DEFINE_PC_MACHINE(v1_6, "pc-q35-1.6", pc_q35_init_1_6, pc_q35_1_6_machine_options); -static void pc_q35_1_5_machine_options(QEMUMachine *m) +static void pc_q35_1_5_machine_options(MachineClass *m) { pc_q35_1_6_machine_options(m); SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); @@ -508,7 +508,7 @@ DEFINE_PC_MACHINE(v1_5, "pc-q35-1.5", pc_q35_init_1_5, pc_q35_1_5_machine_options); -static void pc_q35_1_4_machine_options(QEMUMachine *m) +static void pc_q35_1_4_machine_options(MachineClass *m) { pc_q35_1_5_machine_options(m); m->hot_add_cpu = NULL; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index c4f0808..f3bf500 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -517,12 +517,12 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = stringify(0),\ }, -static inline void pc_common_machine_options(QEMUMachine *m) +static inline void pc_common_machine_options(MachineClass *m) { m->default_boot_order = "cad"; } -static inline void pc_default_machine_options(QEMUMachine *m) +static inline void pc_default_machine_options(MachineClass *m) { pc_common_machine_options(m); m->hot_add_cpu = pc_hot_add_cpu; @@ -530,13 +530,21 @@ static inline void pc_default_machine_options(QEMUMachine *m) } #define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \ + static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \ + { \ + MachineClass *mc = MACHINE_CLASS(oc); \ + optsfn(mc); \ + mc->name = namestr; \ + mc->init = initfn; \ + } \ + static const TypeInfo pc_machine_type_##suffix = { \ + .name = namestr TYPE_MACHINE_SUFFIX, \ + .parent = TYPE_PC_MACHINE, \ + .class_init = pc_machine_##suffix##_class_init, \ + }; \ static void pc_machine_init_##suffix(void) \ { \ - static QEMUMachine m = { }; \ - optsfn(&m); \ - m.name = namestr; \ - m.init = initfn; \ - qemu_register_pc_machine(&m); \ + type_register(&pc_machine_type_##suffix); \ } \ machine_init(pc_machine_init_##suffix) -- cgit v1.1