[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v3 17/35] pc: Eliminate all *_machine_options() functi
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RFC v3 17/35] pc: Eliminate all *_machine_options() functions |
Date: |
Fri, 4 Jul 2014 21:09:44 -0300 |
Finally eliminate all *_machine_options() functions, and make the
class_init functions for older machine-types simply reuse the class_init
functions from newer machine-types.
To allow compat_props reuse, the the PC_COMPAT_* macros were changed to
not nest within the older PC_COMPAT_* macros anymore.
We can now make all pc-{i440fx,q36}-* class_init functions call the previous
one.
For reference (to help ensure the reuse of previous class_init functions
won't change any behavior), these are the fields that are touched by the
class_init functions:
* name: All machine-types set it, class_init reuse won't affect it.
* hw_version: All machines older than pc*-1.0 already set it, class_init reuse
won't affect it.
* desc: Only the base pc-{i440fx,q35} classes set it, so all classes already
reused it.
* hot_add_cpu:
* The base pc-{i440fx,q35} classes set it (so it was already reused by all
subclasses).
* pc-i440fx-1.4 was already overriding it inside
pc_i440fx_1_4_machine_options() (and all older machine-types already
reused it).
* On pc_q35.c, only pc-q-35-1.4 (which is the oldest pc-q35 subclass) set it.
* alias: Only pc*-2.1 was setting them, pc*-2.0 was now changed to unset both,
so only pc*-2.1 still have them set.
* is_default: Only pc-i440fx-2.1 was setting them, pc-i440fx-2.0 was now
changed to unset both, so only pc-i440fx-2.1 still have them set.
* init: pc*-1.3 to pc*-2.1 were already setting it. The only ones that didn't
set it were using the one set by previous *machine_options() functions.
* compat_props: All machine-types used PC_COMPAT_* macros that reused the
previous one. Now they will simply append to the compat_props list added by
the previous class_init function, and PC_COMPAT_* won't include the previous
macros inside them.
* default_machine_opts: It was set by pc_*_2_1_machine_options() and is
now set by pc-*-2.1 class_init(). pc*-1.7 and older didn't reuse
pc_*_2_1_machine_options(), so now pc*-1.7 class_init() set
default_machine_opts to NULL to ensure pc-*1.7 and older don't inherit
it.
Signed-off-by: Eduardo Habkost <address@hidden>
---
hw/i386/pc_piix.c | 76 +++++++++++++++-------------------------------------
hw/i386/pc_q35.c | 17 ++++++------
include/hw/i386/pc.h | 4 ---
3 files changed, 30 insertions(+), 67 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 7081243..979bb40 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -448,16 +448,10 @@ static TypeInfo pc_i440fx_machine_type_info = {
.abstract = true,
};
-
-static void pc_i440fx_2_1_machine_options(MachineClass *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->default_machine_opts = "firmware=bios-256k.bin";
mc->alias = "pc";
mc->init = pc_init_pci;
mc->is_default = 1;
@@ -470,8 +464,6 @@ static const TypeInfo pc_i440fx_machine_v2_1_type_info = {
.class_init = pc_i440fx_machine_v2_1_class_init,
};
-#define pc_i440fx_2_0_machine_options pc_i440fx_2_1_machine_options
-
static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -479,7 +471,9 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass
*oc, void *data)
PC_COMPAT_2_0,
{ /* end of list */ }
};
- pc_i440fx_2_0_machine_options(mc);
+ pc_i440fx_machine_v2_1_class_init(oc, data);
+ mc->alias = NULL;
+ mc->is_default = false;
mc->init = pc_init_pci_2_0;
mc->name = "pc-i440fx-2.0";
machine_class_add_compat_props(mc, compat_props);
@@ -498,6 +492,8 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass
*oc, void *data)
PC_COMPAT_1_7,
{ /* end of list */ }
};
+ pc_i440fx_machine_v2_0_class_init(oc, data);
+ mc->default_machine_opts = NULL;
mc->init = pc_init_pci_1_7;
mc->name = "pc-i440fx-1.7";
machine_class_add_compat_props(mc, compat_props);
@@ -516,6 +512,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass
*oc, void *data)
PC_COMPAT_1_6,
{ /* end of list */ }
};
+ pc_i440fx_machine_v1_7_class_init(oc, data);
mc->init = pc_init_pci_1_6;
mc->name = "pc-i440fx-1.6";
machine_class_add_compat_props(mc, compat_props);
@@ -534,6 +531,7 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass
*oc, void *data)
PC_COMPAT_1_5,
{ /* end of list */ }
};
+ pc_i440fx_machine_v1_6_class_init(oc, data);
mc->init = pc_init_pci_1_5;
mc->name = "pc-i440fx-1.5";
machine_class_add_compat_props(mc, compat_props);
@@ -545,11 +543,6 @@ static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
.class_init = pc_i440fx_machine_v1_5_class_init,
};
-static void pc_i440fx_1_4_machine_options(MachineClass *mc)
-{
- mc->hot_add_cpu = NULL;
-}
-
static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -557,7 +550,8 @@ static void pc_i440fx_machine_v1_4_class_init(ObjectClass
*oc, void *data)
PC_COMPAT_1_4,
{ /* end of list */ }
};
- pc_i440fx_1_4_machine_options(mc);
+ pc_i440fx_machine_v1_5_class_init(oc, data);
+ mc->hot_add_cpu = NULL;
mc->init = pc_init_pci_1_4;
mc->name = "pc-i440fx-1.4";
machine_class_add_compat_props(mc, compat_props);
@@ -570,7 +564,6 @@ static const TypeInfo pc_i440fx_machine_v1_4_type_info = {
};
#define PC_COMPAT_1_3 \
- PC_COMPAT_1_4, \
{\
.driver = "usb-tablet",\
.property = "usb_version",\
@@ -596,7 +589,7 @@ static void pc_machine_v1_3_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_1_3,
{ /* end of list */ }
};
- pc_i440fx_1_4_machine_options(mc);
+ pc_i440fx_machine_v1_4_class_init(oc, data);
mc->init = pc_init_pci_1_3;
mc->name = "pc-1.3";
machine_class_add_compat_props(mc, compat_props);
@@ -609,7 +602,6 @@ static const TypeInfo pc_machine_v1_3_type_info = {
};
#define PC_COMPAT_1_2 \
- PC_COMPAT_1_3,\
{\
.driver = "nec-usb-xhci",\
.property = "msi",\
@@ -636,12 +628,6 @@ static const TypeInfo pc_machine_v1_3_type_info = {
.value = "off",\
}
-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 void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -649,7 +635,8 @@ static void pc_machine_v1_2_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_1_2,
{ /* end of list */ }
};
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v1_3_class_init(oc, data);
+ mc->init = pc_init_pci_1_2;
mc->name = "pc-1.2";
machine_class_add_compat_props(mc, compat_props);
}
@@ -661,7 +648,6 @@ static const TypeInfo pc_machine_v1_2_type_info = {
};
#define PC_COMPAT_1_1 \
- PC_COMPAT_1_2,\
{\
.driver = "virtio-scsi-pci",\
.property = "hotplug",\
@@ -699,7 +685,7 @@ static void pc_machine_v1_1_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_1_1,
{ /* end of list */ }
};
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v1_2_class_init(oc, data);
mc->name = "pc-1.1";
machine_class_add_compat_props(mc, compat_props);
}
@@ -737,7 +723,7 @@ static void pc_machine_v1_0_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_1_0,
{ /* end of list */ }
};
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v1_1_class_init(oc, data);
mc->hw_version = "1.0";
mc->name = "pc-1.0";
machine_class_add_compat_props(mc, compat_props);
@@ -749,20 +735,12 @@ static const TypeInfo pc_machine_v1_0_type_info = {
.class_init = pc_machine_v1_0_class_init,
};
-#define PC_COMPAT_0_15 \
- PC_COMPAT_1_0
-
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 */ }
- };
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v1_0_class_init(oc, data);
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 = {
@@ -772,7 +750,6 @@ static const TypeInfo pc_machine_v0_15_type_info = {
};
#define PC_COMPAT_0_14 \
- PC_COMPAT_0_15,\
{\
.driver = "virtio-blk-pci",\
.property = "event_idx",\
@@ -806,7 +783,7 @@ static void pc_machine_v0_14_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_0_14,
{ /* end of list */ }
};
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v0_15_class_init(oc, data);
mc->hw_version = "0.14";
mc->name = "pc-0.14";
machine_class_add_compat_props(mc, compat_props);
@@ -819,7 +796,6 @@ static const TypeInfo pc_machine_v0_14_type_info = {
};
#define PC_COMPAT_0_13 \
- PC_COMPAT_0_14,\
{\
.driver = TYPE_PCI_DEVICE,\
.property = "command_serr_enable",\
@@ -842,12 +818,6 @@ static const TypeInfo pc_machine_v0_14_type_info = {
.value = stringify(0),\
}
-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 void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -855,7 +825,8 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_0_13,
{ /* end of list */ }
};
- pc_i440fx_0_13_machine_options(mc);
+ pc_machine_v0_14_class_init(oc, data);
+ mc->init = pc_init_pci_no_kvmclock;
mc->hw_version = "0.13";
mc->name = "pc-0.13";
machine_class_add_compat_props(mc, compat_props);
@@ -868,7 +839,6 @@ static const TypeInfo pc_machine_v0_13_type_info = {
};
#define PC_COMPAT_0_12 \
- PC_COMPAT_0_13,\
{\
.driver = "virtio-serial-pci",\
.property = "max_ports",\
@@ -898,7 +868,7 @@ static void pc_machine_v0_12_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_0_12,
{ /* end of list */ }
};
- pc_i440fx_0_13_machine_options(mc);
+ pc_machine_v0_13_class_init(oc, data);
mc->hw_version = "0.12";
mc->name = "pc-0.12";
machine_class_add_compat_props(mc, compat_props);
@@ -911,7 +881,6 @@ static const TypeInfo pc_machine_v0_12_type_info = {
};
#define PC_COMPAT_0_11 \
- PC_COMPAT_0_12,\
{\
.driver = "virtio-blk-pci",\
.property = "vectors",\
@@ -937,7 +906,7 @@ static void pc_machine_v0_11_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_0_11,
{ /* end of list */ }
};
- pc_i440fx_0_13_machine_options(mc);
+ pc_machine_v0_12_class_init(oc, data);
mc->hw_version = "0.11";
mc->name = "pc-0.11";
machine_class_add_compat_props(mc, compat_props);
@@ -953,7 +922,6 @@ 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",
.property = "class",
@@ -977,7 +945,7 @@ static void pc_machine_v0_10_class_init(ObjectClass *oc,
void *data)
},
{ /* end of list */ }
};
- pc_i440fx_0_13_machine_options(mc);
+ pc_machine_v0_11_class_init(oc, data);
mc->hw_version = "0.10";
mc->name = "pc-0.10";
machine_class_add_compat_props(mc, compat_props);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 9eeeac6..74c6d3c 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -354,15 +354,10 @@ static TypeInfo pc_q35_machine_type_info = {
.abstract = true,
};
-static void pc_q35_2_1_machine_options(MachineClass *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->default_machine_opts = "firmware=bios-256k.bin";
mc->alias = "q35";
mc->init = pc_q35_init;
mc->name = "pc-q35-2.1";
@@ -374,8 +369,6 @@ static TypeInfo pc_q35_machine_v2_1_type_info = {
.class_init = pc_q35_machine_v2_1_class_init,
};
-#define pc_q35_2_0_machine_options pc_q35_2_1_machine_options
-
static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -383,7 +376,8 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_2_0,
{ /* end of list */ }
};
- pc_q35_2_0_machine_options(mc);
+ pc_q35_machine_v2_1_class_init(oc, data);
+ mc->alias = NULL;
mc->init = pc_q35_init_2_0;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-2.0";
@@ -402,6 +396,8 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_1_7,
{ /* end of list */ }
};
+ pc_q35_machine_v2_0_class_init(oc, data);
+ mc->default_machine_opts = NULL;
mc->init = pc_q35_init_1_7;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.7";
@@ -420,6 +416,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_1_6,
{ /* end of list */ }
};
+ pc_q35_machine_v1_7_class_init(oc, data);
mc->init = pc_q35_init_1_6;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.6";
@@ -438,6 +435,7 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_1_5,
{ /* end of list */ }
};
+ pc_q35_machine_v1_6_class_init(oc, data);
mc->init = pc_q35_init_1_5;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.5";
@@ -456,6 +454,7 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc,
void *data)
PC_COMPAT_1_4,
{ /* end of list */ }
};
+ pc_q35_machine_v1_5_class_init(oc, data);
mc->hot_add_cpu = NULL;
mc->init = pc_q35_init_1_4;
machine_class_add_compat_props(mc, compat_props);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index e140b1e..318f2cc 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -350,7 +350,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
}
#define PC_COMPAT_1_7 \
- PC_COMPAT_2_0, \
{\
.driver = TYPE_USB_DEVICE,\
.property = "msos-desc",\
@@ -368,7 +367,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
}
#define PC_COMPAT_1_6 \
- PC_COMPAT_1_7, \
{\
.driver = "e1000",\
.property = "mitigation",\
@@ -392,7 +390,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
}
#define PC_COMPAT_1_5 \
- PC_COMPAT_1_6, \
{\
.driver = "Conroe-" TYPE_X86_CPU,\
.property = "model",\
@@ -436,7 +433,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
}
#define PC_COMPAT_1_4 \
- PC_COMPAT_1_5, \
{\
.driver = "scsi-hd",\
.property = "discard_granularity",\
--
1.9.3
- [Qemu-devel] [RFC v3 08/35] piix: Move pc-0.1[23] rombar compat props to PC_COMPAT_0_13, (continued)
- [Qemu-devel] [RFC v3 08/35] piix: Move pc-0.1[23] rombar compat props to PC_COMPAT_0_13, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 07/35] piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 09/35] piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 10/35] machine: Make compat_props a linked list, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 11/35] pc: Register machine classes directly instead of using QEMUMachine, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 12/35] pc: Eliminate pc_common_machine_options(), Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 13/35] pc: Eliminate pc_default_machine_options(), Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 14/35] piix: Eliminate pc_i440fx_machine_options(), Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 15/35] q35: Eliminate pc_q35_machine_options(), Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 16/35] q35: Eliminate pc_q35_1_4_machine_options(), Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 17/35] pc: Eliminate all *_machine_options() functions,
Eduardo Habkost <=
- [Qemu-devel] [RFC v3 18/35] machine: Eliminate QEMUMachine.compat_props, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 19/35] pc: Rename pc_machine variable to pcms, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 20/35] pc: Move pci_enabled parameter to PCMachineClass, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 21/35] q35: Use PCMachineClass.pci_enabled field, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 22/35] pc: Move kvmclock_enabled to PCMachineClass, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 23/35] pc: Move smbios_legacy_mode to PCMachineClass, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 24/35] pc: Move smbios_defaults to PCMachineClass, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 25/35] pc: Move has_acpi_build to PCMachineClass, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 26/35] pc: Move has_pci_info to PCMachineClass, Eduardo Habkost, 2014/07/04
- [Qemu-devel] [RFC v3 27/35] pc: Move gigabyte_align to PCMachineClass, Eduardo Habkost, 2014/07/04