pc: Don't use QEMUMachine, simplify compat+init code
cover pc: Don't use QEMUMachine, simplify compat+init code
This series changes the PC code to not need QEMUMachine anymore, removes ~200 lines of code and simplifies the steps needed to new PC machines in the future.
Previously, a new PC machine required:
* A new PC_COMPAT_* macro;
* A new pc_compat_*() function[1];
* A new pc_init_*() function;
* A new MACHINE_OPTIONS macro;
* A new QEMUMachine declaration;
* A new qemu_register_pc_machine() call in the machine_init() function.
Now it just needs:
* A new PC_COMPAT_* macro;
* A new pc_compat_*() function[1];
* A new pc_*_machine_options() function;
* A DEFINE_*_MACHINE line.
This series depends on the series I submitted recently:
[PATCH v2 00/13] pc, hw, spapr: Cleanup of {HW, PC, SPAPR}_COMPAT_* macros
A git tree can be seen at:
git://github.com/ehabkost/qemu-hacks.git work/pc-compat-macros
[1] I still plan to eliminate the need for the pc_compat_*() functions, and move all compat data inside MachineClass/PCMachineClass, but that will be done later.
Eduardo Habkost (10):
pc: Define MACHINE_OPTIONS macros consistently for all machines
pc: Define machines using a DEFINE_PC_MACHINE macro
pc: Convert *_MACHINE_OPTIONS macros into functions
pc: Move compat_props setting inside *_machine_options() functions
pc: Don't use QEMUMachine anymore
pc: Remove qemu_register_pc_machine() function
machine: Remove unused fields from QEMUMachine
piix: Add kvmclock_enabled, pci_enabled globals
piix: Eliminate pc_init_pci()
pc: Generate init functions with a macro
hw/i386/pc.c | 45 ----- hw/i386/pc_piix.c | 554 +++++++++++++++++++++------------------------------ hw/i386/pc_q35.c | 240 ++++++++-------------- include/hw/boards.h | 15 +- include/hw/i386/pc.h | 45 ++++- vl.c | 15 -- 6 files changed, 358 insertions(+), 556 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/10 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.
--- hw/i386/pc_piix.c | 128 +++++++++++++++++++++++++++++++++++++----------------- hw/i386/pc_q35.c | 34 ++++++++++----- 2 files changed, 110 insertions(+), 52 deletions(-)
hw/i386/pc_piix.c +88 -40
@@ -526,18 +526,21 @@ static void pc_xen_hvm_init(MachineState *machine)#define PC_I440FX_2_4_MACHINE_OPTIONS \ PC_I440FX_MACHINE_OPTIONS, \ .default_machine_opts = "firmware=bios-256k.bin", \ - .default_display = "std" + .default_display = "std", \ + .alias = "pc", \ + .is_default = 1static QEMUMachine pc_i440fx_machine_v2_4 = {PC_I440FX_2_4_MACHINE_OPTIONS , .name ="pc-i440fx-2.4" , - .alias ="pc" , .init = pc_init_pci, - .is_default =1 , }; -#define PC_I440FX_2_3_MACHINE_OPTIONS PC_I440FX_2_4_MACHINE_OPTIONS +#define PC_I440FX_2_3_MACHINE_OPTIONS \ + PC_I440FX_2_4_MACHINE_OPTIONS, \ + .alias = NULL, \ + .is_default = 0static QEMUMachine pc_i440fx_machine_v2_3 = {PC_I440FX_2_3_MACHINE_OPTIONS ,
@@ -549,7 +552,8 @@ static QEMUMachine pc_i440fx_machine_v2_3 = { }, }; -#define PC_I440FX_2_2_MACHINE_OPTIONS PC_I440FX_2_3_MACHINE_OPTIONS +#define PC_I440FX_2_2_MACHINE_OPTIONS \ + PC_I440FX_2_3_MACHINE_OPTIONSstatic QEMUMachine pc_i440fx_machine_v2_2 = {PC_I440FX_2_2_MACHINE_OPTIONS ,
@@ -561,9 +565,9 @@ static QEMUMachine pc_i440fx_machine_v2_2 = { }, }; -#define PC_I440FX_2_1_MACHINE_OPTIONS \ - PC_I440FX_MACHINE_OPTIONS, \ - .default_machine_opts = "firmware=bios-256k.bin" +#define PC_I440FX_2_1_MACHINE_OPTIONS \ + PC_I440FX_2_2_MACHINE_OPTIONS, \ + .default_display = NULLstatic QEMUMachine pc_i440fx_machine_v2_1 = {PC_I440FX_2_1_MACHINE_OPTIONS ,
@@ -575,7 +579,8 @@ static QEMUMachine pc_i440fx_machine_v2_1 = { }, }; -#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_OPTIONSstatic QEMUMachine pc_i440fx_machine_v2_0 = {PC_I440FX_2_0_MACHINE_OPTIONS ,
@@ -587,7 +592,9 @@ static QEMUMachine pc_i440fx_machine_v2_0 = { }, }; -#define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS +#define PC_I440FX_1_7_MACHINE_OPTIONS \ + PC_I440FX_2_0_MACHINE_OPTIONS, \ + .default_machine_opts = NULLstatic QEMUMachine pc_i440fx_machine_v1_7 = {PC_I440FX_1_7_MACHINE_OPTIONS ,
@@ -599,7 +606,8 @@ static QEMUMachine pc_i440fx_machine_v1_7 = { }, }; -#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS +#define PC_I440FX_1_6_MACHINE_OPTIONS \ + PC_I440FX_1_7_MACHINE_OPTIONSstatic QEMUMachine pc_i440fx_machine_v1_6 = {PC_I440FX_1_6_MACHINE_OPTIONS ,
@@ -611,8 +619,11 @@ static QEMUMachine pc_i440fx_machine_v1_6 = { }, }; +#define PC_I440FX_1_5_MACHINE_OPTIONS \ + PC_I440FX_1_6_MACHINE_OPTIONS +static QEMUMachine pc_i440fx_machine_v1_5 = { -PC_I440FX_1_6_MACHINE_OPTIONS , +PC_I440FX_1_5_MACHINE_OPTIONS , .name ="pc-i440fx-1.5" , .init = pc_init_pci_1_5, .compat_props = (GlobalProperty []) {
@@ -622,7 +633,7 @@ static QEMUMachine pc_i440fx_machine_v1_5 = { };#define PC_I440FX_1_4_MACHINE_OPTIONS \ - PC_I440FX_1_6_MACHINE_OPTIONS, \ + PC_I440FX_1_5_MACHINE_OPTIONS, \ .hot_add_cpu = NULLstatic QEMUMachine pc_i440fx_machine_v1_4 = {
@@ -655,8 +666,11 @@ static QEMUMachine pc_i440fx_machine_v1_4 = { .value = "off",\ }, +#define PC_I440FX_1_3_MACHINE_OPTIONS \ + PC_I440FX_1_4_MACHINE_OPTIONS +static QEMUMachine pc_machine_v1_3 = { -PC_I440FX_1_4_MACHINE_OPTIONS , +PC_I440FX_1_3_MACHINE_OPTIONS , .name ="pc-1.3" , .init = pc_init_pci_1_3, .compat_props = (GlobalProperty []) {
@@ -694,12 +708,12 @@ static QEMUMachine pc_machine_v1_3 = { },#define PC_I440FX_1_2_MACHINE_OPTIONS \ - PC_I440FX_1_4_MACHINE_OPTIONS, \ - .init = pc_init_pci_1_2 + PC_I440FX_1_3_MACHINE_OPTIONS static QEMUMachine pc_machine_v1_2 = { PC_I440FX_1_2_MACHINE_OPTIONS, .name = "pc-1.2", + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty[]) { PC_COMPAT_1_2 { /* end of list */ }
@@ -738,9 +752,13 @@ static QEMUMachine pc_machine_v1_2 = { .value = "off",\ }, +#define PC_I440FX_1_1_MACHINE_OPTIONS \ + PC_I440FX_1_2_MACHINE_OPTIONS +static QEMUMachine pc_machine_v1_1 = { -PC_I440FX_1_2_MACHINE_OPTIONS , +PC_I440FX_1_1_MACHINE_OPTIONS , .name ="pc-1.1" , + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty []) {PC_COMPAT_1_1 { /* end of list */ }
@@ -767,27 +785,35 @@ static QEMUMachine pc_machine_v1_1 = { .value = "no",\ }, +#define PC_I440FX_1_0_MACHINE_OPTIONS \ + PC_I440FX_1_1_MACHINE_OPTIONS, \ + .hw_version = "1.0" +static QEMUMachine pc_machine_v1_0 = { -PC_I440FX_1_2_MACHINE_OPTIONS , +PC_I440FX_1_0_MACHINE_OPTIONS , .name ="pc-1.0" , + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty []) { PC_COMPAT_1_0 {/* end of list */ } }, - .hw_version ="1.0" , };#define PC_COMPAT_0_15 \ PC_COMPAT_1_0 +#define PC_I440FX_0_15_MACHINE_OPTIONS \ + PC_I440FX_1_0_MACHINE_OPTIONS, \ + .hw_version = "0.15" +static QEMUMachine pc_machine_v0_15 = { -PC_I440FX_1_2_MACHINE_OPTIONS , +PC_I440FX_0_15_MACHINE_OPTIONS , .name ="pc-0.15" , + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty []) { PC_COMPAT_0_15 {/* end of list */ } }, - .hw_version ="0.15" , };#define PC_COMPAT_0_14 \
@@ -818,14 +844,18 @@ static QEMUMachine pc_machine_v0_15 = { .value = stringify(2),\ }, +#define PC_I440FX_0_14_MACHINE_OPTIONS \ + PC_I440FX_0_15_MACHINE_OPTIONS, \ + .hw_version = "0.14" +static QEMUMachine pc_machine_v0_14 = { -PC_I440FX_1_2_MACHINE_OPTIONS , +PC_I440FX_0_14_MACHINE_OPTIONS , .name ="pc-0.14" , + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty []) { PC_COMPAT_0_14 {/* end of list */ } }, - .hw_version ="0.14" , };#define PC_COMPAT_0_13 \
@@ -853,17 +883,17 @@ static QEMUMachine pc_machine_v0_14 = { },#define PC_I440FX_0_13_MACHINE_OPTIONS \ - PC_I440FX_1_2_MACHINE_OPTIONS, \ - .init = pc_init_pci_no_kvmclock + PC_I440FX_0_14_MACHINE_OPTIONS, \ + .hw_version = "0.13"static QEMUMachine pc_machine_v0_13 = {PC_I440FX_0_13_MACHINE_OPTIONS , .name ="pc-0.13" , + .init = pc_init_pci_no_kvmclock, .compat_props = (GlobalProperty []) { PC_COMPAT_0_13 {/* end of list */ } }, - .hw_version ="0.13" , };#define PC_COMPAT_0_12 \
@@ -890,14 +920,18 @@ static QEMUMachine pc_machine_v0_13 = { .value = "1",\ }, +#define PC_I440FX_0_12_MACHINE_OPTIONS \ + PC_I440FX_0_13_MACHINE_OPTIONS, \ + .hw_version = "0.12" +static QEMUMachine pc_machine_v0_12 = { -PC_I440FX_0_13_MACHINE_OPTIONS , +PC_I440FX_0_12_MACHINE_OPTIONS , .name ="pc-0.12" , + .init = pc_init_pci_no_kvmclock, .compat_props = (GlobalProperty []) { PC_COMPAT_0_12 {/* end of list */ } }, - .hw_version ="0.12" , };#define PC_COMPAT_0_11 \
@@ -920,14 +954,18 @@ static QEMUMachine pc_machine_v0_12 = { .value = "0.11",\ }, +#define PC_I440FX_0_11_MACHINE_OPTIONS \ + PC_I440FX_0_12_MACHINE_OPTIONS, \ + .hw_version = "0.11" +static QEMUMachine pc_machine_v0_11 = { -PC_I440FX_0_13_MACHINE_OPTIONS , +PC_I440FX_0_11_MACHINE_OPTIONS , .name ="pc-0.11" , + .init = pc_init_pci_no_kvmclock, .compat_props = (GlobalProperty []) { PC_COMPAT_0_11 {/* end of list */ } }, - .hw_version ="0.11" , };#define PC_COMPAT_0_10 \
@@ -954,36 +992,46 @@ static QEMUMachine pc_machine_v0_11 = { .value = "0.10",\ }, +#define PC_I440FX_0_10_MACHINE_OPTIONS \ + PC_I440FX_0_11_MACHINE_OPTIONS, \ + .hw_version = "0.10" +static QEMUMachine pc_machine_v0_10 = { -PC_I440FX_0_13_MACHINE_OPTIONS , +PC_I440FX_0_10_MACHINE_OPTIONS , .name ="pc-0.10" , + .init = pc_init_pci_no_kvmclock, .compat_props = (GlobalProperty []) { PC_COMPAT_0_10 {/* end of list */ } }, - .hw_version ="0.10" , }; +#define ISAPC_MACHINE_OPTIONS \ + PC_COMMON_MACHINE_OPTIONS, \ + .desc = "ISA-only PC", \ + .max_cpus = 1 +static QEMUMachine isapc_machine = { -PC_COMMON_MACHINE_OPTIONS , +ISAPC_MACHINE_OPTIONS , .name ="isapc" , - .desc ="ISA-only PC" , .init = pc_init_isa, - .max_cpus =1 , .compat_props = (GlobalProperty []) { {/* end of list */ } }, };#ifdef CONFIG_XEN +#define XENFV_MACHINE_OPTIONS \ + PC_COMMON_MACHINE_OPTIONS, \ + .desc = "Xen Fully-virtualized PC", \ + .max_cpus = HVM_MAX_VCPUS, \ + .default_machine_opts = "accel=xen", \ + .hot_add_cpu = pc_hot_add_cpu +static QEMUMachine xenfv_machine = { -PC_COMMON_MACHINE_OPTIONS , +XENFV_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, };#endif
hw/i386/pc_q35.c +22 -12
@@ -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 = NULLstatic 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_OPTIONSstatic 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 = NULLstatic 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_OPTIONSstatic 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 = NULLstatic 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_OPTIONSstatic 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 = NULLstatic QEMUMachine pc_q35_machine_v1_4 = {
Signature · 1 line
2.1.0
PATCH 2/10 pc: Define machines using a DEFINE_PC_MACHINE macro
In reply to Eduardo HabkostThis will automatically generate the existing QEMUMachine structs based on the *_MACHINE_OPTIONS macros, and automatically add registration code for them.
--- hw/i386/pc_piix.c | 270 ++++++++++++--------------------------------------- hw/i386/pc_q35.c | 118 +++++----------------- include/hw/i386/pc.h | 16 +++ 3 files changed, 103 insertions(+), 301 deletions(-)
hw/i386/pc_piix.c +61 -209
@@ -530,121 +530,70 @@ static void pc_xen_hvm_init(MachineState *machine) .alias = "pc", \ .is_default = 1 +DEFINE_PC_MACHINE (v2_4,"pc-i440fx-2.4" , pc_init_pci, + PC_I440FX_2_4_MACHINE_OPTIONS, /* no compat */) -static QEMUMachine pc_i440fx_machine_v2_4 = { -PC_I440FX_2_4_MACHINE_OPTIONS , - .name ="pc-i440fx-2.4" , - .init = pc_init_pci, -}; #define PC_I440FX_2_3_MACHINE_OPTIONS \PC_I440FX_2_4_MACHINE_OPTIONS , \ .alias = NULL, \ .is_default = 0 -static QEMUMachine pc_i440fx_machine_v2_3 = { -PC_I440FX_2_3_MACHINE_OPTIONS , - .name ="pc-i440fx-2.3" , - .init = pc_init_pci_2_3, - .compat_props = (GlobalProperty []) { - PC_COMPAT_2_3 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v2_3,"pc-i440fx-2.3" , pc_init_pci_2_3, + PC_I440FX_2_3_MACHINE_OPTIONS, PC_COMPAT_2_3); +#define PC_I440FX_2_2_MACHINE_OPTIONS \ PC_I440FX_2_3_MACHINE_OPTIONS -static QEMUMachine pc_i440fx_machine_v2_2 = { -PC_I440FX_2_2_MACHINE_OPTIONS , - .name ="pc-i440fx-2.2" , - .init = pc_init_pci_2_2, - .compat_props = (GlobalProperty []) { - PC_COMPAT_2_2 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v2_2,"pc-i440fx-2.2" , pc_init_pci_2_2, +PC_I440FX_2_2_MACHINE_OPTIONS ,PC_COMPAT_2_2 ); +#define PC_I440FX_2_1_MACHINE_OPTIONS \ PC_I440FX_2_2_MACHINE_OPTIONS, \ .default_display = NULL -static QEMUMachine pc_i440fx_machine_v2_1 = { -PC_I440FX_2_1_MACHINE_OPTIONS , - .name ="pc-i440fx-2.1" , - .init = pc_init_pci_2_1, - .compat_props = (GlobalProperty []) { - PC_COMPAT_2_1 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v2_1,"pc-i440fx-2.1" , pc_init_pci_2_1, +PC_I440FX_2_1_MACHINE_OPTIONS ,PC_COMPAT_2_1 ); +#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 []) { - PC_COMPAT_2_0 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v2_0,"pc-i440fx-2.0" , pc_init_pci_2_0, +PC_I440FX_2_0_MACHINE_OPTIONS ,PC_COMPAT_2_0 ); +#define PC_I440FX_1_7_MACHINE_OPTIONS \ PC_I440FX_2_0_MACHINE_OPTIONS, \ .default_machine_opts = NULL -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 []) { - PC_COMPAT_1_7 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v1_7,"pc-i440fx-1.7" , pc_init_pci_1_7, +PC_I440FX_1_7_MACHINE_OPTIONS ,PC_COMPAT_1_7 ); +#define PC_I440FX_1_6_MACHINE_OPTIONS \ PC_I440FX_1_7_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 []) { - PC_COMPAT_1_6 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v1_6,"pc-i440fx-1.6" , pc_init_pci_1_6, +PC_I440FX_1_6_MACHINE_OPTIONS ,PC_COMPAT_1_6 ); +#define PC_I440FX_1_5_MACHINE_OPTIONS \ PC_I440FX_1_6_MACHINE_OPTIONS -static QEMUMachine pc_i440fx_machine_v1_5 = { -PC_I440FX_1_5_MACHINE_OPTIONS , - .name ="pc-i440fx-1.5" , - .init = pc_init_pci_1_5, - .compat_props = (GlobalProperty []) { - PC_COMPAT_1_5 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v1_5,"pc-i440fx-1.5" , pc_init_pci_1_5, +PC_I440FX_1_5_MACHINE_OPTIONS ,PC_COMPAT_1_5 ); +#define PC_I440FX_1_4_MACHINE_OPTIONS \ PC_I440FX_1_5_MACHINE_OPTIONS, \ .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 []) { - PC_COMPAT_1_4 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v1_4,"pc-i440fx-1.4" , pc_init_pci_1_4, +PC_I440FX_1_4_MACHINE_OPTIONS ,PC_COMPAT_1_4 ); +#define PC_COMPAT_1_3 \ PC_COMPAT_1_4 \
@@ -669,15 +618,9 @@ static QEMUMachine pc_i440fx_machine_v1_4 = {#define PC_I440FX_1_3_MACHINE_OPTIONS \ PC_I440FX_1_4_MACHINE_OPTIONS -static QEMUMachine pc_machine_v1_3 = { -PC_I440FX_1_3_MACHINE_OPTIONS , - .name ="pc-1.3" , - .init = pc_init_pci_1_3, - .compat_props = (GlobalProperty []) { - PC_COMPAT_1_3 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v1_3,"pc-1.3" , pc_init_pci_1_3, +PC_I440FX_1_3_MACHINE_OPTIONS ,PC_COMPAT_1_3 ); +#define PC_COMPAT_1_2 \ PC_COMPAT_1_3 \
@@ -710,15 +653,9 @@ static QEMUMachine pc_machine_v1_3 = {#define PC_I440FX_1_2_MACHINE_OPTIONS \ PC_I440FX_1_3_MACHINE_OPTIONS -static QEMUMachine pc_machine_v1_2 = { -PC_I440FX_1_2_MACHINE_OPTIONS , - .name ="pc-1.2" , - .init = pc_init_pci_1_2, - .compat_props = (GlobalProperty []) { - PC_COMPAT_1_2 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v1_2,"pc-1.2" , pc_init_pci_1_2, +PC_I440FX_1_2_MACHINE_OPTIONS ,PC_COMPAT_1_2 ); +#define PC_COMPAT_1_1 \ PC_COMPAT_1_2 \
@@ -755,15 +692,9 @@ static QEMUMachine pc_machine_v1_2 = {#define PC_I440FX_1_1_MACHINE_OPTIONS \ PC_I440FX_1_2_MACHINE_OPTIONS -static QEMUMachine pc_machine_v1_1 = { -PC_I440FX_1_1_MACHINE_OPTIONS , - .name ="pc-1.1" , - .init = pc_init_pci_1_2, - .compat_props = (GlobalProperty []) { - PC_COMPAT_1_1 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v1_1,"pc-1.1" , pc_init_pci_1_2, +PC_I440FX_1_1_MACHINE_OPTIONS ,PC_COMPAT_1_1 ); +#define PC_COMPAT_1_0 \ PC_COMPAT_1_1 \
@@ -789,15 +720,9 @@ static QEMUMachine pc_machine_v1_1 = {PC_I440FX_1_1_MACHINE_OPTIONS , \ .hw_version = "1.0" -static QEMUMachine pc_machine_v1_0 = { - PC_I440FX_1_0_MACHINE_OPTIONS, - .name = "pc-1.0", - .init = pc_init_pci_1_2, - .compat_props = (GlobalProperty []) { - PC_COMPAT_1_0 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v1_0,"pc-1.0" , pc_init_pci_1_2, +PC_I440FX_1_0_MACHINE_OPTIONS ,PC_COMPAT_1_0 ); +#define PC_COMPAT_0_15 \ PC_COMPAT_1_0
@@ -806,15 +731,9 @@ static QEMUMachine pc_machine_v1_0 = {PC_I440FX_1_0_MACHINE_OPTIONS , \ .hw_version = "0.15" -static QEMUMachine pc_machine_v0_15 = { - PC_I440FX_0_15_MACHINE_OPTIONS, - .name = "pc-0.15", - .init = pc_init_pci_1_2, - .compat_props = (GlobalProperty []) { - PC_COMPAT_0_15 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v0_15,"pc-0.15" , pc_init_pci_1_2, +PC_I440FX_0_15_MACHINE_OPTIONS ,PC_COMPAT_0_15 ); +#define PC_COMPAT_0_14 \ PC_COMPAT_0_15 \
@@ -848,15 +767,9 @@ static QEMUMachine pc_machine_v0_15 = {PC_I440FX_0_15_MACHINE_OPTIONS , \ .hw_version = "0.14" -static QEMUMachine pc_machine_v0_14 = { - PC_I440FX_0_14_MACHINE_OPTIONS, - .name = "pc-0.14", - .init = pc_init_pci_1_2, - .compat_props = (GlobalProperty []) { - PC_COMPAT_0_14 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v0_14,"pc-0.14" , pc_init_pci_1_2, +PC_I440FX_0_14_MACHINE_OPTIONS ,PC_COMPAT_0_14 ); +#define PC_COMPAT_0_13 \ PC_COMPAT_0_14 \
@@ -886,15 +799,9 @@ static QEMUMachine pc_machine_v0_14 = {PC_I440FX_0_14_MACHINE_OPTIONS , \ .hw_version = "0.13" -static QEMUMachine pc_machine_v0_13 = { - PC_I440FX_0_13_MACHINE_OPTIONS, - .name = "pc-0.13", - .init = pc_init_pci_no_kvmclock, - .compat_props = (GlobalProperty []) { - PC_COMPAT_0_13 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v0_13,"pc-0.13" , pc_init_pci_no_kvmclock, +PC_I440FX_0_13_MACHINE_OPTIONS ,PC_COMPAT_0_13 ); +#define PC_COMPAT_0_12 \ PC_COMPAT_0_13 \
@@ -924,15 +831,9 @@ static QEMUMachine pc_machine_v0_13 = {PC_I440FX_0_13_MACHINE_OPTIONS , \ .hw_version = "0.12" -static QEMUMachine pc_machine_v0_12 = { - PC_I440FX_0_12_MACHINE_OPTIONS, - .name = "pc-0.12", - .init = pc_init_pci_no_kvmclock, - .compat_props = (GlobalProperty []) { - PC_COMPAT_0_12 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v0_12,"pc-0.12" , pc_init_pci_no_kvmclock, +PC_I440FX_0_12_MACHINE_OPTIONS ,PC_COMPAT_0_12 ); +#define PC_COMPAT_0_11 \ PC_COMPAT_0_12 \
@@ -958,15 +859,9 @@ static QEMUMachine pc_machine_v0_12 = {PC_I440FX_0_12_MACHINE_OPTIONS , \ .hw_version = "0.11" -static QEMUMachine pc_machine_v0_11 = { - PC_I440FX_0_11_MACHINE_OPTIONS, - .name = "pc-0.11", - .init = pc_init_pci_no_kvmclock, - .compat_props = (GlobalProperty []) { - PC_COMPAT_0_11 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v0_11,"pc-0.11" , pc_init_pci_no_kvmclock, +PC_I440FX_0_11_MACHINE_OPTIONS ,PC_COMPAT_0_11 ); +#define PC_COMPAT_0_10 \ PC_COMPAT_0_11 \
@@ -996,29 +891,18 @@ static QEMUMachine pc_machine_v0_11 = {PC_I440FX_0_11_MACHINE_OPTIONS , \ .hw_version = "0.10" -static QEMUMachine pc_machine_v0_10 = { - PC_I440FX_0_10_MACHINE_OPTIONS, - .name = "pc-0.10", - .init = pc_init_pci_no_kvmclock, - .compat_props = (GlobalProperty []) { - PC_COMPAT_0_10 - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (v0_10,"pc-0.10" , pc_init_pci_no_kvmclock, +PC_I440FX_0_10_MACHINE_OPTIONS ,PC_COMPAT_0_10 ); +#define ISAPC_MACHINE_OPTIONS \ PC_COMMON_MACHINE_OPTIONS, \ .desc = "ISA-only PC", \ .max_cpus = 1 -static QEMUMachine isapc_machine = { -ISAPC_MACHINE_OPTIONS , - .name ="isapc" , - .init = pc_init_isa, - .compat_props = (GlobalProperty []) { - {/* end of list */ } - }, -}; +DEFINE_PC_MACHINE (isapc,"isapc" , pc_init_isa, + ISAPC_MACHINE_OPTIONS, /* no compat */); +#ifdef CONFIG_XEN #define XENFV_MACHINE_OPTIONS \
@@ -1028,38 +912,6 @@ static QEMUMachine isapc_machine = { .default_machine_opts = "accel=xen", \ .hot_add_cpu = pc_hot_add_cpu -static QEMUMachine xenfv_machine = { -XENFV_MACHINE_OPTIONS , - .name ="xenfv" , - .init = pc_xen_hvm_init, -}; +DEFINE_PC_MACHINE (xenfv,"xenfv" , pc_xen_hvm_init, + XENFV_MACHINE_OPTIONS, /* no compat */);#endif - -static void pc_machine_init (void ) -{ -qemu_register_pc_machine (&pc_i440fx_machine_v2_4); -qemu_register_pc_machine (&pc_i440fx_machine_v2_3); -qemu_register_pc_machine (&pc_i440fx_machine_v2_2); -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); -#ifdef CONFIG_XEN -qemu_register_pc_machine (&xenfv_machine); -#endif -} - -machine_init (pc_machine_init);
hw/i386/pc_q35.c +26 -92
157 lines not on this page · raw message
include/hw/i386/pc.h +16 -0
@@ -525,4 +525,20 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .hot_add_cpu = pc_hot_add_cpu, \ .max_cpus = 255 +#define DEFINE_PC_MACHINE(suffix, namestr, initfn, OPTS, COMPAT) \ + static QEMUMachine pc_machine_##suffix = { \ + OPTS, \ + .name = namestr, \ + .init = initfn, \ + .compat_props = (GlobalProperty[]) { \ + COMPAT \ + { /* end of list */ } \ + }, \ + }; \ + static void pc_machine_init_##suffix(void) \ + { \ + qemu_register_pc_machine(&pc_machine_##suffix); \ + } \ + machine_init(pc_machine_init_##suffix) +#endif
Signature · 1 line
2.1.0
PATCH 3/10 pc: Convert *_MACHINE_OPTIONS macros into functions
In reply to Eduardo HabkostBy now the new functions will get QEMUMachine as argument, but they will be later converted to initialize a MachineClass struct directly.
--- hw/i386/pc_piix.c | 229 +++++++++++++++++++++++++++++++-------------------- hw/i386/pc_q35.c | 102 ++++++++++++++--------- include/hw/i386/pc.h | 42 +++++----- 3 files changed, 222 insertions(+), 151 deletions(-)
hw/i386/pc_piix.c +138 -91
@@ -517,82 +517,104 @@ static void pc_xen_hvm_init(MachineState *machine) }#endif -#define PC_I440FX_MACHINE_OPTIONS \ - PC_DEFAULT_MACHINE_OPTIONS, \ - .family = "pc_piix", \ - .desc = "Standard PC (i440FX + PIIX, 1996)", \ - .hot_add_cpu = pc_hot_add_cpu - -#define PC_I440FX_2_4_MACHINE_OPTIONS \ - PC_I440FX_MACHINE_OPTIONS, \ - .default_machine_opts = "firmware=bios-256k.bin", \ - .default_display = "std", \ - .alias = "pc", \ - .is_default = 1 + +static void pc_i440fx_machine_options (QEMUMachine *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) +{ +pc_i440fx_machine_options (m); + m->default_machine_opts ="firmware=bios-256k.bin" ; + m->default_display ="std" ; + m->alias ="pc" ; + m->is_default =1 ; +}DEFINE_PC_MACHINE (v2_4,"pc-i440fx-2.4" , pc_init_pci, - PC_I440FX_2_4_MACHINE_OPTIONS, /* no compat */) + pc_i440fx_2_4_machine_options, /* no compat */) -#define PC_I440FX_2_3_MACHINE_OPTIONS \ -PC_I440FX_2_4_MACHINE_OPTIONS , \ - .alias = NULL, \ - .is_default = 0 +static void pc_i440fx_2_3_machine_options(QEMUMachine *m) +{ +pc_i440fx_machine_options (m); + m->alias =NULL ; + m->is_default =0 ; +} DEFINE_PC_MACHINE(v2_3, "pc-i440fx-2.3", pc_init_pci_2_3, - PC_I440FX_2_3_MACHINE_OPTIONS, PC_COMPAT_2_3); + pc_i440fx_2_3_machine_options,PC_COMPAT_2_3 ); -#define PC_I440FX_2_2_MACHINE_OPTIONS \ - PC_I440FX_2_3_MACHINE_OPTIONS +static void pc_i440fx_2_2_machine_options (QEMUMachine *m) +{ +pc_i440fx_2_3_machine_options (m); +}DEFINE_PC_MACHINE (v2_2,"pc-i440fx-2.2" , pc_init_pci_2_2, -PC_I440FX_2_2_MACHINE_OPTIONS ,PC_COMPAT_2_2 ); + pc_i440fx_2_2_machine_options,PC_COMPAT_2_2 ); -#define PC_I440FX_2_1_MACHINE_OPTIONS \ - PC_I440FX_2_2_MACHINE_OPTIONS, \ - .default_display = NULL +static void pc_i440fx_2_1_machine_options (QEMUMachine *m) +{ +pc_i440fx_2_2_machine_options (m); + m->default_display =NULL ; +}DEFINE_PC_MACHINE (v2_1,"pc-i440fx-2.1" , pc_init_pci_2_1, -PC_I440FX_2_1_MACHINE_OPTIONS ,PC_COMPAT_2_1 ); + pc_i440fx_2_1_machine_options,PC_COMPAT_2_1 ); -#define PC_I440FX_2_0_MACHINE_OPTIONS \ - PC_I440FX_2_1_MACHINE_OPTIONS + +static void pc_i440fx_2_0_machine_options (QEMUMachine *m) +{ +pc_i440fx_2_1_machine_options (m); +}DEFINE_PC_MACHINE (v2_0,"pc-i440fx-2.0" , pc_init_pci_2_0, -PC_I440FX_2_0_MACHINE_OPTIONS ,PC_COMPAT_2_0 ); + pc_i440fx_2_0_machine_options,PC_COMPAT_2_0 ); -#define PC_I440FX_1_7_MACHINE_OPTIONS \ - PC_I440FX_2_0_MACHINE_OPTIONS, \ - .default_machine_opts = NULL +static void pc_i440fx_1_7_machine_options (QEMUMachine *m) +{ +pc_i440fx_2_0_machine_options (m); + m->default_machine_opts =NULL ; +}DEFINE_PC_MACHINE (v1_7,"pc-i440fx-1.7" , pc_init_pci_1_7, -PC_I440FX_1_7_MACHINE_OPTIONS ,PC_COMPAT_1_7 ); + pc_i440fx_1_7_machine_options,PC_COMPAT_1_7 ); -#define PC_I440FX_1_6_MACHINE_OPTIONS \ - PC_I440FX_1_7_MACHINE_OPTIONS +static void pc_i440fx_1_6_machine_options (QEMUMachine *m) +{ +pc_i440fx_1_7_machine_options (m); +}DEFINE_PC_MACHINE (v1_6,"pc-i440fx-1.6" , pc_init_pci_1_6, -PC_I440FX_1_6_MACHINE_OPTIONS ,PC_COMPAT_1_6 ); + pc_i440fx_1_6_machine_options,PC_COMPAT_1_6 ); -#define PC_I440FX_1_5_MACHINE_OPTIONS \ - PC_I440FX_1_6_MACHINE_OPTIONS +static void pc_i440fx_1_5_machine_options (QEMUMachine *m) +{ +pc_i440fx_1_6_machine_options (m); +}DEFINE_PC_MACHINE (v1_5,"pc-i440fx-1.5" , pc_init_pci_1_5, -PC_I440FX_1_5_MACHINE_OPTIONS ,PC_COMPAT_1_5 ); + pc_i440fx_1_5_machine_options,PC_COMPAT_1_5 ); -#define PC_I440FX_1_4_MACHINE_OPTIONS \ - PC_I440FX_1_5_MACHINE_OPTIONS, \ - .hot_add_cpu = NULL +static void pc_i440fx_1_4_machine_options (QEMUMachine *m) +{ +pc_i440fx_1_5_machine_options (m); + m->hot_add_cpu =NULL ; +}DEFINE_PC_MACHINE (v1_4,"pc-i440fx-1.4" , pc_init_pci_1_4, -PC_I440FX_1_4_MACHINE_OPTIONS ,PC_COMPAT_1_4 ); + pc_i440fx_1_4_machine_options,PC_COMPAT_1_4 );#define PC_COMPAT_1_3 \
@@ -615,11 +637,14 @@ DEFINE_PC_MACHINE(v1_4, "pc-i440fx-1.4", pc_init_pci_1_4, .value = "off",\ }, -#define PC_I440FX_1_3_MACHINE_OPTIONS \ - PC_I440FX_1_4_MACHINE_OPTIONS + +static void pc_i440fx_1_3_machine_options (QEMUMachine *m) +{ +pc_i440fx_1_4_machine_options (m); +}DEFINE_PC_MACHINE (v1_3,"pc-1.3" , pc_init_pci_1_3, -PC_I440FX_1_3_MACHINE_OPTIONS ,PC_COMPAT_1_3 ); + pc_i440fx_1_3_machine_options,PC_COMPAT_1_3 );#define PC_COMPAT_1_2 \
@@ -650,11 +675,13 @@ DEFINE_PC_MACHINE(v1_3, "pc-1.3", pc_init_pci_1_3, .value = "off",\ }, -#define PC_I440FX_1_2_MACHINE_OPTIONS \ - PC_I440FX_1_3_MACHINE_OPTIONS +static void pc_i440fx_1_2_machine_options (QEMUMachine *m) +{ +pc_i440fx_1_3_machine_options (m); +}DEFINE_PC_MACHINE (v1_2,"pc-1.2" , pc_init_pci_1_2, -PC_I440FX_1_2_MACHINE_OPTIONS ,PC_COMPAT_1_2 ); + pc_i440fx_1_2_machine_options,PC_COMPAT_1_2 );#define PC_COMPAT_1_1 \
@@ -689,11 +716,13 @@ DEFINE_PC_MACHINE(v1_2, "pc-1.2", pc_init_pci_1_2, .value = "off",\ }, -#define PC_I440FX_1_1_MACHINE_OPTIONS \ - PC_I440FX_1_2_MACHINE_OPTIONS +static void pc_i440fx_1_1_machine_options (QEMUMachine *m) +{ +pc_i440fx_1_2_machine_options (m); +}DEFINE_PC_MACHINE (v1_1,"pc-1.1" , pc_init_pci_1_2, -PC_I440FX_1_1_MACHINE_OPTIONS ,PC_COMPAT_1_1 ); + pc_i440fx_1_1_machine_options,PC_COMPAT_1_1 );#define PC_COMPAT_1_0 \
@@ -716,23 +745,27 @@ DEFINE_PC_MACHINE(v1_1, "pc-1.1", pc_init_pci_1_2, .value = "no",\ }, -#define PC_I440FX_1_0_MACHINE_OPTIONS \ - PC_I440FX_1_1_MACHINE_OPTIONS, \ - .hw_version = "1.0" +static void pc_i440fx_1_0_machine_options (QEMUMachine *m) +{ +pc_i440fx_1_1_machine_options (m); + m->hw_version ="1.0" ; +}DEFINE_PC_MACHINE (v1_0,"pc-1.0" , pc_init_pci_1_2, -PC_I440FX_1_0_MACHINE_OPTIONS ,PC_COMPAT_1_0 ); + pc_i440fx_1_0_machine_options,PC_COMPAT_1_0 );#define PC_COMPAT_0_15 \ PC_COMPAT_1_0 -#define PC_I440FX_0_15_MACHINE_OPTIONS \ - PC_I440FX_1_0_MACHINE_OPTIONS, \ - .hw_version = "0.15" +static void pc_i440fx_0_15_machine_options (QEMUMachine *m) +{ +pc_i440fx_1_0_machine_options (m); + m->hw_version ="0.15" ; +}DEFINE_PC_MACHINE (v0_15,"pc-0.15" , pc_init_pci_1_2, -PC_I440FX_0_15_MACHINE_OPTIONS ,PC_COMPAT_0_15 ); + pc_i440fx_0_15_machine_options,PC_COMPAT_0_15 );#define PC_COMPAT_0_14 \
@@ -763,12 +796,14 @@ DEFINE_PC_MACHINE(v0_15, "pc-0.15", pc_init_pci_1_2, .value = stringify(2),\ }, -#define PC_I440FX_0_14_MACHINE_OPTIONS \ - PC_I440FX_0_15_MACHINE_OPTIONS, \ - .hw_version = "0.14" +static void pc_i440fx_0_14_machine_options (QEMUMachine *m) +{ +pc_i440fx_0_15_machine_options (m); + m->hw_version ="0.14" ; +}DEFINE_PC_MACHINE (v0_14,"pc-0.14" , pc_init_pci_1_2, -PC_I440FX_0_14_MACHINE_OPTIONS ,PC_COMPAT_0_14 ); + pc_i440fx_0_14_machine_options,PC_COMPAT_0_14 );#define PC_COMPAT_0_13 \
@@ -795,12 +830,14 @@ DEFINE_PC_MACHINE(v0_14, "pc-0.14", pc_init_pci_1_2, .value = stringify(0),\ }, -#define PC_I440FX_0_13_MACHINE_OPTIONS \ - PC_I440FX_0_14_MACHINE_OPTIONS, \ - .hw_version = "0.13" +static void pc_i440fx_0_13_machine_options (QEMUMachine *m) +{ +pc_i440fx_0_14_machine_options (m); + m->hw_version ="0.13" ; +}DEFINE_PC_MACHINE (v0_13,"pc-0.13" , pc_init_pci_no_kvmclock, -PC_I440FX_0_13_MACHINE_OPTIONS ,PC_COMPAT_0_13 ); + pc_i440fx_0_13_machine_options,PC_COMPAT_0_13 );#define PC_COMPAT_0_12 \
@@ -827,12 +864,14 @@ DEFINE_PC_MACHINE(v0_13, "pc-0.13", pc_init_pci_no_kvmclock, .value = "1",\ }, -#define PC_I440FX_0_12_MACHINE_OPTIONS \ - PC_I440FX_0_13_MACHINE_OPTIONS, \ - .hw_version = "0.12" +static void pc_i440fx_0_12_machine_options (QEMUMachine *m) +{ +pc_i440fx_0_13_machine_options (m); + m->hw_version ="0.12" ; +}DEFINE_PC_MACHINE (v0_12,"pc-0.12" , pc_init_pci_no_kvmclock, -PC_I440FX_0_12_MACHINE_OPTIONS ,PC_COMPAT_0_12 ); + pc_i440fx_0_12_machine_options,PC_COMPAT_0_12 );#define PC_COMPAT_0_11 \
@@ -855,12 +894,14 @@ DEFINE_PC_MACHINE(v0_12, "pc-0.12", pc_init_pci_no_kvmclock, .value = "0.11",\ }, -#define PC_I440FX_0_11_MACHINE_OPTIONS \ - PC_I440FX_0_12_MACHINE_OPTIONS, \ - .hw_version = "0.11" +static void pc_i440fx_0_11_machine_options (QEMUMachine *m) +{ +pc_i440fx_0_12_machine_options (m); + m->hw_version ="0.11" ; +}DEFINE_PC_MACHINE (v0_11,"pc-0.11" , pc_init_pci_no_kvmclock, -PC_I440FX_0_11_MACHINE_OPTIONS ,PC_COMPAT_0_11 ); + pc_i440fx_0_11_machine_options,PC_COMPAT_0_11 );#define PC_COMPAT_0_10 \
@@ -887,31 +928,37 @@ DEFINE_PC_MACHINE(v0_11, "pc-0.11", pc_init_pci_no_kvmclock, .value = "0.10",\ }, -#define PC_I440FX_0_10_MACHINE_OPTIONS \ - PC_I440FX_0_11_MACHINE_OPTIONS, \ - .hw_version = "0.10" +static void pc_i440fx_0_10_machine_options (QEMUMachine *m) +{ +pc_i440fx_0_11_machine_options (m); + m->hw_version ="0.10" ; +}DEFINE_PC_MACHINE (v0_10,"pc-0.10" , pc_init_pci_no_kvmclock, -PC_I440FX_0_10_MACHINE_OPTIONS ,PC_COMPAT_0_10 ); + pc_i440fx_0_10_machine_options,PC_COMPAT_0_10 ); -#define ISAPC_MACHINE_OPTIONS \ - PC_COMMON_MACHINE_OPTIONS, \ - .desc = "ISA-only PC", \ - .max_cpus = 1 +static void isapc_machine_options (QEMUMachine *m) +{ +pc_common_machine_options (m); + m->desc ="ISA-only PC" ; + m->max_cpus =1 ; +}DEFINE_PC_MACHINE (isapc,"isapc" , pc_init_isa, - ISAPC_MACHINE_OPTIONS, /* no compat */); + isapc_machine_options, /* no compat */);#ifdef CONFIG_XEN -#define XENFV_MACHINE_OPTIONS \ - PC_COMMON_MACHINE_OPTIONS, \ - .desc = "Xen Fully-virtualized PC", \ - .max_cpus = HVM_MAX_VCPUS, \ - .default_machine_opts = "accel=xen", \ - .hot_add_cpu = pc_hot_add_cpu +static void xenfv_machine_options (QEMUMachine *m) +{ +pc_common_machine_options (m); + m->desc ="Xen Fully-virtualized PC" ; + m->max_cpus =HVM_MAX_VCPUS ; + m->default_machine_opts ="accel=xen" ; + m->hot_add_cpu = pc_hot_add_cpu; +}DEFINE_PC_MACHINE (xenfv,"xenfv" , pc_xen_hvm_init, - XENFV_MACHINE_OPTIONS, /* no compat */); + xenfv_machine_options, /* no compat */);#endif
hw/i386/pc_q35.c +61 -41
139 lines not on this page · raw message
include/hw/i386/pc.h +23 -19
50 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 4/10 pc: Move compat_props setting inside *_machine_options() functions
In reply to Eduardo HabkostThis will simplify the DEFINE_PC_MACHINE macro, and will help us to implement reuse of PC_COMPAT_* macros through class_init function reuse, in the future.
--- hw/i386/pc_piix.c | 60 ++++++++++++++++++++++++++++++++++------------------ hw/i386/pc_q35.c | 26 +++++++++++++++-------- include/hw/i386/pc.h | 15 +++++++------ 3 files changed, 65 insertions(+), 36 deletions(-)
hw/i386/pc_piix.c +39 -21
@@ -536,7 +536,7 @@ static void pc_i440fx_2_4_machine_options(QEMUMachine *m) }DEFINE_PC_MACHINE (v2_4,"pc-i440fx-2.4" , pc_init_pci, - pc_i440fx_2_4_machine_options, /* no compat */) + pc_i440fx_2_4_machine_options)static void pc_i440fx_2_3_machine_options (QEMUMachine *m)
@@ -544,77 +544,85 @@ static void pc_i440fx_2_3_machine_options(QEMUMachine *m)pc_i440fx_machine_options (m); m->alias =NULL ; m->is_default =0 ; +SET_MACHINE_COMPAT (m,PC_COMPAT_2_3 ); }DEFINE_PC_MACHINE (v2_3,"pc-i440fx-2.3" , pc_init_pci_2_3, - pc_i440fx_2_3_machine_options,PC_COMPAT_2_3 ); + pc_i440fx_2_3_machine_options);static void pc_i440fx_2_2_machine_options (QEMUMachine *m) {pc_i440fx_2_3_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_2_2 ); }DEFINE_PC_MACHINE (v2_2,"pc-i440fx-2.2" , pc_init_pci_2_2, - pc_i440fx_2_2_machine_options,PC_COMPAT_2_2 ); + pc_i440fx_2_2_machine_options);static void pc_i440fx_2_1_machine_options (QEMUMachine *m) {pc_i440fx_2_2_machine_options (m); m->default_display =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_2_1 ); }DEFINE_PC_MACHINE (v2_1,"pc-i440fx-2.1" , pc_init_pci_2_1, - pc_i440fx_2_1_machine_options,PC_COMPAT_2_1 ); + pc_i440fx_2_1_machine_options);static void pc_i440fx_2_0_machine_options (QEMUMachine *m) {pc_i440fx_2_1_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_2_0 ); }DEFINE_PC_MACHINE (v2_0,"pc-i440fx-2.0" , pc_init_pci_2_0, - pc_i440fx_2_0_machine_options,PC_COMPAT_2_0 ); + pc_i440fx_2_0_machine_options);static void pc_i440fx_1_7_machine_options (QEMUMachine *m) {pc_i440fx_2_0_machine_options (m); m->default_machine_opts =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_1_7 ); }DEFINE_PC_MACHINE (v1_7,"pc-i440fx-1.7" , pc_init_pci_1_7, - pc_i440fx_1_7_machine_options,PC_COMPAT_1_7 ); + pc_i440fx_1_7_machine_options);static void pc_i440fx_1_6_machine_options (QEMUMachine *m) {pc_i440fx_1_7_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_1_6 ); }DEFINE_PC_MACHINE (v1_6,"pc-i440fx-1.6" , pc_init_pci_1_6, - pc_i440fx_1_6_machine_options,PC_COMPAT_1_6 ); + pc_i440fx_1_6_machine_options);static void pc_i440fx_1_5_machine_options (QEMUMachine *m) {pc_i440fx_1_6_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_1_5 ); }DEFINE_PC_MACHINE (v1_5,"pc-i440fx-1.5" , pc_init_pci_1_5, - pc_i440fx_1_5_machine_options,PC_COMPAT_1_5 ); + pc_i440fx_1_5_machine_options);static void pc_i440fx_1_4_machine_options (QEMUMachine *m) {pc_i440fx_1_5_machine_options (m); m->hot_add_cpu =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_1_4 ); }DEFINE_PC_MACHINE (v1_4,"pc-i440fx-1.4" , pc_init_pci_1_4, - pc_i440fx_1_4_machine_options,PC_COMPAT_1_4 ); + pc_i440fx_1_4_machine_options);#define PC_COMPAT_1_3 \
@@ -641,10 +649,11 @@ DEFINE_PC_MACHINE(v1_4, "pc-i440fx-1.4", pc_init_pci_1_4,static void pc_i440fx_1_3_machine_options (QEMUMachine *m) {pc_i440fx_1_4_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_1_3 ); }DEFINE_PC_MACHINE (v1_3,"pc-1.3" , pc_init_pci_1_3, - pc_i440fx_1_3_machine_options,PC_COMPAT_1_3 ); + pc_i440fx_1_3_machine_options);#define PC_COMPAT_1_2 \
@@ -678,10 +687,11 @@ DEFINE_PC_MACHINE(v1_3, "pc-1.3", pc_init_pci_1_3,static void pc_i440fx_1_2_machine_options (QEMUMachine *m) {pc_i440fx_1_3_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_1_2 ); }DEFINE_PC_MACHINE (v1_2,"pc-1.2" , pc_init_pci_1_2, - pc_i440fx_1_2_machine_options,PC_COMPAT_1_2 ); + pc_i440fx_1_2_machine_options);#define PC_COMPAT_1_1 \
@@ -719,10 +729,11 @@ DEFINE_PC_MACHINE(v1_2, "pc-1.2", pc_init_pci_1_2,static void pc_i440fx_1_1_machine_options (QEMUMachine *m) {pc_i440fx_1_2_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_1_1 ); }DEFINE_PC_MACHINE (v1_1,"pc-1.1" , pc_init_pci_1_2, - pc_i440fx_1_1_machine_options,PC_COMPAT_1_1 ); + pc_i440fx_1_1_machine_options);#define PC_COMPAT_1_0 \
@@ -749,10 +760,11 @@ static void pc_i440fx_1_0_machine_options(QEMUMachine *m) {pc_i440fx_1_1_machine_options (m); m->hw_version ="1.0" ; +SET_MACHINE_COMPAT (m,PC_COMPAT_1_0 ); }DEFINE_PC_MACHINE (v1_0,"pc-1.0" , pc_init_pci_1_2, - pc_i440fx_1_0_machine_options,PC_COMPAT_1_0 ); + pc_i440fx_1_0_machine_options);#define PC_COMPAT_0_15 \
@@ -762,10 +774,11 @@ static void pc_i440fx_0_15_machine_options(QEMUMachine *m) {pc_i440fx_1_0_machine_options (m); m->hw_version ="0.15" ; +SET_MACHINE_COMPAT (m,PC_COMPAT_0_15 ); }DEFINE_PC_MACHINE (v0_15,"pc-0.15" , pc_init_pci_1_2, - pc_i440fx_0_15_machine_options,PC_COMPAT_0_15 ); + pc_i440fx_0_15_machine_options);#define PC_COMPAT_0_14 \
@@ -800,10 +813,11 @@ static void pc_i440fx_0_14_machine_options(QEMUMachine *m) {pc_i440fx_0_15_machine_options (m); m->hw_version ="0.14" ; +SET_MACHINE_COMPAT (m,PC_COMPAT_0_14 ); }DEFINE_PC_MACHINE (v0_14,"pc-0.14" , pc_init_pci_1_2, - pc_i440fx_0_14_machine_options,PC_COMPAT_0_14 ); + pc_i440fx_0_14_machine_options);#define PC_COMPAT_0_13 \
@@ -834,10 +848,11 @@ static void pc_i440fx_0_13_machine_options(QEMUMachine *m) {pc_i440fx_0_14_machine_options (m); m->hw_version ="0.13" ; +SET_MACHINE_COMPAT (m,PC_COMPAT_0_13 ); }DEFINE_PC_MACHINE (v0_13,"pc-0.13" , pc_init_pci_no_kvmclock, - pc_i440fx_0_13_machine_options,PC_COMPAT_0_13 ); + pc_i440fx_0_13_machine_options);#define PC_COMPAT_0_12 \
@@ -868,10 +883,11 @@ static void pc_i440fx_0_12_machine_options(QEMUMachine *m) {pc_i440fx_0_13_machine_options (m); m->hw_version ="0.12" ; +SET_MACHINE_COMPAT (m,PC_COMPAT_0_12 ); }DEFINE_PC_MACHINE (v0_12,"pc-0.12" , pc_init_pci_no_kvmclock, - pc_i440fx_0_12_machine_options,PC_COMPAT_0_12 ); + pc_i440fx_0_12_machine_options);#define PC_COMPAT_0_11 \
@@ -898,10 +914,11 @@ static void pc_i440fx_0_11_machine_options(QEMUMachine *m) {pc_i440fx_0_12_machine_options (m); m->hw_version ="0.11" ; +SET_MACHINE_COMPAT (m,PC_COMPAT_0_11 ); }DEFINE_PC_MACHINE (v0_11,"pc-0.11" , pc_init_pci_no_kvmclock, - pc_i440fx_0_11_machine_options,PC_COMPAT_0_11 ); + pc_i440fx_0_11_machine_options);#define PC_COMPAT_0_10 \
@@ -932,10 +949,11 @@ static void pc_i440fx_0_10_machine_options(QEMUMachine *m) {pc_i440fx_0_11_machine_options (m); m->hw_version ="0.10" ; +SET_MACHINE_COMPAT (m,PC_COMPAT_0_10 ); }DEFINE_PC_MACHINE (v0_10,"pc-0.10" , pc_init_pci_no_kvmclock, - pc_i440fx_0_10_machine_options,PC_COMPAT_0_10 ); + pc_i440fx_0_10_machine_options);static void isapc_machine_options (QEMUMachine *m)
@@ -946,7 +964,7 @@ static void isapc_machine_options(QEMUMachine *m) }DEFINE_PC_MACHINE (isapc,"isapc" , pc_init_isa, - isapc_machine_options, /* no compat */); + isapc_machine_options);#ifdef CONFIG_XEN
@@ -960,5 +978,5 @@ static void xenfv_machine_options(QEMUMachine *m) }DEFINE_PC_MACHINE (xenfv,"xenfv" , pc_xen_hvm_init, - xenfv_machine_options, /* no compat */); + xenfv_machine_options);#endif
hw/i386/pc_q35.c +17 -9
@@ -432,80 +432,88 @@ static void pc_q35_2_4_machine_options(QEMUMachine *m) }DEFINE_PC_MACHINE (v2_4,"pc-q35-2.4" , pc_q35_init, - pc_q35_2_4_machine_options, /* no compat */); + pc_q35_2_4_machine_options);static void pc_q35_2_3_machine_options (QEMUMachine *m) {pc_q35_2_4_machine_options (m); m->alias =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_2_3 ); }DEFINE_PC_MACHINE (v2_3,"pc-q35-2.3" , pc_q35_init_2_3, - pc_q35_2_3_machine_options,PC_COMPAT_2_3 ); + pc_q35_2_3_machine_options);static void pc_q35_2_2_machine_options (QEMUMachine *m) {pc_q35_2_3_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_2_2 ); }DEFINE_PC_MACHINE (v2_2,"pc-q35-2.2" , pc_q35_init_2_2, - pc_q35_2_2_machine_options,PC_COMPAT_2_2 ); + pc_q35_2_2_machine_options);static void pc_q35_2_1_machine_options (QEMUMachine *m) {pc_q35_2_2_machine_options (m); m->default_display =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_2_1 ); }DEFINE_PC_MACHINE (v2_1,"pc-q35-2.1" , pc_q35_init_2_1, - pc_q35_2_1_machine_options,PC_COMPAT_2_1 ); + pc_q35_2_1_machine_options);static void pc_q35_2_0_machine_options (QEMUMachine *m) {pc_q35_2_1_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_2_0 ); }DEFINE_PC_MACHINE (v2_0,"pc-q35-2.0" , pc_q35_init_2_0, - pc_q35_2_0_machine_options,PC_COMPAT_2_0 ); + pc_q35_2_0_machine_options);static void pc_q35_1_7_machine_options (QEMUMachine *m) {pc_q35_2_0_machine_options (m); m->default_machine_opts =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_1_7 ); }DEFINE_PC_MACHINE (v1_7,"pc-q35-1.7" , pc_q35_init_1_7, - pc_q35_1_7_machine_options,PC_COMPAT_1_7 ); + pc_q35_1_7_machine_options);static void pc_q35_1_6_machine_options (QEMUMachine *m) {pc_q35_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_1_6 ); }DEFINE_PC_MACHINE (v1_6,"pc-q35-1.6" , pc_q35_init_1_6, - pc_q35_1_6_machine_options,PC_COMPAT_1_6 ); + pc_q35_1_6_machine_options);static void pc_q35_1_5_machine_options (QEMUMachine *m) {pc_q35_1_6_machine_options (m); +SET_MACHINE_COMPAT (m,PC_COMPAT_1_5 ); }DEFINE_PC_MACHINE (v1_5,"pc-q35-1.5" , pc_q35_init_1_5, - pc_q35_1_5_machine_options,PC_COMPAT_1_5 ); + pc_q35_1_5_machine_options);static void pc_q35_1_4_machine_options (QEMUMachine *m) {pc_q35_1_5_machine_options (m); m->hot_add_cpu =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_1_4 ); }DEFINE_PC_MACHINE (v1_4,"pc-q35-1.4" , pc_q35_init_1_4, - pc_q35_1_4_machine_options,PC_COMPAT_1_4 ); + pc_q35_1_4_machine_options);
include/hw/i386/pc.h +9 -6
@@ -529,20 +529,23 @@ static inline void pc_default_machine_options(QEMUMachine *m) m->max_cpus =255 ; } -#define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn, COMPAT) \ +#define DEFINE_PC_MACHINE (suffix, namestr, initfn, optsfn) \ static void pc_machine_init_##suffix(void) \ { \ static QEMUMachine m = { }; \ - static GlobalProperty props[] = { \ - COMPAT \ - { /* end of list */ } \ - }; \ optsfn(&m); \ m.name = namestr; \ m.init = initfn; \ - m.compat_props = props; \ qemu_register_pc_machine(&m); \ } \ machine_init(pc_machine_init_##suffix) +#define SET_MACHINE_COMPAT(m, COMPAT) do { \ + static GlobalProperty props[] = { \ + COMPAT \ + { /* end of list */ } \ + }; \ + (m)->compat_props = props; \ +} while (0) +#endif
Signature · 1 line
2.1.0
PATCH 5/10 pc: Don't use QEMUMachine anymore
In reply to Eduardo HabkostNow 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.
--- hw/i386/pc_piix.c | 44 ++++++++++++++++++++++---------------------- hw/i386/pc_q35.c | 20 ++++++++++---------- include/hw/i386/pc.h | 22 +++++++++++++++------- 3 files changed, 47 insertions(+), 39 deletions(-)
hw/i386/pc_piix.c +22 -22
@@ -518,7 +518,7 @@ 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" ;
@@ -526,7 +526,7 @@ static void pc_i440fx_machine_options(QEMUMachine *m) 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" ;
@@ -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 ;
@@ -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 );
@@ -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 ;
@@ -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 );
@@ -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 ;
@@ -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 );
@@ -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 );
@@ -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 ;
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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" ;
@@ -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" ;
@@ -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" ;
@@ -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" ;
@@ -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" ;
@@ -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" ;
@@ -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" ;
@@ -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" ;
@@ -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" ;
hw/i386/pc_q35.c +10 -10
@@ -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" ;
@@ -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" ;
@@ -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 ;
@@ -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 );
@@ -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 ;
@@ -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 );
@@ -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 ;
@@ -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 );
@@ -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 );
@@ -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 ;
include/hw/i386/pc.h +15 -7
@@ -517,12 +517,12 @@ 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;
@@ -530,13 +530,21 @@ static inline void pc_default_machine_options(QEMUMachine *m) }#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)
Signature · 1 line
2.1.0
PATCH 6/10 pc: Remove qemu_register_pc_machine() function
In reply to Eduardo HabkostThe helper is not needed anymore, as the PC machine classes are registered using QOM directly.
--- hw/i386/pc.c | 45 --------------------------------------------- include/hw/i386/pc.h | 2 -- 2 files changed, 47 deletions(-)
hw/i386/pc.c +0 -45
@@ -1543,51 +1543,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->family = qm->family; - 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->units_per_default_bus = qm->units_per_default_bus; - 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->default_display = qm->default_display; - mc->compat_props = qm->compat_props; - mc->hw_version = qm->hw_version; -} - -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) {
include/hw/i386/pc.h +0 -2
@@ -73,8 +73,6 @@ typedef struct PCMachineClass PCMachineClass;#define PC_MACHINE_CLASS (klass) \ OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE) -void qemu_register_pc_machine (QEMUMachine *m); -/* PC-style peripherals (also used by other machines). */ typedef struct PcPciInfo {
Signature · 1 line
2.1.0
PATCH 7/10 machine: Remove unused fields from QEMUMachine
In reply to Eduardo HabkostThis removes the following fields from QEMUMachine: family, alias, reset, hot_add_cpu, units_per_default_bus, no_serial, no_parallel, use_virtcon, use_sclp, no_floppy, no_cdrom, default_display, compat_props, and hw_version.
The only users of those fields were already converted to use QOM and MachineClass directly, so they are not needed anymore.
--- include/hw/boards.h | 15 +-------------- vl.c | 15 --------------- 2 files changed, 1 insertion(+), 29 deletions(-)
include/hw/boards.h +1 -14
@@ -19,31 +19,18 @@ typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp);typedef int QEMUMachineGetKvmtypeFunc (const char *arg);struct QEMUMachine { -const char *family;/* NULL iff @name identifies a standalone machtype */ const char *name; -const char *alias;const char *desc;QEMUMachineInitFunc *init; -QEMUMachineResetFunc *reset; -QEMUMachineHotAddCPUFunc *hot_add_cpu;QEMUMachineGetKvmtypeFunc *kvm_type;BlockInterfaceType block_default_type; -int units_per_default_bus;int max_cpus; -unsigned int no_serial:1 , - no_parallel:1 , - use_virtcon:1 , - use_sclp:1 , - no_floppy:1 , - no_cdrom:1 , +unsigned int no_sdcard:1 , has_dynamic_sysbus:1 ;int is_default;const char *default_machine_opts;const char *default_boot_order; -const char *default_display; -GlobalProperty *compat_props; -const char *hw_version; }; void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
vl.c +0 -15
@@ -1314,32 +1314,17 @@ static void machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc);QEMUMachine *qm = data; - - mc->family = qm->family; 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->units_per_default_bus = qm->units_per_default_bus; 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->has_dynamic_sysbus = qm->has_dynamic_sysbus; mc->is_default = qm->is_default; mc->default_machine_opts = qm->default_machine_opts; mc->default_boot_order = qm->default_boot_order; - mc->default_display = qm->default_display; - mc->compat_props = qm->compat_props; - mc->hw_version = qm->hw_version; }int qemu_register_machine (QEMUMachine *m)
Signature · 1 line
2.1.0
PATCH 8/10 piix: Add kvmclock_enabled, pci_enabled globals
In reply to Eduardo HabkostThis looks like a step backwards, but it will allow pc-0.1[0123] and isapc to follow the same compat+init pattern used by the other machine-types, allowing us to generate all init function using the same macro later.
--- hw/i386/pc_piix.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
hw/i386/pc_piix.c +15 -7
@@ -59,6 +59,7 @@ static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };static const int ide_iobase2[MAX_IDE_BUS ] = {0x3f6 ,0x376 };static const int ide_irq[MAX_IDE_BUS ] = {14 ,15 }; +static bool pci_enabled = true;static bool has_acpi_build = true;static bool rsdp_in_ram = true;static int legacy_acpi_table_size;
@@ -71,11 +72,10 @@ static bool smbios_uuid_encoded = true;*/ static bool gigabyte_align = true;static bool has_reserved_memory = true; +static bool kvmclock_enabled = true;/* PC hardware initialisation */ -static void pc_init1 (MachineState *machine, -int pci_enabled, -int kvmclock_enabled) +static void pc_init1 (MachineState *machine) {PCMachineState *pc_machine =PC_MACHINE (machine);MemoryRegion *system_memory =get_system_memory ();
@@ -307,7 +307,7 @@ static void pc_init1(MachineState *machine,static void pc_init_pci (MachineState *machine) { -pc_init1 (machine,1 ,1 ); +pc_init1 (machine); }static void pc_compat_2_3 (MachineState *machine)
@@ -430,6 +430,13 @@ static void pc_init_pci_2_2(MachineState *machine)pc_init_pci (machine); } +/* PC compat function for pc-0.10 to pc-0.13 */ +static void pc_compat_0_13 (MachineState *machine) +{ +pc_compat_1_2 (machine); + kvmclock_enabled = false; +} +static void pc_init_pci_2_1 (MachineState *machine) {pc_compat_2_1 (machine);
@@ -482,12 +489,13 @@ static void pc_init_pci_1_2(MachineState *machine)/* PC init function for pc-0.10 to pc-0.13 */ static void pc_init_pci_no_kvmclock (MachineState *machine) { -pc_compat_1_2 (machine); -pc_init1 (machine,1 ,0 ); +pc_compat_0_13 (machine); +pc_init_pci (machine); }static void pc_init_isa (MachineState *machine) { + pci_enabled = false; has_acpi_build = false; smbios_defaults = false; gigabyte_align = false;
@@ -500,7 +508,7 @@ static void pc_init_isa(MachineState *machine) }x86_cpu_compat_kvm_no_autoenable (FEAT_KVM ,1 <<KVM_FEATURE_PV_EOI );enable_compat_apic_id_mode (); -pc_init1 (machine,0 ,1 ); +pc_init1 (machine); }#ifdef CONFIG_XEN
Signature · 1 line
2.1.0
PATCH 9/10 piix: Eliminate pc_init_pci()
In reply to Eduardo HabkostThe function is not needed anymore, we can simply call pc_init1() directly.
--- hw/i386/pc_piix.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
hw/i386/pc_piix.c +13 -18
@@ -305,11 +305,6 @@ static void pc_init1(MachineState *machine) } } -static void pc_init_pci (MachineState *machine) -{ -pc_init1 (machine); -} -static void pc_compat_2_3 (MachineState *machine) { }
@@ -421,13 +416,13 @@ static void pc_compat_1_2(MachineState *machine)static void pc_init_pci_2_3 (MachineState *machine) {pc_compat_2_3 (machine); -pc_init_pci (machine); +pc_init1 (machine); }static void pc_init_pci_2_2 (MachineState *machine) {pc_compat_2_2 (machine); -pc_init_pci (machine); +pc_init1 (machine); }/* PC compat function for pc-0.10 to pc-0.13 */
@@ -440,57 +435,57 @@ static void pc_compat_0_13(MachineState *machine)static void pc_init_pci_2_1 (MachineState *machine) {pc_compat_2_1 (machine); -pc_init_pci (machine); +pc_init1 (machine); }static void pc_init_pci_2_0 (MachineState *machine) {pc_compat_2_0 (machine); -pc_init_pci (machine); +pc_init1 (machine); }static void pc_init_pci_1_7 (MachineState *machine) {pc_compat_1_7 (machine); -pc_init_pci (machine); +pc_init1 (machine); }static void pc_init_pci_1_6 (MachineState *machine) {pc_compat_1_6 (machine); -pc_init_pci (machine); +pc_init1 (machine); }static void pc_init_pci_1_5 (MachineState *machine) {pc_compat_1_5 (machine); -pc_init_pci (machine); +pc_init1 (machine); }static void pc_init_pci_1_4 (MachineState *machine) {pc_compat_1_4 (machine); -pc_init_pci (machine); +pc_init1 (machine); }static void pc_init_pci_1_3 (MachineState *machine) {pc_compat_1_3 (machine); -pc_init_pci (machine); +pc_init1 (machine); }/* PC machine init function for pc-0.14 to pc-1.2 */ static void pc_init_pci_1_2 (MachineState *machine) {pc_compat_1_2 (machine); -pc_init_pci (machine); +pc_init1 (machine); }/* PC init function for pc-0.10 to pc-0.13 */ static void pc_init_pci_no_kvmclock (MachineState *machine) {pc_compat_0_13 (machine); -pc_init_pci (machine); +pc_init1 (machine); }static void pc_init_isa (MachineState *machine)
@@ -516,7 +511,7 @@ static void pc_xen_hvm_init(MachineState *machine) {PCIBus *bus; -pc_init_pci (machine); +pc_init1 (machine); bus =pci_find_primary_bus ();if (bus !=NULL ) {
@@ -543,7 +538,7 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m) m->is_default =1 ; } -DEFINE_PC_MACHINE (v2_4,"pc-i440fx-2.4" , pc_init_pci, +DEFINE_PC_MACHINE (v2_4,"pc-i440fx-2.4" , pc_init1, pc_i440fx_2_4_machine_options)
Signature · 1 line
2.1.0
PATCH 10/10 pc: Generate init functions with a macro
In reply to Eduardo HabkostAll pc-i440fx and pc-q35 init functions simply call the corresponding compat function and then call the main init function. Use a macro to generate that code.
--- hw/i386/pc_piix.c | 154 +++++++++++++++++------------------------------------- hw/i386/pc_q35.c | 92 ++++++++++---------------------- 2 files changed, 76 insertions(+), 170 deletions(-)
hw/i386/pc_piix.c +48 -106
@@ -413,18 +413,6 @@ static void pc_compat_1_2(MachineState *machine)x86_cpu_compat_kvm_no_autoenable (FEAT_KVM ,1 <<KVM_FEATURE_PV_EOI ); } -static void pc_init_pci_2_3 (MachineState *machine) -{ -pc_compat_2_3 (machine); -pc_init1 (machine); -} - -static void pc_init_pci_2_2 (MachineState *machine) -{ -pc_compat_2_2 (machine); -pc_init1 (machine); -} -/* PC compat function for pc-0.10 to pc-0.13 */ static void pc_compat_0_13 (MachineState *machine) {
@@ -432,62 +420,6 @@ static void pc_compat_0_13(MachineState *machine) kvmclock_enabled = false; } -static void pc_init_pci_2_1 (MachineState *machine) -{ -pc_compat_2_1 (machine); -pc_init1 (machine); -} - -static void pc_init_pci_2_0 (MachineState *machine) -{ -pc_compat_2_0 (machine); -pc_init1 (machine); -} - -static void pc_init_pci_1_7 (MachineState *machine) -{ -pc_compat_1_7 (machine); -pc_init1 (machine); -} - -static void pc_init_pci_1_6 (MachineState *machine) -{ -pc_compat_1_6 (machine); -pc_init1 (machine); -} - -static void pc_init_pci_1_5 (MachineState *machine) -{ -pc_compat_1_5 (machine); -pc_init1 (machine); -} - -static void pc_init_pci_1_4 (MachineState *machine) -{ -pc_compat_1_4 (machine); -pc_init1 (machine); -} - -static void pc_init_pci_1_3 (MachineState *machine) -{ -pc_compat_1_3 (machine); -pc_init1 (machine); -} - -/* PC machine init function for pc-0.14 to pc-1.2 */ -static void pc_init_pci_1_2 (MachineState *machine) -{ -pc_compat_1_2 (machine); -pc_init1 (machine); -} - -/* PC init function for pc-0.10 to pc-0.13 */ -static void pc_init_pci_no_kvmclock (MachineState *machine) -{ -pc_compat_0_13 (machine); -pc_init1 (machine); -} -static void pc_init_isa (MachineState *machine) { pci_enabled = false;
@@ -520,6 +452,16 @@ static void pc_xen_hvm_init(MachineState *machine) }#endif +#define DEFINE_I440FX_MACHINE (suffix, name, compatfn, optionfn) \ + static void pc_init_##suffix(MachineState *machine) \ + { \ + void (*compat)(MachineState *m) = (compatfn); \ + if (compat) { \ + compat(machine); \ + } \ + pc_init1(machine); \ + } \ + DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)static void pc_i440fx_machine_options (MachineClass *m) {
@@ -538,8 +480,8 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m) m->is_default =1 ; } -DEFINE_PC_MACHINE (v2_4,"pc-i440fx-2.4" , pc_init1, - pc_i440fx_2_4_machine_options) +DEFINE_I440FX_MACHINE (v2_4,"pc-i440fx-2.4" ,NULL , + pc_i440fx_2_4_machine_options)static void pc_i440fx_2_3_machine_options (MachineClass *m)
@@ -550,8 +492,8 @@ static void pc_i440fx_2_3_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_2_3 ); } -DEFINE_PC_MACHINE (v2_3,"pc-i440fx-2.3" , pc_init_pci_2_3, - pc_i440fx_2_3_machine_options); +DEFINE_I440FX_MACHINE (v2_3,"pc-i440fx-2.3" , pc_compat_2_3, + pc_i440fx_2_3_machine_options);static void pc_i440fx_2_2_machine_options (MachineClass *m)
@@ -560,8 +502,8 @@ static void pc_i440fx_2_2_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_2_2 ); } -DEFINE_PC_MACHINE (v2_2,"pc-i440fx-2.2" , pc_init_pci_2_2, - pc_i440fx_2_2_machine_options); +DEFINE_I440FX_MACHINE (v2_2,"pc-i440fx-2.2" , pc_compat_2_2, + pc_i440fx_2_2_machine_options);static void pc_i440fx_2_1_machine_options (MachineClass *m)
@@ -571,8 +513,8 @@ static void pc_i440fx_2_1_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_2_1 ); } -DEFINE_PC_MACHINE (v2_1,"pc-i440fx-2.1" , pc_init_pci_2_1, - pc_i440fx_2_1_machine_options); +DEFINE_I440FX_MACHINE (v2_1,"pc-i440fx-2.1" , pc_compat_2_1, + pc_i440fx_2_1_machine_options);
@@ -582,8 +524,8 @@ static void pc_i440fx_2_0_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_2_0 ); } -DEFINE_PC_MACHINE (v2_0,"pc-i440fx-2.0" , pc_init_pci_2_0, - pc_i440fx_2_0_machine_options); +DEFINE_I440FX_MACHINE (v2_0,"pc-i440fx-2.0" , pc_compat_2_0, + pc_i440fx_2_0_machine_options);static void pc_i440fx_1_7_machine_options (MachineClass *m)
@@ -593,8 +535,8 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_1_7 ); } -DEFINE_PC_MACHINE (v1_7,"pc-i440fx-1.7" , pc_init_pci_1_7, - pc_i440fx_1_7_machine_options); +DEFINE_I440FX_MACHINE (v1_7,"pc-i440fx-1.7" , pc_compat_1_7, + pc_i440fx_1_7_machine_options);static void pc_i440fx_1_6_machine_options (MachineClass *m)
@@ -603,8 +545,8 @@ static void pc_i440fx_1_6_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_1_6 ); } -DEFINE_PC_MACHINE (v1_6,"pc-i440fx-1.6" , pc_init_pci_1_6, - pc_i440fx_1_6_machine_options); +DEFINE_I440FX_MACHINE (v1_6,"pc-i440fx-1.6" , pc_compat_1_6, + pc_i440fx_1_6_machine_options);static void pc_i440fx_1_5_machine_options (MachineClass *m)
@@ -613,8 +555,8 @@ static void pc_i440fx_1_5_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_1_5 ); } -DEFINE_PC_MACHINE (v1_5,"pc-i440fx-1.5" , pc_init_pci_1_5, - pc_i440fx_1_5_machine_options); +DEFINE_I440FX_MACHINE (v1_5,"pc-i440fx-1.5" , pc_compat_1_5, + pc_i440fx_1_5_machine_options);static void pc_i440fx_1_4_machine_options (MachineClass *m)
@@ -624,8 +566,8 @@ static void pc_i440fx_1_4_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_1_4 ); } -DEFINE_PC_MACHINE (v1_4,"pc-i440fx-1.4" , pc_init_pci_1_4, - pc_i440fx_1_4_machine_options); +DEFINE_I440FX_MACHINE (v1_4,"pc-i440fx-1.4" , pc_compat_1_4, + pc_i440fx_1_4_machine_options);#define PC_COMPAT_1_3 \
@@ -655,8 +597,8 @@ static void pc_i440fx_1_3_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_1_3 ); } -DEFINE_PC_MACHINE (v1_3,"pc-1.3" , pc_init_pci_1_3, - pc_i440fx_1_3_machine_options); +DEFINE_I440FX_MACHINE (v1_3,"pc-1.3" , pc_compat_1_3, + pc_i440fx_1_3_machine_options);#define PC_COMPAT_1_2 \
@@ -693,8 +635,8 @@ static void pc_i440fx_1_2_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_1_2 ); } -DEFINE_PC_MACHINE (v1_2,"pc-1.2" , pc_init_pci_1_2, - pc_i440fx_1_2_machine_options); +DEFINE_I440FX_MACHINE (v1_2,"pc-1.2" , pc_compat_1_2, + pc_i440fx_1_2_machine_options);#define PC_COMPAT_1_1 \
@@ -735,8 +677,8 @@ static void pc_i440fx_1_1_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_1_1 ); } -DEFINE_PC_MACHINE (v1_1,"pc-1.1" , pc_init_pci_1_2, - pc_i440fx_1_1_machine_options); +DEFINE_I440FX_MACHINE (v1_1,"pc-1.1" , pc_compat_1_2, + pc_i440fx_1_1_machine_options);#define PC_COMPAT_1_0 \
@@ -766,8 +708,8 @@ static void pc_i440fx_1_0_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_1_0 ); } -DEFINE_PC_MACHINE (v1_0,"pc-1.0" , pc_init_pci_1_2, - pc_i440fx_1_0_machine_options); +DEFINE_I440FX_MACHINE (v1_0,"pc-1.0" , pc_compat_1_2, + pc_i440fx_1_0_machine_options);#define PC_COMPAT_0_15 \
@@ -780,8 +722,8 @@ static void pc_i440fx_0_15_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_0_15 ); } -DEFINE_PC_MACHINE (v0_15,"pc-0.15" , pc_init_pci_1_2, - pc_i440fx_0_15_machine_options); +DEFINE_I440FX_MACHINE (v0_15,"pc-0.15" , pc_compat_1_2, + pc_i440fx_0_15_machine_options);#define PC_COMPAT_0_14 \
@@ -819,8 +761,8 @@ static void pc_i440fx_0_14_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_0_14 ); } -DEFINE_PC_MACHINE (v0_14,"pc-0.14" , pc_init_pci_1_2, - pc_i440fx_0_14_machine_options); +DEFINE_I440FX_MACHINE (v0_14,"pc-0.14" , pc_compat_1_2, + pc_i440fx_0_14_machine_options);#define PC_COMPAT_0_13 \
@@ -854,8 +796,8 @@ static void pc_i440fx_0_13_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_0_13 ); } -DEFINE_PC_MACHINE (v0_13,"pc-0.13" , pc_init_pci_no_kvmclock, - pc_i440fx_0_13_machine_options); +DEFINE_I440FX_MACHINE (v0_13,"pc-0.13" , pc_compat_0_13, + pc_i440fx_0_13_machine_options);#define PC_COMPAT_0_12 \
@@ -889,8 +831,8 @@ static void pc_i440fx_0_12_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_0_12 ); } -DEFINE_PC_MACHINE (v0_12,"pc-0.12" , pc_init_pci_no_kvmclock, - pc_i440fx_0_12_machine_options); +DEFINE_I440FX_MACHINE (v0_12,"pc-0.12" , pc_compat_0_13, + pc_i440fx_0_12_machine_options);#define PC_COMPAT_0_11 \
@@ -920,8 +862,8 @@ static void pc_i440fx_0_11_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_0_11 ); } -DEFINE_PC_MACHINE (v0_11,"pc-0.11" , pc_init_pci_no_kvmclock, - pc_i440fx_0_11_machine_options); +DEFINE_I440FX_MACHINE (v0_11,"pc-0.11" , pc_compat_0_13, + pc_i440fx_0_11_machine_options);#define PC_COMPAT_0_10 \
@@ -955,8 +897,8 @@ static void pc_i440fx_0_10_machine_options(MachineClass *m)SET_MACHINE_COMPAT (m,PC_COMPAT_0_10 ); } -DEFINE_PC_MACHINE (v0_10,"pc-0.10" , pc_init_pci_no_kvmclock, - pc_i440fx_0_10_machine_options); +DEFINE_I440FX_MACHINE (v0_10,"pc-0.10" , pc_compat_0_13, + pc_i440fx_0_10_machine_options);static void isapc_machine_options (MachineClass *m)
hw/i386/pc_q35.c +28 -64
150 lines not on this page · raw message
Signature · 1 line
2.1.0