diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2015-05-15 14:18:52 -0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-05-31 16:26:42 +0200 |
commit | b6b5c8e492ae7b71a16fe702b7409bff0feebfa7 (patch) | |
tree | 4140b36ae230659e18c26c9ba78acf19845640a0 /hw/i386/pc_q35.c | |
parent | f6d5a0bad276ea97fac4e0efb0f41f54a3f1ac84 (diff) | |
download | qemu-b6b5c8e492ae7b71a16fe702b7409bff0feebfa7.tar.gz qemu-b6b5c8e492ae7b71a16fe702b7409bff0feebfa7.tar.bz2 qemu-b6b5c8e492ae7b71a16fe702b7409bff0feebfa7.zip |
pc: Define MACHINE_OPTIONS macros consistently for all machines
Define a MACHINE_OPTIONS macro for each PC machine, and move every field
inside the QEMUMachine structs to the macros, except for name, init, and
compat_props.
This also ensures that all MACHINE_OPTIONS inherit the fields from the
next version, so their definitions carry only the changes that exist
between one version and the next one.
Comments about specific cases:
pc-*-2.1:
Existing PC_*_2_1_MACHINE_OPTIONS macros were defined as:
PC_*_MACHINE_OPTIONS,
.default_machine_opts = "firmware=bios-256k.bin"
PC_*_2_2_MACHINE_OPTIONS is:
PC_*_2_3_MACHINE_OPTIONS
which is expanded to:
PC_*_MACHINE_OPTIONS,
.default_machine_opts = "firmware=bios-256k.bin",
.default_display = "std"
The only difference between 2_1 and 2_2 is .default_display, that's why
we didn't reuse PC_*_2_2_MACHINE_OPTIONS. The good news is that having
multiple initializers for a field is allowed by C99, and the last
initializer overrides the previous ones.
So we can reuse the 2_2 macro in 2_1 and define PC_*_2_1_MACHINE_OPTIONS
as:
PC_*_2_2_MACHINE_OPTIONS,
.default_display = NULL
pc-*-1.7:
PC_*_1_7_MACHINE_OPTIONS was defined as:
PC_*_MACHINE_OPTIONS
PC_*_2_0_MACHINE_OPTIONS is defined as:
PC_*_2_1_MACHINE_OPTIONS
which is expanded to:
PC_*_2_2_MACHINE_OPTIONS,
.default_display = NULL
which is expanded to:
PC_*_2_3_MACHINE_OPTIONS,
.default_display = NULL
which is expanded to:
PC_*_MACHINE_OPTIONS,
.default_machine_opts = "firmware=bios-256k.bin",
.default_display = "std",
.default_display = NULL /* overrides the previous line */
So, the only difference between PC_*_1_7_MACHINE_OPTIONS and
PC_*_2_0_MACHINE_OPTIONS is .default_machine_opts (as .default_display
is not explicitly set by PC_*_MACHINE_OPTIONS so it is NULL).
So we can keep the macro reuse pattern and define
PC_*_2_0_MACHINE_OPTIONS as:
PC_*_2_0_MACHINE_OPTIONS,
.default_machine_opts = NULL
pc-*-2.4 (alias and is_default fields):
Set alias and is_default fields inside the 2.4 MACHINE_OPTIONS macro,
and clear it in the 2.3 macro (that reuses the 2.4 macro).
hw_machine:
As all the machines older than v1.0 set hw_version explicitly, we can
safely move the field to the MACHINE_OPTIONS macros without affecting
the other versions that reuse them.
init function:
Some machines had the init function set inside the MACHINE_OPTIONS
macro. Move it to the QEMUMachine declaration, to keep it consistent
with the other machines.
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>
Diffstat (limited to 'hw/i386/pc_q35.c')
-rw-r--r-- | hw/i386/pc_q35.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 0051666ce2..196178ec5f 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -424,16 +424,18 @@ static void pc_q35_init_1_4(MachineState *machine) #define PC_Q35_2_4_MACHINE_OPTIONS \ PC_Q35_MACHINE_OPTIONS, \ .default_machine_opts = "firmware=bios-256k.bin", \ - .default_display = "std" + .default_display = "std", \ + .alias = "q35" static QEMUMachine pc_q35_machine_v2_4 = { PC_Q35_2_4_MACHINE_OPTIONS, .name = "pc-q35-2.4", - .alias = "q35", .init = pc_q35_init, }; -#define PC_Q35_2_3_MACHINE_OPTIONS PC_Q35_2_4_MACHINE_OPTIONS +#define PC_Q35_2_3_MACHINE_OPTIONS \ + PC_Q35_2_4_MACHINE_OPTIONS, \ + .alias = NULL static QEMUMachine pc_q35_machine_v2_3 = { PC_Q35_2_3_MACHINE_OPTIONS, @@ -445,7 +447,8 @@ static QEMUMachine pc_q35_machine_v2_3 = { }, }; -#define PC_Q35_2_2_MACHINE_OPTIONS PC_Q35_2_3_MACHINE_OPTIONS +#define PC_Q35_2_2_MACHINE_OPTIONS \ + PC_Q35_2_3_MACHINE_OPTIONS static QEMUMachine pc_q35_machine_v2_2 = { PC_Q35_2_2_MACHINE_OPTIONS, @@ -457,9 +460,9 @@ static QEMUMachine pc_q35_machine_v2_2 = { }, }; -#define PC_Q35_2_1_MACHINE_OPTIONS \ - PC_Q35_MACHINE_OPTIONS, \ - .default_machine_opts = "firmware=bios-256k.bin" +#define PC_Q35_2_1_MACHINE_OPTIONS \ + PC_Q35_2_2_MACHINE_OPTIONS, \ + .default_display = NULL static QEMUMachine pc_q35_machine_v2_1 = { PC_Q35_2_1_MACHINE_OPTIONS, @@ -471,7 +474,8 @@ static QEMUMachine pc_q35_machine_v2_1 = { }, }; -#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, @@ -483,7 +487,9 @@ static QEMUMachine pc_q35_machine_v2_0 = { }, }; -#define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS +#define PC_Q35_1_7_MACHINE_OPTIONS \ + PC_Q35_2_0_MACHINE_OPTIONS, \ + .default_machine_opts = NULL static QEMUMachine pc_q35_machine_v1_7 = { PC_Q35_1_7_MACHINE_OPTIONS, @@ -495,7 +501,8 @@ static QEMUMachine pc_q35_machine_v1_7 = { }, }; -#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, @@ -507,8 +514,11 @@ static QEMUMachine pc_q35_machine_v1_6 = { }, }; +#define PC_Q35_1_5_MACHINE_OPTIONS \ + PC_Q35_1_6_MACHINE_OPTIONS + static QEMUMachine pc_q35_machine_v1_5 = { - PC_Q35_1_6_MACHINE_OPTIONS, + PC_Q35_1_5_MACHINE_OPTIONS, .name = "pc-q35-1.5", .init = pc_q35_init_1_5, .compat_props = (GlobalProperty[]) { @@ -518,7 +528,7 @@ static QEMUMachine pc_q35_machine_v1_5 = { }; #define PC_Q35_1_4_MACHINE_OPTIONS \ - PC_Q35_1_6_MACHINE_OPTIONS, \ + PC_Q35_1_5_MACHINE_OPTIONS, \ .hot_add_cpu = NULL static QEMUMachine pc_q35_machine_v1_4 = { |