Skip to content

Commit

Permalink
pc: Don't use QEMUMachine anymore
Browse files Browse the repository at this point in the history
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 <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
ehabkost authored and mstsirkin committed May 31, 2015
1 parent 25519b0 commit 865906f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 39 deletions.
44 changes: 22 additions & 22 deletions hw/i386/pc_piix.c
Expand Up @@ -518,15 +518,15 @@ 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";
m->desc = "Standard PC (i440FX + PIIX, 1996)";
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";
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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";
Expand Down
20 changes: 10 additions & 10 deletions hw/i386/pc_q35.c
Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down
22 changes: 15 additions & 7 deletions include/hw/i386/pc.h
Expand Up @@ -517,26 +517,34 @@ 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;
m->max_cpus = 255;
}

#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)

Expand Down

0 comments on commit 865906f

Please sign in to comment.