[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 08/39] pc: Register machine classes directly instea
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RFC v2 08/39] pc: Register machine classes directly instead of using QEMUMachine |
Date: |
Fri, 13 Jun 2014 16:43:47 -0300 |
This is a (mostly) blind and mechanical conversion of the PC QEMUMachine
definitions to corresponding class registration code.
Having the PC code converted to pure QOM registration code will help us
move PC-specific machine state that is currently held in static
variables inside PC machine objects, and reduce duplication between
pc_piix.c and pc_q35.c.
Signed-off-by: Eduardo Habkost <address@hidden>
Cc: Igor Mammedov <address@hidden>
---
Changes v1 -> v2:
* Remove unused PC_DEFAULT_MACHINE_OPTIONS macro leftover
* Use machine_class_register_global_props_array()
* Rebase on top of Michael's pci tree
* Eliminate qemu_register_pc_machine(), as it is not needed anymore
---
hw/i386/pc.c | 44 -----
hw/i386/pc_piix.c | 473 +++++++++++++++++++++++++++++++++++----------------
hw/i386/pc_q35.c | 171 +++++++++++++------
include/hw/i386/pc.h | 17 +-
4 files changed, 448 insertions(+), 257 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 62f3c39..2618bf0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1508,50 +1508,6 @@ void ioapic_init_gsi(GSIState *gsi_state, const char
*parent_name)
}
}
-static void pc_generic_machine_class_init(ObjectClass *oc, void *data)
-{
- MachineClass *mc = MACHINE_CLASS(oc);
- QEMUMachine *qm = data;
-
- mc->name = qm->name;
- mc->alias = qm->alias;
- mc->desc = qm->desc;
- mc->init = qm->init;
- mc->reset = qm->reset;
- mc->hot_add_cpu = qm->hot_add_cpu;
- mc->kvm_type = qm->kvm_type;
- mc->block_default_type = qm->block_default_type;
- mc->max_cpus = qm->max_cpus;
- mc->no_serial = qm->no_serial;
- mc->no_parallel = qm->no_parallel;
- mc->use_virtcon = qm->use_virtcon;
- mc->use_sclp = qm->use_sclp;
- mc->no_floppy = qm->no_floppy;
- mc->no_cdrom = qm->no_cdrom;
- mc->no_sdcard = qm->no_sdcard;
- mc->is_default = qm->is_default;
- mc->default_machine_opts = qm->default_machine_opts;
- mc->default_boot_order = qm->default_boot_order;
- mc->hw_version = qm->hw_version;
- if (qm->compat_props) {
- machine_class_add_compat_props(mc, qm->compat_props);
- }
-}
-
-void qemu_register_pc_machine(QEMUMachine *m)
-{
- char *name = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL);
- TypeInfo ti = {
- .name = name,
- .parent = TYPE_PC_MACHINE,
- .class_init = pc_generic_machine_class_init,
- .class_data = (void *)m,
- };
-
- type_register(&ti);
- g_free(name);
-}
-
static void pc_dimm_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index dd52183..bb7a788 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -405,81 +405,140 @@ static void pc_xen_hvm_init(MachineState *machine)
}
#endif
-#define PC_I440FX_MACHINE_OPTIONS \
- PC_DEFAULT_MACHINE_OPTIONS, \
- .desc = "Standard PC (i440FX + PIIX, 1996)", \
- .hot_add_cpu = pc_hot_add_cpu
-
-#define PC_I440FX_2_1_MACHINE_OPTIONS \
- PC_I440FX_MACHINE_OPTIONS, \
- .default_machine_opts = "firmware=bios-256k.bin"
-
-static QEMUMachine pc_i440fx_machine_v2_1 = {
- PC_I440FX_2_1_MACHINE_OPTIONS,
- .name = "pc-i440fx-2.1",
- .alias = "pc",
- .init = pc_init_pci,
- .is_default = 1,
+static void pc_i440fx_machine_options(MachineClass *mc)
+{
+ pc_default_machine_options(mc);
+ mc->desc = "Standard PC (i440FX + PIIX, 1996)";
+ mc->hot_add_cpu = pc_hot_add_cpu;
+}
+
+static void pc_i440fx_2_1_machine_options(MachineClass *mc)
+{
+ pc_i440fx_machine_options(mc);
+ mc->default_machine_opts = "firmware=bios-256k.bin";
+}
+
+static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ pc_i440fx_2_1_machine_options(mc);
+ mc->alias = "pc";
+ mc->init = pc_init_pci;
+ mc->is_default = 1;
+ mc->name = "pc-i440fx-2.1";
+}
+
+static TypeInfo pc_i440fx_machine_v2_1_type_info = {
+ .name = "pc-i440fx-2.1" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v2_1_class_init,
};
-#define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
+#define pc_i440fx_2_0_machine_options pc_i440fx_2_1_machine_options
-static QEMUMachine pc_i440fx_machine_v2_0 = {
- PC_I440FX_2_0_MACHINE_OPTIONS,
- .name = "pc-i440fx-2.0",
- .init = pc_init_pci_2_0,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_2_0,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_2_0_machine_options(mc);
+ mc->init = pc_init_pci_2_0;
+ mc->name = "pc-i440fx-2.0";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_i440fx_machine_v2_0_type_info = {
+ .name = "pc-i440fx-2.0" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v2_0_class_init,
};
-#define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
+#define pc_i440fx_1_7_machine_options pc_i440fx_machine_options
-static QEMUMachine pc_i440fx_machine_v1_7 = {
- PC_I440FX_1_7_MACHINE_OPTIONS,
- .name = "pc-i440fx-1.7",
- .init = pc_init_pci_1_7,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_7,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_7_machine_options(mc);
+ mc->init = pc_init_pci_1_7;
+ mc->name = "pc-i440fx-1.7";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_i440fx_machine_v1_7_type_info = {
+ .name = "pc-i440fx-1.7" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v1_7_class_init,
};
-#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
+#define pc_i440fx_1_6_machine_options pc_i440fx_machine_options
-static QEMUMachine pc_i440fx_machine_v1_6 = {
- PC_I440FX_1_6_MACHINE_OPTIONS,
- .name = "pc-i440fx-1.6",
- .init = pc_init_pci_1_6,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_6,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_6_machine_options(mc);
+ mc->init = pc_init_pci_1_6;
+ mc->name = "pc-i440fx-1.6";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_i440fx_machine_v1_6_type_info = {
+ .name = "pc-i440fx-1.6" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v1_6_class_init,
};
-static QEMUMachine pc_i440fx_machine_v1_5 = {
- PC_I440FX_1_6_MACHINE_OPTIONS,
- .name = "pc-i440fx-1.5",
- .init = pc_init_pci_1_5,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_5,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_6_machine_options(mc);
+ mc->init = pc_init_pci_1_5;
+ mc->name = "pc-i440fx-1.5";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_i440fx_machine_v1_5_type_info = {
+ .name = "pc-i440fx-1.5" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v1_5_class_init,
};
-#define PC_I440FX_1_4_MACHINE_OPTIONS \
- PC_I440FX_1_6_MACHINE_OPTIONS, \
- .hot_add_cpu = NULL
+static void pc_i440fx_1_4_machine_options(MachineClass *mc)
+{
+ pc_i440fx_1_6_machine_options(mc);
+ mc->hot_add_cpu = NULL;
+}
-static QEMUMachine pc_i440fx_machine_v1_4 = {
- PC_I440FX_1_4_MACHINE_OPTIONS,
- .name = "pc-i440fx-1.4",
- .init = pc_init_pci_1_4,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_4,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_4_machine_options(mc);
+ mc->init = pc_init_pci_1_4;
+ mc->name = "pc-i440fx-1.4";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_i440fx_machine_v1_4_type_info = {
+ .name = "pc-i440fx-1.4" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v1_4_class_init,
};
#define PC_COMPAT_1_3 \
@@ -502,14 +561,23 @@ static QEMUMachine pc_i440fx_machine_v1_4 = {
.value = "off",\
}
-static QEMUMachine pc_machine_v1_3 = {
- PC_I440FX_1_4_MACHINE_OPTIONS,
- .name = "pc-1.3",
- .init = pc_init_pci_1_3,
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_3,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_4_machine_options(mc);
+ mc->init = pc_init_pci_1_3;
+ mc->name = "pc-1.3";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v1_3_type_info = {
+ .name = "pc-1.3" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v1_3_class_init,
};
#define PC_COMPAT_1_2 \
@@ -540,17 +608,28 @@ static QEMUMachine pc_machine_v1_3 = {
.value = "off",\
}
-#define PC_I440FX_1_2_MACHINE_OPTIONS \
- PC_I440FX_1_4_MACHINE_OPTIONS, \
- .init = pc_init_pci_1_2
+static void pc_i440fx_1_2_machine_options(MachineClass *mc)
+{
+ pc_i440fx_1_4_machine_options(mc);
+ mc->init = pc_init_pci_1_2;
+}
-static QEMUMachine pc_machine_v1_2 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-1.2",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_2,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->name = "pc-1.2";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v1_2_type_info = {
+ .name = "pc-1.2" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v1_2_class_init,
};
#define PC_COMPAT_1_1 \
@@ -585,13 +664,22 @@ static QEMUMachine pc_machine_v1_2 = {
.value = "off",\
}
-static QEMUMachine pc_machine_v1_1 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-1.1",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v1_1_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_1,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->name = "pc-1.1";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v1_1_type_info = {
+ .name = "pc-1.1" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v1_1_class_init,
};
#define PC_COMPAT_1_0 \
@@ -614,27 +702,45 @@ static QEMUMachine pc_machine_v1_1 = {
.value = "no",\
}
-static QEMUMachine pc_machine_v1_0 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-1.0",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v1_0_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_0,
{ /* end of list */ }
- },
- .hw_version = "1.0",
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->hw_version = "1.0";
+ mc->name = "pc-1.0";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v1_0_type_info = {
+ .name = "pc-1.0" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v1_0_class_init,
};
#define PC_COMPAT_0_15 \
PC_COMPAT_1_0
-static QEMUMachine pc_machine_v0_15 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-0.15",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_15_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_15,
{ /* end of list */ }
- },
- .hw_version = "0.15",
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->hw_version = "0.15";
+ mc->name = "pc-0.15";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v0_15_type_info = {
+ .name = "pc-0.15" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_15_class_init,
};
#define PC_COMPAT_0_14 \
@@ -665,14 +771,23 @@ static QEMUMachine pc_machine_v0_15 = {
.value = stringify(2),\
}
-static QEMUMachine pc_machine_v0_14 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-0.14",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_14_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_14,
{ /* end of list */ }
- },
- .hw_version = "0.14",
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->hw_version = "0.14";
+ mc->name = "pc-0.14";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v0_14_type_info = {
+ .name = "pc-0.14" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_14_class_init,
};
#define PC_COMPAT_0_13 \
@@ -699,18 +814,29 @@ static QEMUMachine pc_machine_v0_14 = {
.value = stringify(0),\
}
-#define PC_I440FX_0_13_MACHINE_OPTIONS \
- PC_I440FX_1_2_MACHINE_OPTIONS, \
- .init = pc_init_pci_no_kvmclock
+static void pc_i440fx_0_13_machine_options(MachineClass *mc)
+{
+ pc_i440fx_1_2_machine_options(mc);
+ mc->init = pc_init_pci_no_kvmclock;
+}
-static QEMUMachine pc_machine_v0_13 = {
- PC_I440FX_0_13_MACHINE_OPTIONS,
- .name = "pc-0.13",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_13,
{ /* end of list */ }
- },
- .hw_version = "0.13",
+ };
+ pc_i440fx_0_13_machine_options(mc);
+ mc->hw_version = "0.13";
+ mc->name = "pc-0.13";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v0_13_type_info = {
+ .name = "pc-0.13" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_13_class_init,
};
#define PC_COMPAT_0_12 \
@@ -737,14 +863,23 @@ static QEMUMachine pc_machine_v0_13 = {
.value = "1",\
}
-static QEMUMachine pc_machine_v0_12 = {
- PC_I440FX_0_13_MACHINE_OPTIONS,
- .name = "pc-0.12",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_12,
{ /* end of list */ }
- },
- .hw_version = "0.12",
+ };
+ pc_i440fx_0_13_machine_options(mc);
+ mc->hw_version = "0.12";
+ mc->name = "pc-0.12";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v0_12_type_info = {
+ .name = "pc-0.12" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_12_class_init,
};
#define PC_COMPAT_0_11 \
@@ -767,20 +902,29 @@ static QEMUMachine pc_machine_v0_12 = {
.value = "0.11",\
}
-static QEMUMachine pc_machine_v0_11 = {
- PC_I440FX_0_13_MACHINE_OPTIONS,
- .name = "pc-0.11",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_11,
{ /* end of list */ }
- },
- .hw_version = "0.11",
+ };
+ pc_i440fx_0_13_machine_options(mc);
+ mc->hw_version = "0.11";
+ mc->name = "pc-0.11";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v0_11_type_info = {
+ .name = "pc-0.11" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_11_class_init,
};
-static QEMUMachine pc_machine_v0_10 = {
- PC_I440FX_0_13_MACHINE_OPTIONS,
- .name = "pc-0.10",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_11,
{
.driver = "virtio-blk-pci",
@@ -804,31 +948,44 @@ static QEMUMachine pc_machine_v0_10 = {
.value = "0.10",
},
{ /* end of list */ }
- },
- .hw_version = "0.10",
+ };
+ pc_i440fx_0_13_machine_options(mc);
+ mc->hw_version = "0.10";
+ mc->name = "pc-0.10";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo pc_machine_v0_10_type_info = {
+ .name = "pc-0.10" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_10_class_init,
};
-static QEMUMachine isapc_machine = {
- PC_COMMON_MACHINE_OPTIONS,
- .name = "isapc",
- .desc = "ISA-only PC",
- .init = pc_init_isa,
- .max_cpus = 1,
- .compat_props = (GlobalProperty[]) {
+static void isapc_machine_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
{ /* end of list */ }
- },
+ };
+ pc_common_machine_options(mc);
+ mc->desc = "ISA-only PC";
+ mc->init = pc_init_isa;
+ mc->max_cpus = 1;
+ mc->name = "isapc";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo isapc_machine_type_info = {
+ .name = "isapc" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = isapc_machine_class_init,
};
#ifdef CONFIG_XEN
-static QEMUMachine xenfv_machine = {
- PC_COMMON_MACHINE_OPTIONS,
- .name = "xenfv",
- .desc = "Xen Fully-virtualized PC",
- .init = pc_xen_hvm_init,
- .max_cpus = HVM_MAX_VCPUS,
- .default_machine_opts = "accel=xen",
- .hot_add_cpu = pc_hot_add_cpu,
- .compat_props = (GlobalProperty[]) {
+static void xenfv_machine_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
/* xenfv has no fwcfg and so does not load acpi from QEMU.
* as such new acpi features don't work.
*/
@@ -838,31 +995,45 @@ static QEMUMachine xenfv_machine = {
.value = "off",
},
{ /* end of list */ }
- },
+ };
+ pc_common_machine_options(mc);
+ mc->desc = "Xen Fully-virtualized PC";
+ mc->init = pc_xen_hvm_init;
+ mc->max_cpus = HVM_MAX_VCPUS;
+ mc->default_machine_opts = "accel=xen";
+ mc->hot_add_cpu = pc_hot_add_cpu;
+ mc->name = "xenfv";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static TypeInfo xenfv_machine_type_info = {
+ .name = "xenfv" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = xenfv_machine_class_init,
};
#endif
static void pc_machine_init(void)
{
- qemu_register_pc_machine(&pc_i440fx_machine_v2_1);
- qemu_register_pc_machine(&pc_i440fx_machine_v2_0);
- qemu_register_pc_machine(&pc_i440fx_machine_v1_7);
- qemu_register_pc_machine(&pc_i440fx_machine_v1_6);
- qemu_register_pc_machine(&pc_i440fx_machine_v1_5);
- qemu_register_pc_machine(&pc_i440fx_machine_v1_4);
- qemu_register_pc_machine(&pc_machine_v1_3);
- qemu_register_pc_machine(&pc_machine_v1_2);
- qemu_register_pc_machine(&pc_machine_v1_1);
- qemu_register_pc_machine(&pc_machine_v1_0);
- qemu_register_pc_machine(&pc_machine_v0_15);
- qemu_register_pc_machine(&pc_machine_v0_14);
- qemu_register_pc_machine(&pc_machine_v0_13);
- qemu_register_pc_machine(&pc_machine_v0_12);
- qemu_register_pc_machine(&pc_machine_v0_11);
- qemu_register_pc_machine(&pc_machine_v0_10);
- qemu_register_pc_machine(&isapc_machine);
+ type_register_static(&pc_i440fx_machine_v2_1_type_info);
+ type_register_static(&pc_i440fx_machine_v2_0_type_info);
+ type_register_static(&pc_i440fx_machine_v1_7_type_info);
+ type_register_static(&pc_i440fx_machine_v1_6_type_info);
+ type_register_static(&pc_i440fx_machine_v1_5_type_info);
+ type_register_static(&pc_i440fx_machine_v1_4_type_info);
+ type_register_static(&pc_machine_v1_3_type_info);
+ type_register_static(&pc_machine_v1_2_type_info);
+ type_register_static(&pc_machine_v1_1_type_info);
+ type_register_static(&pc_machine_v1_0_type_info);
+ type_register_static(&pc_machine_v0_15_type_info);
+ type_register_static(&pc_machine_v0_14_type_info);
+ type_register_static(&pc_machine_v0_13_type_info);
+ type_register_static(&pc_machine_v0_12_type_info);
+ type_register_static(&pc_machine_v0_11_type_info);
+ type_register_static(&pc_machine_v0_10_type_info);
+ type_register_static(&isapc_machine_type_info);
#ifdef CONFIG_XEN
- qemu_register_pc_machine(&xenfv_machine);
+ type_register_static(&xenfv_machine_type_info);
#endif
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 52920d3..cfeda8d 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -319,90 +319,149 @@ static void pc_q35_init_1_4(MachineState *machine)
pc_q35_init(machine);
}
-#define PC_Q35_MACHINE_OPTIONS \
- PC_DEFAULT_MACHINE_OPTIONS, \
- .desc = "Standard PC (Q35 + ICH9, 2009)", \
- .hot_add_cpu = pc_hot_add_cpu
-
-#define PC_Q35_2_1_MACHINE_OPTIONS \
- PC_Q35_MACHINE_OPTIONS, \
- .default_machine_opts = "firmware=bios-256k.bin"
-
-static QEMUMachine pc_q35_machine_v2_1 = {
- PC_Q35_2_1_MACHINE_OPTIONS,
- .name = "pc-q35-2.1",
- .alias = "q35",
- .init = pc_q35_init,
+static void pc_q35_machine_options(MachineClass *mc)
+{
+ pc_default_machine_options(mc);
+ mc->desc = "Standard PC (Q35 + ICH9, 2009)";
+ mc->hot_add_cpu = pc_hot_add_cpu;
+}
+
+static void pc_q35_2_1_machine_options(MachineClass *mc)
+{
+ pc_q35_machine_options(mc);
+ mc->default_machine_opts = "firmware=bios-256k.bin";
+}
+
+static void pc_q35_machine_v2_1_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ pc_q35_2_1_machine_options(mc);
+ mc->alias = "q35";
+ mc->init = pc_q35_init;
+ mc->name = "pc-q35-2.1";
+}
+
+static TypeInfo pc_q35_machine_v2_1_type_info = {
+ .name = "pc-q35-2.1" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v2_1_class_init,
};
-#define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
+#define pc_q35_2_0_machine_options pc_q35_2_1_machine_options
-static QEMUMachine pc_q35_machine_v2_0 = {
- PC_Q35_2_0_MACHINE_OPTIONS,
- .name = "pc-q35-2.0",
- .init = pc_q35_init_2_0,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_Q35_COMPAT_2_0,
{ /* end of list */ }
- },
+ };
+ pc_q35_2_0_machine_options(mc);
+ mc->init = pc_q35_init_2_0;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-2.0";
+}
+
+static TypeInfo pc_q35_machine_v2_0_type_info = {
+ .name = "pc-q35-2.0" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v2_0_class_init,
};
-#define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
+#define pc_q35_1_7_machine_options pc_q35_machine_options
-static QEMUMachine pc_q35_machine_v1_7 = {
- PC_Q35_1_7_MACHINE_OPTIONS,
- .name = "pc-q35-1.7",
- .init = pc_q35_init_1_7,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_Q35_COMPAT_1_7,
{ /* end of list */ }
- },
+ };
+ pc_q35_1_7_machine_options(mc);
+ mc->init = pc_q35_init_1_7;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-1.7";
+}
+
+static TypeInfo pc_q35_machine_v1_7_type_info = {
+ .name = "pc-q35-1.7" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v1_7_class_init,
};
-#define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
+#define pc_q35_1_6_machine_options pc_q35_machine_options
-static QEMUMachine pc_q35_machine_v1_6 = {
- PC_Q35_1_6_MACHINE_OPTIONS,
- .name = "pc-q35-1.6",
- .init = pc_q35_init_1_6,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_Q35_COMPAT_1_6,
{ /* end of list */ }
- },
+ };
+ pc_q35_1_6_machine_options(mc);
+ mc->init = pc_q35_init_1_6;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-1.6";
+}
+
+static TypeInfo pc_q35_machine_v1_6_type_info = {
+ .name = "pc-q35-1.6" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v1_6_class_init,
};
-static QEMUMachine pc_q35_machine_v1_5 = {
- PC_Q35_1_6_MACHINE_OPTIONS,
- .name = "pc-q35-1.5",
- .init = pc_q35_init_1_5,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_Q35_COMPAT_1_5,
{ /* end of list */ }
- },
+ };
+ pc_q35_1_6_machine_options(mc);
+ mc->init = pc_q35_init_1_5;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-1.5";
+}
+
+static TypeInfo pc_q35_machine_v1_5_type_info = {
+ .name = "pc-q35-1.5" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v1_5_class_init,
};
-#define PC_Q35_1_4_MACHINE_OPTIONS \
- PC_Q35_1_6_MACHINE_OPTIONS, \
- .hot_add_cpu = NULL
+static void pc_q35_1_4_machine_options(MachineClass *mc)
+{
+ pc_q35_1_6_machine_options(mc);
+ mc->hot_add_cpu = NULL;
+}
-static QEMUMachine pc_q35_machine_v1_4 = {
- PC_Q35_1_4_MACHINE_OPTIONS,
- .name = "pc-q35-1.4",
- .init = pc_q35_init_1_4,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_Q35_COMPAT_1_4,
{ /* end of list */ }
- },
+ };
+ pc_q35_1_4_machine_options(mc);
+ mc->init = pc_q35_init_1_4;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-1.4";
+}
+
+static TypeInfo pc_q35_machine_v1_4_type_info = {
+ .name = "pc-q35-1.4" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v1_4_class_init,
};
static void pc_q35_machine_init(void)
{
- qemu_register_pc_machine(&pc_q35_machine_v2_1);
- qemu_register_pc_machine(&pc_q35_machine_v2_0);
- qemu_register_pc_machine(&pc_q35_machine_v1_7);
- qemu_register_pc_machine(&pc_q35_machine_v1_6);
- qemu_register_pc_machine(&pc_q35_machine_v1_5);
- qemu_register_pc_machine(&pc_q35_machine_v1_4);
+ type_register_static(&pc_q35_machine_v2_1_type_info);
+ type_register_static(&pc_q35_machine_v2_0_type_info);
+ type_register_static(&pc_q35_machine_v1_7_type_info);
+ type_register_static(&pc_q35_machine_v1_6_type_info);
+ type_register_static(&pc_q35_machine_v1_5_type_info);
+ type_register_static(&pc_q35_machine_v1_4_type_info);
}
machine_init(pc_q35_machine_init);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index fe9e18b..d190fef 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -7,6 +7,7 @@
#include "hw/block/fdc.h"
#include "net/net.h"
#include "hw/i386/ioapic.h"
+#include "hw/boards.h"
#include "qemu/range.h"
#include "qemu/bitmap.h"
@@ -499,12 +500,16 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t
*);
.value = stringify(0),\
}
-#define PC_COMMON_MACHINE_OPTIONS \
- .default_boot_order = "cad"
+static inline void pc_common_machine_options(MachineClass *mc)
+{
+ mc->default_boot_order = "cad";
+}
-#define PC_DEFAULT_MACHINE_OPTIONS \
- PC_COMMON_MACHINE_OPTIONS, \
- .hot_add_cpu = pc_hot_add_cpu, \
- .max_cpus = 255
+static inline void pc_default_machine_options(MachineClass *mc)
+{
+ pc_common_machine_options(mc);
+ mc->hot_add_cpu = pc_hot_add_cpu;
+ mc->max_cpus = 255;
+}
#endif
--
1.9.0
- [Qemu-devel] [RFC v2 00/39] Convert PC machine-types to QOM classes, Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 01/39] q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props, Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 03/39] piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13, Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 02/39] piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14, Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 05/39] piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11, Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 06/39] vl.c: Use qdev_prop_register_global() for single globals, Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 07/39] machine: Make compat_props a linked list, Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 08/39] pc: Register machine classes directly instead of using QEMUMachine,
Eduardo Habkost <=
- [Qemu-devel] [RFC v2 10/39] pc: Eliminate pc_default_machine_options(), Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 09/39] pc: Eliminate pc_common_machine_options(), Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 11/39] piix: Eliminate pc_i440fx_machine_options(), Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 13/39] q35: Eliminate pc_q35_1_4_machine_options(), Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 12/39] q35: Eliminate pc_q35_machine_options(), Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 14/39] pc: Eliminate *machine_options macros, Eduardo Habkost, 2014/06/13
- [Qemu-devel] [RFC v2 15/39] piix: Make all *machine_options() functions call the previous one, Eduardo Habkost, 2014/06/13