From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marcel Apfelbaum" <marcel.a@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Alexander Graf" <agraf@suse.de>,
"Don Slutz" <dslutz@verizon.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH v4 11/33] pc: Register machine classes directly instead of using QEMUMachine
Date: Thu, 14 Aug 2014 16:25:40 -0300 [thread overview]
Message-ID: <1408044362-11621-12-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1408044362-11621-1-git-send-email-ehabkost@redhat.com>
This is a (mostly) blind and mechanical conversion of the PC QEMUMachine
definitions to corresponding class registration code.
Existing duplication and unnecessary complexity on macro/function reuse
is being kept, to keep the conversion simple to review. The complexity
and duplication will be gradually removed by the next patches.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
---
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
Changes v2 -> v3:
* Make static TypeInfo structs const
Suggested-by: Andreas Färber <afaerber@suse.de>
---
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 301b127..e56716f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1532,50 +1532,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 1127c54..a2ff925 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -452,81 +452,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_init1,
- .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_init1;
+ mc->is_default = 1;
+ mc->name = "pc-i440fx-2.1";
+}
+
+static const 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 const 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 const 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 const 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 const 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 const 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 \
@@ -549,14 +608,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 const 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 \
@@ -587,17 +655,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 const 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 \
@@ -632,13 +711,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 const 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 \
@@ -661,27 +749,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 const 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 const 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 \
@@ -712,14 +818,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 const 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 \
@@ -746,18 +861,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 const 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 \
@@ -784,14 +910,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 const 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 \
@@ -814,20 +949,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 const 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",
@@ -851,31 +995,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 const 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 const 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.
*/
@@ -885,31 +1042,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 const 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 0abd56c..3b923b7 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -341,90 +341,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_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_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_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_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_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 9fb7144..46bbf48 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -8,6 +8,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"
@@ -505,12 +506,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.3
next prev parent reply other threads:[~2014-08-14 19:27 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-14 19:25 [Qemu-devel] [PATCH v4 00/33] Convert PC machine-types to QOM classes Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 01/33] pc: Replace tabs with spaces on pc.h Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 02/33] vl.c: Use qdev_prop_register_global() for single globals Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 03/33] pc: Eliminate has_pci_info global variable Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 04/33] piix: Add kvmclock_enabled, pci_enabled globals Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 05/33] piix: Eliminate pc_init_pci() Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 06/33] piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14 Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 07/33] piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13 Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 08/33] piix: Move pc-0.1[23] rombar compat props " Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 09/33] piix: Move pc-0.11 drive version compat props to PC_COMPAT_0_11 Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 10/33] machine: Make compat_props a linked list Eduardo Habkost
2014-08-14 19:25 ` Eduardo Habkost [this message]
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 12/33] pc: Eliminate pc_common_machine_options() Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 13/33] pc: Eliminate pc_default_machine_options() Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 14/33] piix: Eliminate pc_i440fx_machine_options() Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 15/33] q35: Eliminate pc_q35_machine_options() Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 16/33] q35: Eliminate pc_q35_1_4_machine_options() Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 17/33] pc: Eliminate all *_machine_options() functions Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 18/33] machine: Eliminate QEMUMachine.compat_props Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 19/33] pc: Rename pc_machine variable to pcms Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 20/33] pc: Pass PCMachineState argument to pc_cpus_init() Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 21/33] machine: Add MachineClass.default_cpu_model field Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 22/33] pc: Move globals to PCMachineClass Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 23/33] pc: Move option_rom_has_mr/rom_file_has_mr to MachineClass Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 24/33] pc: Add PCMachineClass.compat_apic_id_mode field Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 25/33] target-i386: Move error handling to end of x86_cpu_parse_featurestr() Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 26/33] target-i386: Renove underscores from feature names Eduardo Habkost
2014-08-14 19:31 ` Michael S. Tsirkin
2014-08-14 19:32 ` Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 27/33] target-i386: Register X86CPU "feat-kvmclock" feature Eduardo Habkost
2014-08-14 21:08 ` Michael S. Tsirkin
2014-08-14 23:59 ` Eduardo Habkost
2014-08-16 21:03 ` Michael S. Tsirkin
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 28/33] target-i386: set [+-]feature using QOM properties Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 29/33] pc: Use compat_props for CPUID compat bits Eduardo Habkost
2014-08-14 19:25 ` [Qemu-devel] [PATCH v4 30/33] target-i386: Move some declarations to hw/i386/cpu.h Eduardo Habkost
2014-08-14 19:26 ` [Qemu-devel] [PATCH v4 31/33] pc: Add default KVM features fields to PCMachineClass Eduardo Habkost
2014-08-14 21:09 ` Michael S. Tsirkin
2014-08-15 0:04 ` Eduardo Habkost
2014-08-14 19:26 ` [Qemu-devel] [PATCH v4 32/33] pc: Eliminate pc_compat_*() functions Eduardo Habkost
2014-08-14 19:26 ` [Qemu-devel] [PATCH v4 33/33] piix: Move pc_xen_hvm_init() closer to xenfv_machine_class_init() Eduardo Habkost
2014-08-14 20:03 ` Michael S. Tsirkin
2014-08-15 0:03 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1408044362-11621-12-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=dslutz@verizon.com \
--cc=imammedo@redhat.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).