Convert PC machine-types to QOM classes
v3 cover Convert PC machine-types to QOM classes
New version, rebased to latest qemu.git master.
Git tree:
https://github.com/ehabkost/qemu-hacks/tree/pc-machine-class.v3
I would like to get this discussed/reviewed before QEMU 2.1.0 is released, so we can be ready to include the series as soon as we start 2.2 development.
My goal is that _all_ PC machine-types should be declared using only a class_init + TypeInfo pair, and nothing else. The compat_func field on PCMachineClass is supposed to be temporary, until we manage to eliminate all pc_compat_*() functions.
The only obstacle for that are the CPUID compat stuff inside some pc_compat_*() functions. I will submit a series for that later, including X86CPU feature properties.
Eduardo Habkost (35):
pc_piix: Add missing compat code to pc-0.1[0123]
target-i385: Add kvmclock_enabled static
pc_piix: Reuse pc_compat_1_2() on pc_init_pci_no_kvmclock()
pc: Replace tabs with spaces on pc.h
vl.c: Use qdev_prop_register_global() for single globals
piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14
piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13
piix: Move pc-0.1[23] rombar compat props to PC_COMPAT_0_13
piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11
machine: Make compat_props a linked list
pc: Register machine classes directly instead of using QEMUMachine
pc: Eliminate pc_common_machine_options()
pc: Eliminate pc_default_machine_options()
piix: Eliminate pc_i440fx_machine_options()
q35: Eliminate pc_q35_machine_options()
q35: Eliminate pc_q35_1_4_machine_options()
pc: Eliminate all *_machine_options() functions
machine: Eliminate QEMUMachine.compat_props
pc: Rename pc_machine variable to pcms
pc: Move pci_enabled parameter to PCMachineClass
q35: Use PCMachineClass.pci_enabled field
pc: Move kvmclock_enabled to PCMachineClass
pc: Move smbios_legacy_mode to PCMachineClass
pc: Move smbios_defaults to PCMachineClass
pc: Move has_acpi_build to PCMachineClass
pc: Move has_pci_info to PCMachineClass
pc: Move gigabyte_align to PCMachineClass
pc: Move has_reserved_memory to PCMachineClass
pc: Move option_rom_has_mr/rom_file_has_mr to MachineClass
piix: Eliminate pc_init_pci()
piix: Introduce struct PCI440FXMachineClass
pc: Create common machine init function
pc: Eliminate empty or trivial compat functions
piix: Move compat/init functions closer to corresponding class_init
pc: Move {ram,pci,rom}_memory variables to PCMachineState
hw/core/loader.c | 12 +- hw/core/machine.c | 16 + hw/core/qdev-properties.c | 9 +- hw/i386/pc.c | 71 ++-- hw/i386/pc_piix.c | 805 +++++++++++++++++++++++-------------------- hw/i386/pc_q35.c | 282 ++++++++------- include/hw/boards.h | 13 +- include/hw/i386/pc.h | 46 +-- include/hw/qdev-core.h | 2 + include/hw/qdev-properties.h | 2 +- vl.c | 44 +-- 11 files changed, 677 insertions(+), 625 deletions(-)
Signature · 1 line
1.9.3
RFC v3 1/35 pc_piix: Add missing compat code to pc-0.1[0123]
pc-0.13 and older were missing some compat code that is present on newer machine-types:
* x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC); (pc-i440fx-1.7 and older)
* x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); (pc-i440fx-1.4 and older)
* x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); (pc-i440fx-1.4 and older)
Add those missing bits to pc_init_pci_no_kvmclock(), to make sure pc-0.13 and older are compatible with the older QEMU versions. While at it, reorder pc_init_pci_no_kvmclock() and document where each line is was copied from.
--- hw/i386/pc_piix.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
hw/i386/pc_piix.c +20 -5
@@ -389,16 +389,31 @@ static void pc_init_pci_1_2(MachineState *machine)/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */ static void pc_init_pci_no_kvmclock (MachineState *machine) { - has_pci_info = false; - has_acpi_build = false; - smbios_defaults = false; - gigabyte_align = false; +/* Copy from pc_compat_2_0(): */ smbios_legacy_mode = true; has_reserved_memory = false; + +/* Copy from pc_compat_1_7(): */ + smbios_defaults = false; + gigabyte_align = false; option_rom_has_mr = true; +x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); + +/* Copy from pc_compat_1_6(): */ + has_pci_info = false; rom_file_has_mr = false; -x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); + has_acpi_build = false; + +/* Copy from pc_compat_1_4(): */ +x86_cpu_compat_set_features ("n270" ,FEAT_1_ECX ,0 ,CPUID_EXT_MOVBE ); +x86_cpu_compat_set_features ("Westmere" ,FEAT_1_ECX ,0 ,CPUID_EXT_PCLMULQDQ ); + +/* Copy from pc_compat_1_3(): */ enable_compat_apic_id_mode (); + +/* Copy from pc_compat_1_2(): */ +x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); +pc_init1 (machine,1 ,0 ); }
Signature · 1 line
1.9.3
RFC v3 2/35 target-i385: Add kvmclock_enabled static
In reply to Eduardo HabkostThis looks like a step backwards, but it will allow pc-0.1[0123] reuse pc_compat_1_2() instead of duplicating the code from all pc_compat_*() functions.
--- hw/i386/pc_piix.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
hw/i386/pc_piix.c +8 -5
@@ -69,11 +69,11 @@ static bool smbios_legacy_mode;*/ 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) +int pci_enabled) {PCMachineState *pc_machine =PC_MACHINE (machine);MemoryRegion *system_memory =get_system_memory ();
@@ -292,7 +292,7 @@ static void pc_init1(MachineState *machine,static void pc_init_pci (MachineState *machine) { -pc_init1 (machine,1 ,1 ); +pc_init1 (machine,1 ); }static void pc_compat_2_0 (MachineState *machine)
@@ -414,7 +414,10 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)/* Copy from pc_compat_1_2(): */ x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); -pc_init1 (machine,1 ,0 ); +/* Specific to pc-0.13 and older: */ + kvmclock_enabled = false; + +pc_init_pci (machine); }static void pc_init_isa (MachineState *machine)
@@ -432,7 +435,7 @@ static void pc_init_isa(MachineState *machine) }x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI );enable_compat_apic_id_mode (); -pc_init1 (machine,0 ,1 ); +pc_init1 (machine,0 ); }#ifdef CONFIG_XEN
Signature · 1 line
1.9.3
RFC v3 3/35 pc_piix: Reuse pc_compat_1_2() on pc_init_pci_no_kvmclock()
In reply to Eduardo HabkostInstead of following a different pattern from all other PC init functions, make pc-0.13 and older reuse pc_compat_1_2() and simply set kvmclock_enabled=false.
--- hw/i386/pc_piix.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-)
hw/i386/pc_piix.c +8 -28
@@ -343,6 +343,13 @@ static void pc_compat_1_2(MachineState *machine)x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); } +/* 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_0 (MachineState *machine) {pc_compat_2_0 (machine);
@@ -389,34 +396,7 @@ static void pc_init_pci_1_2(MachineState *machine)/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */ static void pc_init_pci_no_kvmclock (MachineState *machine) { -/* Copy from pc_compat_2_0(): */ - smbios_legacy_mode = true; - has_reserved_memory = false; - -/* Copy from pc_compat_1_7(): */ - smbios_defaults = false; - gigabyte_align = false; - option_rom_has_mr = true; -x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); - -/* Copy from pc_compat_1_6(): */ - has_pci_info = false; - rom_file_has_mr = false; - has_acpi_build = false; - -/* Copy from pc_compat_1_4(): */ -x86_cpu_compat_set_features ("n270" ,FEAT_1_ECX ,0 ,CPUID_EXT_MOVBE ); -x86_cpu_compat_set_features ("Westmere" ,FEAT_1_ECX ,0 ,CPUID_EXT_PCLMULQDQ ); - -/* Copy from pc_compat_1_3(): */ -enable_compat_apic_id_mode (); - -/* Copy from pc_compat_1_2(): */ -x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); - -/* Specific to pc-0.13 and older: */ - kvmclock_enabled = false; - +pc_compat_0_13 (machine);pc_init_pci (machine); }
Signature · 1 line
1.9.3
RFC v3 4/35 pc: Replace tabs with spaces on pc.h
In reply to Eduardo Habkost--- include/hw/i386/pc.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/hw/i386/pc.h +6 -6
@@ -440,23 +440,23 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .driver = "scsi-hd",\ .property = "discard_granularity",\ .value = stringify(0),\ - },{\ + },{\ .driver = "scsi-cd",\ .property = "discard_granularity",\ .value = stringify(0),\ - },{\ + },{\ .driver = "scsi-disk",\ .property = "discard_granularity",\ .value = stringify(0),\ - },{\ + },{\ .driver = "ide-hd",\ .property = "discard_granularity",\ .value = stringify(0),\ - },{\ + },{\ .driver = "ide-cd",\ .property = "discard_granularity",\ .value = stringify(0),\ - },{\ + },{\ .driver = "ide-drive",\ .property = "discard_granularity",\ .value = stringify(0),\
@@ -464,7 +464,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .driver = "virtio-blk-pci",\ .property = "discard_granularity",\ .value = stringify(0),\ - },{\ + },{\ .driver = "virtio-serial-pci",\ .property = "vectors",\ /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
Signature · 1 line
1.9.3
RFC v3 5/35 vl.c: Use qdev_prop_register_global() for single globals
In reply to Eduardo HabkostInstead of using an array when registering a single global, simply call qdev_prop_register().
--- vl.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-)
vl.c +15 -24
@@ -861,16 +861,13 @@ static void configure_rtc(QemuOpts *opts) value =qemu_opt_get (opts,"driftfix" );if (value) {if (!strcmp (value,"slew" )) { -static GlobalProperty slew_lost_ticks[] = { - { - .driver ="mc146818rtc" , - .property ="lost_tick_policy" , - .value ="slew" , - }, - {/* end of list */ } +static GlobalProperty slew_lost_ticks = { + .driver ="mc146818rtc" , + .property ="lost_tick_policy" , + .value ="slew" , }; -qdev_prop_register_global_list (slew_lost_ticks); +qdev_prop_register_global (&slew_lost_ticks); }else if (!strcmp (value,"none" )) {/* discard is default */ }else {
@@ -3633,16 +3630,13 @@ int main(int argc, char **argv, char **envp) win2k_install_hack =1 ;break ;case QEMU_OPTION_rtc_td_hack: { -static GlobalProperty slew_lost_ticks[] = { - { - .driver ="mc146818rtc" , - .property ="lost_tick_policy" , - .value ="slew" , - }, - {/* end of list */ } +static GlobalProperty slew_lost_ticks = { + .driver ="mc146818rtc" , + .property ="lost_tick_policy" , + .value ="slew" , }; -qdev_prop_register_global_list (slew_lost_ticks); +qdev_prop_register_global (&slew_lost_ticks);break ; }case QEMU_OPTION_acpitable:
@@ -3684,18 +3678,15 @@ int main(int argc, char **argv, char **envp)break ; }case QEMU_OPTION_no_kvm_pit_reinjection: { -static GlobalProperty kvm_pit_lost_tick_policy[] = { - { - .driver ="kvm-pit" , - .property ="lost_tick_policy" , - .value ="discard" , - }, - {/* end of list */ } +static GlobalProperty kvm_pit_lost_tick_policy = { + .driver ="kvm-pit" , + .property ="lost_tick_policy" , + .value ="discard" , };fprintf (stderr,"Warning: option deprecated, use " "lost_tick_policy property of kvm-pit instead.\n" ); -qdev_prop_register_global_list (kvm_pit_lost_tick_policy); +qdev_prop_register_global (&kvm_pit_lost_tick_policy);break ; }case QEMU_OPTION_usb:
Signature · 1 line
1.9.3
RFC v3 6/35 piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14
In reply to Eduardo HabkostThose properties were introduced by commit 3827cdb1c3aa17a792d1658161195b9d7173c26b. They were not duplicated into pc-0.13 and older because 0.14 was the first QEMU version supporting qxl. The only problem is that this breaks the PC_COMPAT_* nesting pattern we currently use.
So, move the properties to PC_COMPAT_0_14. This makes pc-0.13 and older inherit them, but that shouldn't be an issue as QEMU 0.13 didn't support qxl.
--- hw/i386/pc_piix.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
hw/i386/pc_piix.c +8 -9
@@ -682,6 +682,14 @@ static QEMUMachine pc_machine_v0_15 = { .driver = "virtio-balloon-pci",\ .property = "event_idx",\ .value = "off",\ + },{\ + .driver = "qxl",\ + .property = "revision",\ + .value = stringify(2),\ + },{\ + .driver = "qxl-vga",\ + .property = "revision",\ + .value = stringify(2),\ } static QEMUMachine pc_machine_v0_14 = {
@@ -689,15 +697,6 @@ static QEMUMachine pc_machine_v0_14 = { .name = "pc-0.14", .compat_props = (GlobalProperty []) {PC_COMPAT_0_14 , - { - .driver ="qxl" , - .property ="revision" , - .value =stringify (2 ), - },{ - .driver ="qxl-vga" , - .property ="revision" , - .value =stringify (2 ), - }, {/* end of list */ } }, .hw_version = "0.14",
Signature · 1 line
1.9.3
RFC v3 7/35 piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13
In reply to Eduardo HabkostThe compat property was added by commit 9dbcca5aa13cb9ab40788ac4c56bc227d94ca920, and the pc-0.12 and older machine-types were not changed because virtio-9p-pci was introduced on QEMU 0.13 (commit 9f10751365b26b13b8a9b67e0e90536ae3d282df). The only problem is that this breaks the PC_COMPAT_* nesting pattern we currently use.
So, move the property to PC_COMPAT_0_13. This make pc-0.12 and older inherit it, but that shouldn't be an issue as QEMU 0.12 didn't have virtio-9p-pci.
--- hw/i386/pc_piix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/i386/pc_piix.c +4 -4
@@ -712,6 +712,10 @@ static QEMUMachine pc_machine_v0_14 = { .driver = "AC97",\ .property = "use_broken_id",\ .value = stringify(1),\ + },{\ + .driver = "virtio-9p-pci",\ + .property = "vectors",\ + .value = stringify(0),\ }#define PC_I440FX_0_13_MACHINE_OPTIONS \
@@ -724,10 +728,6 @@ static QEMUMachine pc_machine_v0_13 = { .compat_props = (GlobalProperty[]) {PC_COMPAT_0_13 , { - .driver ="virtio-9p-pci" , - .property ="vectors" , - .value =stringify (0 ), - },{ .driver ="VGA" , .property ="rombar" , .value =stringify (0 ),
Signature · 1 line
1.9.3
RFC v3 8/35 piix: Move pc-0.1[23] rombar compat props to PC_COMPAT_0_13
In reply to Eduardo HabkostThe VGA and vmware-svga rombar compat properties were added by commit 281a26b15b4adcecb8604216738975abd754bea8, but only to pc-0.13 and pc-0.12. This breaks the PC_COMPAT_* nesting pattern we currently follow.
The new variables will now be inherited by pc-0.11 and older, but pc-0.11 and pc-0.10 already have PCI.rombar=0 on compat_props, so they shouldn't be affected at all.
--- hw/i386/pc_piix.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
hw/i386/pc_piix.c +8 -18
@@ -716,6 +716,14 @@ static QEMUMachine pc_machine_v0_14 = { .driver = "virtio-9p-pci",\ .property = "vectors",\ .value = stringify(0),\ + },{\ + .driver = "VGA",\ + .property = "rombar",\ + .value = stringify(0),\ + },{\ + .driver = "vmware-svga",\ + .property = "rombar",\ + .value = stringify(0),\ }#define PC_I440FX_0_13_MACHINE_OPTIONS \
@@ -727,15 +735,6 @@ static QEMUMachine pc_machine_v0_13 = { .name = "pc-0.13", .compat_props = (GlobalProperty []) {PC_COMPAT_0_13 , - { - .driver ="VGA" , - .property ="rombar" , - .value =stringify (0 ), - },{ - .driver ="vmware-svga" , - .property ="rombar" , - .value =stringify (0 ), - }, {/* end of list */ } }, .hw_version = "0.13",
@@ -770,15 +769,6 @@ static QEMUMachine pc_machine_v0_12 = { .name = "pc-0.12", .compat_props = (GlobalProperty []) {PC_COMPAT_0_12 , - { - .driver ="VGA" , - .property ="rombar" , - .value =stringify (0 ), - },{ - .driver ="vmware-svga" , - .property ="rombar" , - .value =stringify (0 ), - }, {/* end of list */ } }, .hw_version = "0.12",
Signature · 1 line
1.9.3
RFC v3 9/35 piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11
In reply to Eduardo HabkostThe current code setting ide-drive.ver and scsi-disk.ver on pc-0.11 breaks the PC_COMPAT_* nesting pattern we currently use.
As those variables are overwritten in pc-0.10 too, they can be inherited by pc-0.10 with no side-effects at all.
--- hw/i386/pc_piix.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
hw/i386/pc_piix.c +8 -9
@@ -784,6 +784,14 @@ static QEMUMachine pc_machine_v0_12 = { .driver = TYPE_PCI_DEVICE,\ .property = "rombar",\ .value = stringify(0),\ + },{\ + .driver = "ide-drive",\ + .property = "ver",\ + .value = "0.11",\ + },{\ + .driver = "scsi-disk",\ + .property = "ver",\ + .value = "0.11",\ } static QEMUMachine pc_machine_v0_11 = {
@@ -791,15 +799,6 @@ static QEMUMachine pc_machine_v0_11 = { .name = "pc-0.11", .compat_props = (GlobalProperty []) {PC_COMPAT_0_11 , - { - .driver ="ide-drive" , - .property ="ver" , - .value ="0.11" , - },{ - .driver ="scsi-disk" , - .property ="ver" , - .value ="0.11" , - }, {/* end of list */ } }, .hw_version = "0.11",
Signature · 1 line
1.9.3
RFC v3 10/35 machine: Make compat_props a linked list
In reply to Eduardo HabkostThis will make it easier to write reusable class_init code which adds properties to MachineClass.compat_props.
--- hw/core/machine.c | 15 +++++++++++++++ hw/core/qdev-properties.c | 9 +++++---- hw/i386/pc.c | 4 +++- include/hw/boards.h | 10 +++++++++- include/hw/qdev-core.h | 2 ++ include/hw/qdev-properties.h | 2 +- vl.c | 8 ++++---- 7 files changed, 39 insertions(+), 11 deletions(-)
hw/core/machine.c +15 -0
@@ -290,12 +290,27 @@ static void machine_finalize(Object *obj)g_free (ms->firmware); } +void machine_class_add_compat_props (MachineClass *mc,GlobalProperty *props) +{ +int i; +for (i =0 ; props[i].driver; i++) { +QTAILQ_INSERT_TAIL (&mc->compat_props, &props[i], next); + } +} + +static void machine_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +QTAILQ_INIT (&mc->compat_props); +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT , .abstract = true, .class_size =sizeof (MachineClass), .instance_size =sizeof (MachineState), + .class_init = machine_class_init, .instance_init = machine_initfn, .instance_finalize = machine_finalize, };
hw/core/qdev-properties.c +5 -4
@@ -946,12 +946,13 @@ void qdev_prop_register_global(GlobalProperty *prop)QTAILQ_INSERT_TAIL (&global_props, prop, next); } -void qdev_prop_register_global_list (GlobalProperty *props) +void qdev_prop_register_global_list (GlobalPropertyList *props) { -int i; +GlobalProperty *prop, *nprop; -for (i =0 ; props[i].driver !=NULL ; i++) { -qdev_prop_register_global (props+i); + QTAILQ_FOREACH_SAFE(prop, props, next, nprop) { +QTAILQ_REMOVE (props, prop, next); +qdev_prop_register_global (prop); } }
hw/i386/pc.c +3 -1
@@ -1531,8 +1531,10 @@ static void pc_generic_machine_class_init(ObjectClass *oc, void *data) mc->is_default = qm->is_default; mc->default_machine_opts = qm->default_machine_opts; mc->default_boot_order = qm->default_boot_order; - mc->compat_props = qm->compat_props; mc->hw_version = qm->hw_version; +if (qm->compat_props) { +machine_class_add_compat_props (mc, qm->compat_props); + } }void qemu_register_pc_machine (QEMUMachine *m)
include/hw/boards.h +9 -1
@@ -4,6 +4,7 @@#define HW_BOARDS_H #include "qemu/typedefs.h" +#include "qemu/queue.h" #include "sysemu/blockdev.h" #include "hw/qdev.h" #include "qom/object.h"
@@ -97,7 +98,7 @@ struct MachineClass {int is_default;const char *default_machine_opts;const char *default_boot_order; -GlobalProperty *compat_props; +GlobalPropertyList compat_props;const char *hw_version; HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
@@ -105,6 +106,13 @@ struct MachineClass { };/** +* machine_class_add_compat_props: +* +* Adds compat props from an array to the MachineClass compat_props list. +*/ +void machine_class_add_compat_props (MachineClass *mc,GlobalProperty *props); + +/** * MachineState: */ struct MachineState {
include/hw/qdev-core.h +2 -0
@@ -255,6 +255,8 @@ typedef struct GlobalProperty {QTAILQ_ENTRY (GlobalProperty) next; } GlobalProperty; +typedef QTAILQ_HEAD(GlobalPropertyList, GlobalProperty) GlobalPropertyList; +/*** Board API. This should go away once we have a machine config file. ***/ DeviceState *qdev_create (BusState *bus,const char *name);
include/hw/qdev-properties.h +1 -1
@@ -176,7 +176,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);void qdev_prop_set_ptr (DeviceState *dev,const char *name,void *value);void qdev_prop_register_global (GlobalProperty *prop); -void qdev_prop_register_global_list (GlobalProperty *props); +void qdev_prop_register_global_list (GlobalPropertyList *props);int qdev_prop_check_global (void );void qdev_prop_set_globals (DeviceState *dev,Error **errp); void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
vl.c +4 -4
@@ -1569,8 +1569,10 @@ static void machine_class_init(ObjectClass *oc, void *data) mc->is_default = qm->is_default; mc->default_machine_opts = qm->default_machine_opts; mc->default_boot_order = qm->default_boot_order; - mc->compat_props = qm->compat_props; mc->hw_version = qm->hw_version; +if (qm->compat_props) { +machine_class_add_compat_props (mc, qm->compat_props); + } }int qemu_register_machine (QEMUMachine *m)
@@ -4374,9 +4376,7 @@ int main(int argc, char **argv, char **envp)exit (i ==1 ?1 :0 ); } -if (machine_class->compat_props) { -qdev_prop_register_global_list (machine_class->compat_props); - } +qdev_prop_register_global_list (&machine_class->compat_props);qemu_add_globals ();qdev_machine_init ();
Signature · 1 line
1.9.3
RFC v3 11/35 pc: Register machine classes directly instead of using QEMUMachine
In reply to Eduardo HabkostThis is a (mostly) blind and mechanical conversion of the PC QEMUMachine definitions to corresponding class registration code.
Existing duplication and unnecessary complexity on macro/function reuse is being kept, to keep the conversion simple to review. The complexity and duplication will be gradually removed by the next patches.
---
Changes v1 -> v2:
* Remove unused PC_DEFAULT_MACHINE_OPTIONS macro leftover
* Use machine_class_register_global_props_array()
* Rebase on top of Michael's pci tree
* Eliminate qemu_register_pc_machine(), as it is not needed anymore
Changes v2 -> v3:
* Make static TypeInfo structs const
--- hw/i386/pc.c | 44 ----- hw/i386/pc_piix.c | 473 +++++++++++++++++++++++++++++++++++---------------- hw/i386/pc_q35.c | 171 +++++++++++++------ include/hw/i386/pc.h | 17 +- 4 files changed, 448 insertions(+), 257 deletions(-)
hw/i386/pc.c +0 -44
@@ -1507,50 +1507,6 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name) } } -static void pc_generic_machine_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -QEMUMachine *qm = data; - - mc->name = qm->name; - mc->alias = qm->alias; - mc->desc = qm->desc; - mc->init = qm->init; - mc->reset = qm->reset; - mc->hot_add_cpu = qm->hot_add_cpu; - mc->kvm_type = qm->kvm_type; - mc->block_default_type = qm->block_default_type; - mc->max_cpus = qm->max_cpus; - mc->no_serial = qm->no_serial; - mc->no_parallel = qm->no_parallel; - mc->use_virtcon = qm->use_virtcon; - mc->use_sclp = qm->use_sclp; - mc->no_floppy = qm->no_floppy; - mc->no_cdrom = qm->no_cdrom; - mc->no_sdcard = qm->no_sdcard; - mc->is_default = qm->is_default; - mc->default_machine_opts = qm->default_machine_opts; - mc->default_boot_order = qm->default_boot_order; - mc->hw_version = qm->hw_version; -if (qm->compat_props) { -machine_class_add_compat_props (mc, qm->compat_props); - } -} - -void qemu_register_pc_machine (QEMUMachine *m) -{ -char *name =g_strconcat (m->name,TYPE_MACHINE_SUFFIX ,NULL ); -TypeInfo ti = { - .name = name, - .parent =TYPE_PC_MACHINE , - .class_init = pc_generic_machine_class_init, - .class_data = (void *)m, - }; - -type_register (&ti); -g_free (name); -} -static void pc_dimm_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {
hw/i386/pc_piix.c +322 -151
602 lines not on this page · raw message
hw/i386/pc_q35.c +115 -56
205 lines not on this page · raw message
include/hw/i386/pc.h +11 -6
@@ -8,6 +8,7 @@#include "hw/block/fdc.h" #include "net/net.h" #include "hw/i386/ioapic.h" +#include "hw/boards.h" #include "qemu/range.h" #include "qemu/bitmap.h"
@@ -499,12 +500,16 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = stringify(0),\ } -#define PC_COMMON_MACHINE_OPTIONS \ - .default_boot_order = "cad" +static inline void pc_common_machine_options (MachineClass *mc) +{ + mc->default_boot_order ="cad" ; +} -#define PC_DEFAULT_MACHINE_OPTIONS \ - PC_COMMON_MACHINE_OPTIONS, \ - .hot_add_cpu = pc_hot_add_cpu, \ - .max_cpus = 255 +static inline void pc_default_machine_options (MachineClass *mc) +{ +pc_common_machine_options (mc); + mc->hot_add_cpu = pc_hot_add_cpu; + mc->max_cpus =255 ; +}#endif
Signature · 1 line
1.9.3
RFC v3 12/35 pc: Eliminate pc_common_machine_options()
In reply to Eduardo HabkostThe TYPE_PC_MACHINE parent class can initialize the common options for all PC machines.
--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 2 -- include/hw/i386/pc.h | 6 ------ 3 files changed, 1 insertion(+), 8 deletions(-)
hw/i386/pc.c +1 -0
@@ -1663,6 +1663,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->get_hotplug_handler = mc->get_hotplug_handler; mc->get_hotplug_handler = pc_get_hotpug_handler; + mc->default_boot_order ="cad" ; hc->plug = pc_machine_device_plug_cb; }
hw/i386/pc_piix.c +0 -2
@@ -994,7 +994,6 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)static GlobalProperty compat_props[] = { {/* end of list */ } }; -pc_common_machine_options (mc); mc->desc ="ISA-only PC" ; mc->init = pc_init_isa; mc->max_cpus =1 ;
@@ -1023,7 +1022,6 @@ static void xenfv_machine_class_init(ObjectClass *oc, void *data) }, {/* end of list */ } }; -pc_common_machine_options (mc); mc->desc ="Xen Fully-virtualized PC" ; mc->init = pc_xen_hvm_init; mc->max_cpus =HVM_MAX_VCPUS ;
include/hw/i386/pc.h +0 -6
@@ -500,14 +500,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = stringify(0),\ } -static inline void pc_common_machine_options (MachineClass *mc) -{ - mc->default_boot_order ="cad" ; -} -static inline void pc_default_machine_options (MachineClass *mc) { -pc_common_machine_options (mc); mc->hot_add_cpu = pc_hot_add_cpu; mc->max_cpus =255 ; }
Signature · 1 line
1.9.3
RFC v3 13/35 pc: Eliminate pc_default_machine_options()
In reply to Eduardo HabkostThe only PC machines that didn't call pc_default_machine_options() were isaps and xenfv. Both were already overwriting max_cpus, and only isapc was not overwriting hot_add_cpu.
After making isapc set hot_add_cpu to NULL, we can move the pc_default_machine_options() code the PC common class_init.
--- hw/i386/pc.c | 2 ++ hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 1 - include/hw/i386/pc.h | 6 ------ 4 files changed, 3 insertions(+), 8 deletions(-)
hw/i386/pc.c +2 -0
@@ -1664,6 +1664,8 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->get_hotplug_handler = mc->get_hotplug_handler; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->default_boot_order ="cad" ; + mc->hot_add_cpu = pc_hot_add_cpu; + mc->max_cpus =255 ; hc->plug = pc_machine_device_plug_cb; }
hw/i386/pc_piix.c +1 -1
@@ -434,7 +434,6 @@ static void pc_xen_hvm_init(MachineState *machine)static void pc_i440fx_machine_options (MachineClass *mc) { -pc_default_machine_options (mc); mc->desc ="Standard PC (i440FX + PIIX, 1996)" ; mc->hot_add_cpu = pc_hot_add_cpu; }
@@ -997,6 +996,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data) mc->desc ="ISA-only PC" ; mc->init = pc_init_isa; mc->max_cpus =1 ; + mc->hot_add_cpu =NULL ; mc->name ="isapc" ;machine_class_add_compat_props (mc, compat_props); }
hw/i386/pc_q35.c +0 -1
@@ -340,7 +340,6 @@ static void pc_q35_init_1_4(MachineState *machine)static void pc_q35_machine_options (MachineClass *mc) { -pc_default_machine_options (mc); mc->desc ="Standard PC (Q35 + ICH9, 2009)" ; mc->hot_add_cpu = pc_hot_add_cpu; }
include/hw/i386/pc.h +0 -6
@@ -500,10 +500,4 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = stringify(0),\ } -static inline void pc_default_machine_options (MachineClass *mc) -{ - mc->hot_add_cpu = pc_hot_add_cpu; - mc->max_cpus =255 ; -} -#endif
Signature · 1 line
1.9.3
RFC v3 14/35 piix: Eliminate pc_i440fx_machine_options()
In reply to Eduardo HabkostInstead of calling it on every i440fx class_init function, just register a common parent class for all i440fx machine-types.
--- hw/i386/pc_piix.c | 55 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-)
hw/i386/pc_piix.c +29 -26
@@ -432,15 +432,25 @@ static void pc_xen_hvm_init(MachineState *machine) }#endif -static void pc_i440fx_machine_options (MachineClass *mc) +static void pc_i440fx_machine_class_init (ObjectClass *oc,void *data) { +MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="Standard PC (i440FX + PIIX, 1996)" ; mc->hot_add_cpu = pc_hot_add_cpu; } +#define TYPE_PC_I440FX_MACHINE "pc-i440fx" TYPE_MACHINE_SUFFIX + +static TypeInfo pc_i440fx_machine_type_info = { + .name =TYPE_PC_I440FX_MACHINE , + .parent =TYPE_PC_MACHINE , + .class_init = pc_i440fx_machine_class_init, + .abstract = true, +}; + +static void pc_i440fx_2_1_machine_options (MachineClass *mc) { -pc_i440fx_machine_options (mc); mc->default_machine_opts ="firmware=bios-256k.bin" ; }
@@ -456,7 +466,7 @@ static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_i440fx_machine_v2_1_type_info = { .name ="pc-i440fx-2.1" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_i440fx_machine_v2_1_class_init, };
@@ -477,12 +487,10 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_i440fx_machine_v2_0_type_info = { .name ="pc-i440fx-2.0" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_i440fx_machine_v2_0_class_init, }; -#define pc_i440fx_1_7_machine_options pc_i440fx_machine_options -static void pc_i440fx_machine_v1_7_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -490,7 +498,6 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_7, {/* end of list */ } }; -pc_i440fx_1_7_machine_options (mc); mc->init = pc_init_pci_1_7; mc->name ="pc-i440fx-1.7" ;machine_class_add_compat_props (mc, compat_props);
@@ -498,12 +505,10 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_i440fx_machine_v1_7_type_info = { .name ="pc-i440fx-1.7" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_i440fx_machine_v1_7_class_init, }; -#define pc_i440fx_1_6_machine_options pc_i440fx_machine_options -static void pc_i440fx_machine_v1_6_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -511,7 +516,6 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_6, {/* end of list */ } }; -pc_i440fx_1_6_machine_options (mc); mc->init = pc_init_pci_1_6; mc->name ="pc-i440fx-1.6" ;machine_class_add_compat_props (mc, compat_props);
@@ -519,7 +523,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_i440fx_machine_v1_6_type_info = { .name ="pc-i440fx-1.6" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_i440fx_machine_v1_6_class_init, };
@@ -530,7 +534,6 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_5, {/* end of list */ } }; -pc_i440fx_1_6_machine_options (mc); mc->init = pc_init_pci_1_5; mc->name ="pc-i440fx-1.5" ;machine_class_add_compat_props (mc, compat_props);
@@ -538,13 +541,12 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_i440fx_machine_v1_5_type_info = { .name ="pc-i440fx-1.5" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_i440fx_machine_v1_5_class_init, };static void pc_i440fx_1_4_machine_options (MachineClass *mc) { -pc_i440fx_1_6_machine_options (mc); mc->hot_add_cpu =NULL ; }
@@ -563,7 +565,7 @@ static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_i440fx_machine_v1_4_type_info = { .name ="pc-i440fx-1.4" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_i440fx_machine_v1_4_class_init, };
@@ -602,7 +604,7 @@ static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v1_3_type_info = { .name ="pc-1.3" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v1_3_class_init, };
@@ -654,7 +656,7 @@ static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v1_2_type_info = { .name ="pc-1.2" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v1_2_class_init, };
@@ -704,7 +706,7 @@ static void pc_machine_v1_1_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v1_1_type_info = { .name ="pc-1.1" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v1_1_class_init, };
@@ -743,7 +745,7 @@ static void pc_machine_v1_0_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v1_0_type_info = { .name ="pc-1.0" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v1_0_class_init, };
@@ -765,7 +767,7 @@ static void pc_machine_v0_15_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v0_15_type_info = { .name ="pc-0.15" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v0_15_class_init, };
@@ -812,7 +814,7 @@ static void pc_machine_v0_14_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v0_14_type_info = { .name ="pc-0.14" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v0_14_class_init, };
@@ -861,7 +863,7 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v0_13_type_info = { .name ="pc-0.13" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v0_13_class_init, };
@@ -904,7 +906,7 @@ static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v0_12_type_info = { .name ="pc-0.12" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v0_12_class_init, };
@@ -943,7 +945,7 @@ static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v0_11_type_info = { .name ="pc-0.11" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v0_11_class_init, };
@@ -983,7 +985,7 @@ static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)static const TypeInfo pc_machine_v0_10_type_info = { .name ="pc-0.10" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_I440FX_MACHINE , .class_init = pc_machine_v0_10_class_init, };
@@ -1040,6 +1042,7 @@ static const TypeInfo xenfv_machine_type_info = {static void pc_machine_init (void ) { +type_register_static (&pc_i440fx_machine_type_info);type_register_static (&pc_i440fx_machine_v2_1_type_info);type_register_static (&pc_i440fx_machine_v2_0_type_info);type_register_static (&pc_i440fx_machine_v1_7_type_info);
Signature · 1 line
1.9.3
RFC v3 15/35 q35: Eliminate pc_q35_machine_options()
In reply to Eduardo HabkostInstead of calling it on every q35 class_init function, just register a common parent class for all q35 machine-types.
--- hw/i386/pc_q35.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-)
hw/i386/pc_q35.c +18 -16
@@ -338,15 +338,24 @@ static void pc_q35_init_1_4(MachineState *machine)pc_q35_init (machine); } -static void pc_q35_machine_options (MachineClass *mc) +static void pc_q35_machine_class_init (ObjectClass *oc,void *data) { +MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="Standard PC (Q35 + ICH9, 2009)" ; mc->hot_add_cpu = pc_hot_add_cpu; } +#define TYPE_PC_Q35_MACHINE "pc-q35" TYPE_MACHINE_SUFFIX + +static TypeInfo pc_q35_machine_type_info = { + .name =TYPE_PC_Q35_MACHINE , + .parent =TYPE_PC_MACHINE , + .class_init = pc_q35_machine_class_init, + .abstract = true, +}; +static void pc_q35_2_1_machine_options (MachineClass *mc) { -pc_q35_machine_options (mc); mc->default_machine_opts ="firmware=bios-256k.bin" ; }
@@ -361,7 +370,7 @@ static void pc_q35_machine_v2_1_class_init(ObjectClass *oc, void *data)static TypeInfo pc_q35_machine_v2_1_type_info = { .name ="pc-q35-2.1" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_Q35_MACHINE , .class_init = pc_q35_machine_v2_1_class_init, };
@@ -382,12 +391,10 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)static TypeInfo pc_q35_machine_v2_0_type_info = { .name ="pc-q35-2.0" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_Q35_MACHINE , .class_init = pc_q35_machine_v2_0_class_init, }; -#define pc_q35_1_7_machine_options pc_q35_machine_options -static void pc_q35_machine_v1_7_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -395,7 +402,6 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_7, {/* end of list */ } }; -pc_q35_1_7_machine_options (mc); mc->init = pc_q35_init_1_7;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.7" ;
@@ -403,12 +409,10 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)static TypeInfo pc_q35_machine_v1_7_type_info = { .name ="pc-q35-1.7" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_Q35_MACHINE , .class_init = pc_q35_machine_v1_7_class_init, }; -#define pc_q35_1_6_machine_options pc_q35_machine_options -static void pc_q35_machine_v1_6_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -416,7 +420,6 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_6, {/* end of list */ } }; -pc_q35_1_6_machine_options (mc); mc->init = pc_q35_init_1_6;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.6" ;
@@ -424,7 +427,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)static TypeInfo pc_q35_machine_v1_6_type_info = { .name ="pc-q35-1.6" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_Q35_MACHINE , .class_init = pc_q35_machine_v1_6_class_init, };
@@ -435,7 +438,6 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_5, {/* end of list */ } }; -pc_q35_1_6_machine_options (mc); mc->init = pc_q35_init_1_5;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.5" ;
@@ -443,13 +445,12 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)static TypeInfo pc_q35_machine_v1_5_type_info = { .name ="pc-q35-1.5" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_Q35_MACHINE , .class_init = pc_q35_machine_v1_5_class_init, };static void pc_q35_1_4_machine_options (MachineClass *mc) { -pc_q35_1_6_machine_options (mc); mc->hot_add_cpu =NULL ; }
@@ -468,12 +469,13 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)static TypeInfo pc_q35_machine_v1_4_type_info = { .name ="pc-q35-1.4" TYPE_MACHINE_SUFFIX , - .parent =TYPE_PC_MACHINE , + .parent =TYPE_PC_Q35_MACHINE , .class_init = pc_q35_machine_v1_4_class_init, };static void pc_q35_machine_init (void ) { +type_register_static (&pc_q35_machine_type_info);type_register_static (&pc_q35_machine_v2_1_type_info);type_register_static (&pc_q35_machine_v2_0_type_info);type_register_static (&pc_q35_machine_v1_7_type_info);
Signature · 1 line
1.9.3
RFC v3 16/35 q35: Eliminate pc_q35_1_4_machine_options()
In reply to Eduardo HabkostThe function was used only in a single place.
--- hw/i386/pc_q35.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
hw/i386/pc_q35.c +1 -6
@@ -449,11 +449,6 @@ static TypeInfo pc_q35_machine_v1_5_type_info = { .class_init = pc_q35_machine_v1_5_class_init, }; -static void pc_q35_1_4_machine_options (MachineClass *mc) -{ - mc->hot_add_cpu =NULL ; -} -static void pc_q35_machine_v1_4_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -461,7 +456,7 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_4, {/* end of list */ } }; -pc_q35_1_4_machine_options (mc); + mc->hot_add_cpu =NULL ; mc->init = pc_q35_init_1_4;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.4" ;
Signature · 1 line
1.9.3
RFC v3 17/35 pc: Eliminate all *_machine_options() functions
In reply to Eduardo HabkostFinally 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.
--- 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(-)
hw/i386/pc_piix.c +22 -54
@@ -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);
hw/i386/pc_q35.c +8 -9
@@ -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);
include/hw/i386/pc.h +0 -4
@@ -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",\
Signature · 1 line
1.9.3
RFC v3 18/35 machine: Eliminate QEMUMachine.compat_props
In reply to Eduardo HabkostThe only user of QEMUMachine.compat_props was the PC code, that was already converted to QOM. We don't need that field anymore.
--- include/hw/boards.h | 1 - vl.c | 3 --- 2 files changed, 4 deletions(-)
include/hw/boards.h +0 -1
@@ -40,7 +40,6 @@ struct QEMUMachine {int is_default;const char *default_machine_opts;const char *default_boot_order; -GlobalProperty *compat_props;const char *hw_version; };
vl.c +0 -3
@@ -1570,9 +1570,6 @@ static void machine_class_init(ObjectClass *oc, void *data) mc->default_machine_opts = qm->default_machine_opts; mc->default_boot_order = qm->default_boot_order; mc->hw_version = qm->hw_version; -if (qm->compat_props) { -machine_class_add_compat_props (mc, qm->compat_props); - } }int qemu_register_machine (QEMUMachine *m)
Signature · 1 line
1.9.3
RFC v3 19/35 pc: Rename pc_machine variable to pcms
In reply to Eduardo Habkost"pcms" being the initials of "PCMachineState". The variable will be used a lot, so it's better to make it short.
--- hw/i386/pc_piix.c | 10 +++++----- hw/i386/pc_q35.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-)
hw/i386/pc_piix.c +5 -5
@@ -75,7 +75,7 @@ static bool kvmclock_enabled = true;static void pc_init1 (MachineState *machine,int pci_enabled) { -PCMachineState *pc_machine =PC_MACHINE (machine); +PCMachineState *pcms =PC_MACHINE (machine);MemoryRegion *system_memory =get_system_memory ();MemoryRegion *system_io =get_system_io ();int i;
@@ -117,13 +117,13 @@ static void pc_init1(MachineState *machine,/* Handle the machine opt max-ram-below-4g. It is basicly doing * min(qemu limit, user limit). */ -if (lowmem > pc_machine->max_ram_below_4g) { - lowmem = pc_machine->max_ram_below_4g; +if (lowmem > pcms->max_ram_below_4g) { + lowmem = pcms->max_ram_below_4g;if (machine->ram_size - lowmem > lowmem && lowmem & ((1ULL <<30 ) -1 )) {error_report ("Warning: Large machine and max_ram_below_4g(%" PRIu64") not a multiple of 1G; possible bad performance." , - pc_machine->max_ram_below_4g); + pcms->max_ram_below_4g); } }
@@ -278,7 +278,7 @@ static void pc_init1(MachineState *machine,object_property_add_link (OBJECT (machine),PC_MACHINE_ACPI_DEVICE_PROP ,TYPE_HOTPLUG_HANDLER , - (Object **)&pc_machine->acpi_dev, + (Object **)&pcms->acpi_dev, object_property_allow_set_link,OBJ_PROP_LINK_UNREF_ON_RELEASE , &error_abort); object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
hw/i386/pc_q35.c +5 -5
@@ -63,7 +63,7 @@ static bool has_reserved_memory = true;/* PC hardware initialisation */ static void pc_q35_init (MachineState *machine) { -PCMachineState *pc_machine =PC_MACHINE (machine); +PCMachineState *pcms =PC_MACHINE (machine);ram_addr_t below_4g_mem_size, above_4g_mem_size;Q35PCIHost *q35_host;PCIHostState *phb;
@@ -106,13 +106,13 @@ static void pc_q35_init(MachineState *machine)/* Handle the machine opt max-ram-below-4g. It is basicly doing * min(qemu limit, user limit). */ -if (lowmem > pc_machine->max_ram_below_4g) { - lowmem = pc_machine->max_ram_below_4g; +if (lowmem > pcms->max_ram_below_4g) { + lowmem = pcms->max_ram_below_4g;if (machine->ram_size - lowmem > lowmem && lowmem & ((1ULL <<30 ) -1 )) {error_report ("Warning: Large machine and max_ram_below_4g(%" PRIu64") not a multiple of 1G; possible bad performance." , - pc_machine->max_ram_below_4g); + pcms->max_ram_below_4g); } }
@@ -201,7 +201,7 @@ static void pc_q35_init(MachineState *machine)object_property_add_link (OBJECT (machine),PC_MACHINE_ACPI_DEVICE_PROP ,TYPE_HOTPLUG_HANDLER , - (Object **)&pc_machine->acpi_dev, + (Object **)&pcms->acpi_dev, object_property_allow_set_link,OBJ_PROP_LINK_UNREF_ON_RELEASE , &error_abort); object_property_set_link(OBJECT(machine), OBJECT(lpc),
Signature · 1 line
1.9.3
RFC v3 20/35 pc: Move pci_enabled parameter to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 11 +++++++---- include/hw/i386/pc.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-)
hw/i386/pc.c +1 -0
@@ -1662,6 +1662,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); pcmc->get_hotplug_handler = mc->get_hotplug_handler; + pcmc->pci_enabled = true; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->default_boot_order ="cad" ; mc->hot_add_cpu = pc_hot_add_cpu;
hw/i386/pc_piix.c +7 -4
@@ -72,10 +72,11 @@ static bool has_reserved_memory = true;static bool kvmclock_enabled = true;/* PC hardware initialisation */ -static void pc_init1 (MachineState *machine, -int pci_enabled) +static void pc_init1 (MachineState *machine) {PCMachineState *pcms =PC_MACHINE (machine); +PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pcms); +bool pci_enabled = pcmc->pci_enabled;MemoryRegion *system_memory =get_system_memory ();MemoryRegion *system_io =get_system_io ();int i;
@@ -292,7 +293,7 @@ static void pc_init1(MachineState *machine,static void pc_init_pci (MachineState *machine) { -pc_init1 (machine,1 ); +pc_init1 (machine); }static void pc_compat_2_0 (MachineState *machine)
@@ -415,7 +416,7 @@ static void pc_init_isa(MachineState *machine) }x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI );enable_compat_apic_id_mode (); -pc_init1 (machine,0 ); +pc_init1 (machine); }#ifdef CONFIG_XEN
@@ -960,9 +961,11 @@ static const TypeInfo pc_machine_v0_10_type_info = {static void isapc_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = { {/* end of list */ } }; + pcmc->pci_enabled = false; mc->desc ="ISA-only PC" ; mc->init = pc_init_isa; mc->max_cpus =1 ;
include/hw/i386/pc.h +1 -0
@@ -53,6 +53,7 @@ struct PCMachineClass {/*< public >*/ HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); +bool pci_enabled; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 21/35 q35: Use PCMachineClass.pci_enabled field
In reply to Eduardo HabkostLittle step towards making the q35 and piix init functions converge, to eliminate duplication.
--- hw/i386/pc_q35.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/i386/pc_q35.c +4 -1
@@ -64,6 +64,8 @@ static bool has_reserved_memory = true;static void pc_q35_init (MachineState *machine) {PCMachineState *pcms =PC_MACHINE (machine); +PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pcms); +bool pci_enabled = pcmc->pci_enabled;ram_addr_t below_4g_mem_size, above_4g_mem_size;Q35PCIHost *q35_host;PCIHostState *phb;
@@ -77,7 +79,6 @@ static void pc_q35_init(MachineState *machine)MemoryRegion *ram_memory;GSIState *gsi_state;ISABus *isa_bus; -int pci_enabled =1 ;qemu_irq *cpu_irq;qemu_irq *gsi;qemu_irq *i8259;
@@ -341,8 +342,10 @@ static void pc_q35_init_1_4(MachineState *machine)static void pc_q35_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc); mc->desc ="Standard PC (Q35 + ICH9, 2009)" ; mc->hot_add_cpu = pc_hot_add_cpu; + pcmc->pci_enabled = true; }#define TYPE_PC_Q35_MACHINE "pc-q35" TYPE_MACHINE_SUFFIX
Signature · 1 line
1.9.3
RFC v3 22/35 pc: Move kvmclock_enabled to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 6 +++--- include/hw/i386/pc.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-)
hw/i386/pc.c +1 -0
@@ -1663,6 +1663,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->get_hotplug_handler = mc->get_hotplug_handler; pcmc->pci_enabled = true; + pcmc->kvmclock_enabled = true; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->default_boot_order ="cad" ; mc->hot_add_cpu = pc_hot_add_cpu;
hw/i386/pc_piix.c +3 -3
@@ -69,7 +69,6 @@ static bool smbios_legacy_mode;*/ 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)
@@ -148,7 +147,7 @@ static void pc_init1(MachineState *machine)pc_cpus_init (machine->cpu_model, icc_bridge); -if (kvm_enabled () && kvmclock_enabled) { +if (kvm_enabled () && pcmc->kvmclock_enabled) {kvmclock_create (); }
@@ -348,7 +347,6 @@ static void pc_compat_1_2(MachineState *machine)static void pc_compat_0_13 (MachineState *machine) {pc_compat_1_2 (machine); - kvmclock_enabled = false; }static void pc_init_pci_2_0 (MachineState *machine)
@@ -822,6 +820,7 @@ static const TypeInfo pc_machine_v0_14_type_info = {static void pc_machine_v0_13_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_0_13 , {/* end of list */ }
@@ -831,6 +830,7 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data) mc->hw_version ="0.13" ; mc->name ="pc-0.13" ;machine_class_add_compat_props (mc, compat_props); + pcmc->kvmclock_enabled = false; }static const TypeInfo pc_machine_v0_13_type_info = {
include/hw/i386/pc.h +1 -0
@@ -54,6 +54,7 @@ struct PCMachineClass { HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);bool pci_enabled; +bool kvmclock_enabled; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 23/35 pc: Move smbios_legacy_mode to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 9 +++++---- hw/i386/pc_q35.c | 7 ++++--- include/hw/i386/pc.h | 1 + 3 files changed, 10 insertions(+), 7 deletions(-)
hw/i386/pc_piix.c +5 -4
@@ -62,7 +62,6 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };static bool has_pci_info;static bool has_acpi_build = true;static bool smbios_defaults = true; -static bool smbios_legacy_mode;/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * pages in the host.
@@ -170,9 +169,10 @@ static void pc_init1(MachineState *machine)if (smbios_defaults) {MachineClass *mc =MACHINE_GET_CLASS (machine); +PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (mc);/* These values are guest ABI, do not change */ smbios_set_defaults ("QEMU" ,"Standard PC (i440FX + PIIX, 1996)" , - mc->name, smbios_legacy_mode); + mc->name, pcmc->smbios_legacy_mode); }/* allocate ram and load rom/bios */
@@ -297,7 +297,6 @@ static void pc_init_pci(MachineState *machine)static void pc_compat_2_0 (MachineState *machine) { - smbios_legacy_mode = true; has_reserved_memory = false; }
@@ -405,7 +404,6 @@ static void pc_init_isa(MachineState *machine) has_acpi_build = false; smbios_defaults = false; gigabyte_align = false; - smbios_legacy_mode = true; has_reserved_memory = false; option_rom_has_mr = true; rom_file_has_mr = false;
@@ -466,6 +464,7 @@ static const TypeInfo pc_i440fx_machine_v2_1_type_info = {static void pc_i440fx_machine_v2_0_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_2_0 , {/* end of list */ }
@@ -476,6 +475,7 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data) mc->init = pc_init_pci_2_0; mc->name ="pc-i440fx-2.0" ;machine_class_add_compat_props (mc, compat_props); + pcmc->smbios_legacy_mode = true; }static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
@@ -966,6 +966,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data) {/* end of list */ } }; pcmc->pci_enabled = false; + pcmc->smbios_legacy_mode = true; mc->desc ="ISA-only PC" ; mc->init = pc_init_isa; mc->max_cpus =1 ;
hw/i386/pc_q35.c +4 -3
@@ -52,7 +52,6 @@static bool has_pci_info;static bool has_acpi_build = true;static bool smbios_defaults = true; -static bool smbios_legacy_mode;/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * pages in the host.
@@ -158,9 +157,10 @@ static void pc_q35_init(MachineState *machine)if (smbios_defaults) {MachineClass *mc =MACHINE_GET_CLASS (machine); +PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine);/* These values are guest ABI, do not change */ smbios_set_defaults ("QEMU" ,"Standard PC (Q35 + ICH9, 2009)" , - mc->name, smbios_legacy_mode); + mc->name, pcmc->smbios_legacy_mode); }/* allocate ram and load rom/bios */
@@ -276,7 +276,6 @@ static void pc_q35_init(MachineState *machine)static void pc_compat_2_0 (MachineState *machine) { - smbios_legacy_mode = true; has_reserved_memory = false; }
@@ -375,6 +374,7 @@ static TypeInfo pc_q35_machine_v2_1_type_info = {static void pc_q35_machine_v2_0_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_2_0 , {/* end of list */ }
@@ -384,6 +384,7 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data) mc->init = pc_q35_init_2_0;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-2.0" ; + pcmc->smbios_legacy_mode = true; }static TypeInfo pc_q35_machine_v2_0_type_info = {
include/hw/i386/pc.h +1 -0
@@ -55,6 +55,7 @@ struct PCMachineClass { DeviceState *dev);bool pci_enabled;bool kvmclock_enabled; +bool smbios_legacy_mode; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 24/35 pc: Move smbios_defaults to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 9 ++++----- hw/i386/pc_q35.c | 7 +++---- include/hw/i386/pc.h | 1 + 4 files changed, 9 insertions(+), 9 deletions(-)
hw/i386/pc.c +1 -0
@@ -1664,6 +1664,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->get_hotplug_handler = mc->get_hotplug_handler; pcmc->pci_enabled = true; pcmc->kvmclock_enabled = true; + pcmc->smbios_defaults = true; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->default_boot_order ="cad" ; mc->hot_add_cpu = pc_hot_add_cpu;
hw/i386/pc_piix.c +4 -5
@@ -61,7 +61,6 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };static bool has_pci_info;static bool has_acpi_build = true; -static bool smbios_defaults = true;/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * pages in the host.
@@ -167,9 +166,8 @@ static void pc_init1(MachineState *machine) guest_info->isapc_ram_fw = !pci_enabled; guest_info->has_reserved_memory = has_reserved_memory; -if (smbios_defaults) { +if (pcmc->smbios_defaults) {MachineClass *mc =MACHINE_GET_CLASS (machine); -PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (mc);/* These values are guest ABI, do not change */ smbios_set_defaults ("QEMU" ,"Standard PC (i440FX + PIIX, 1996)" , mc->name, pcmc->smbios_legacy_mode);
@@ -303,7 +301,6 @@ static void pc_compat_2_0(MachineState *machine)static void pc_compat_1_7 (MachineState *machine) {pc_compat_2_0 (machine); - smbios_defaults = false; gigabyte_align = false; option_rom_has_mr = true;x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC );
@@ -402,7 +399,6 @@ static void pc_init_isa(MachineState *machine) { has_pci_info = false; has_acpi_build = false; - smbios_defaults = false; gigabyte_align = false; has_reserved_memory = false; option_rom_has_mr = true;
@@ -487,6 +483,7 @@ static const TypeInfo pc_i440fx_machine_v2_0_type_info = {static void pc_i440fx_machine_v1_7_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_1_7 , {/* end of list */ }
@@ -496,6 +493,7 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data) mc->init = pc_init_pci_1_7; mc->name ="pc-i440fx-1.7" ;machine_class_add_compat_props (mc, compat_props); + pcmc->smbios_defaults = false; }static const TypeInfo pc_i440fx_machine_v1_7_type_info = {
@@ -973,6 +971,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data) mc->hot_add_cpu =NULL ; mc->name ="isapc" ;machine_class_add_compat_props (mc, compat_props); + pcmc->smbios_defaults = false; }static const TypeInfo isapc_machine_type_info = {
hw/i386/pc_q35.c +3 -4
@@ -51,7 +51,6 @@static bool has_pci_info;static bool has_acpi_build = true; -static bool smbios_defaults = true;/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * pages in the host.
@@ -155,9 +154,8 @@ static void pc_q35_init(MachineState *machine) guest_info->has_acpi_build = has_acpi_build; guest_info->has_reserved_memory = has_reserved_memory; -if (smbios_defaults) { +if (pcmc->smbios_defaults) {MachineClass *mc =MACHINE_GET_CLASS (machine); -PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine);/* These values are guest ABI, do not change */ smbios_set_defaults ("QEMU" ,"Standard PC (Q35 + ICH9, 2009)" , mc->name, pcmc->smbios_legacy_mode);
@@ -282,7 +280,6 @@ static void pc_compat_2_0(MachineState *machine)static void pc_compat_1_7 (MachineState *machine) {pc_compat_2_0 (machine); - smbios_defaults = false; gigabyte_align = false; option_rom_has_mr = true;x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC );
@@ -396,6 +393,7 @@ static TypeInfo pc_q35_machine_v2_0_type_info = {static void pc_q35_machine_v1_7_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_1_7 , {/* end of list */ }
@@ -405,6 +403,7 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data) mc->init = pc_q35_init_1_7;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.7" ; + pcmc->smbios_defaults = false; }static TypeInfo pc_q35_machine_v1_7_type_info = {
include/hw/i386/pc.h +1 -0
@@ -56,6 +56,7 @@ struct PCMachineClass {bool pci_enabled;bool kvmclock_enabled;bool smbios_legacy_mode; +bool smbios_defaults; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 25/35 pc: Move has_acpi_build to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 8 ++++---- hw/i386/pc_q35.c | 6 +++--- include/hw/i386/pc.h | 1 + 4 files changed, 9 insertions(+), 7 deletions(-)
hw/i386/pc.c +1 -0
@@ -1665,6 +1665,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->pci_enabled = true; pcmc->kvmclock_enabled = true; pcmc->smbios_defaults = true; + pcmc->has_acpi_build = true; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->default_boot_order ="cad" ; mc->hot_add_cpu = pc_hot_add_cpu;
hw/i386/pc_piix.c +4 -4
@@ -60,7 +60,6 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };static const int ide_irq[MAX_IDE_BUS ] = {14 ,15 };static bool has_pci_info; -static bool has_acpi_build = true;/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * pages in the host.
@@ -160,7 +159,7 @@ static void pc_init1(MachineState *machine) guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); - guest_info->has_acpi_build = has_acpi_build; + guest_info->has_acpi_build = pcmc->has_acpi_build; guest_info->has_pci_info = has_pci_info; guest_info->isapc_ram_fw = !pci_enabled;
@@ -311,7 +310,6 @@ static void pc_compat_1_6(MachineState *machine)pc_compat_1_7 (machine); has_pci_info = false; rom_file_has_mr = false; - has_acpi_build = false; }static void pc_compat_1_5 (MachineState *machine)
@@ -398,7 +396,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)static void pc_init_isa (MachineState *machine) { has_pci_info = false; - has_acpi_build = false; gigabyte_align = false; has_reserved_memory = false; option_rom_has_mr = true;
@@ -505,6 +502,7 @@ static const TypeInfo pc_i440fx_machine_v1_7_type_info = {static void pc_i440fx_machine_v1_6_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_1_6 , {/* end of list */ }
@@ -513,6 +511,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data) mc->init = pc_init_pci_1_6; mc->name ="pc-i440fx-1.6" ;machine_class_add_compat_props (mc, compat_props); + pcmc->has_acpi_build = false; }static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
@@ -972,6 +971,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data) mc->name ="isapc" ;machine_class_add_compat_props (mc, compat_props); pcmc->smbios_defaults = false; + pcmc->has_acpi_build = false; }static const TypeInfo isapc_machine_type_info = {
hw/i386/pc_q35.c +3 -3
@@ -50,7 +50,6 @@#define MAX_SATA_PORTS 6static bool has_pci_info; -static bool has_acpi_build = true;/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * pages in the host.
@@ -151,7 +150,7 @@ static void pc_q35_init(MachineState *machine) guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); guest_info->has_pci_info = has_pci_info; guest_info->isapc_ram_fw = false; - guest_info->has_acpi_build = has_acpi_build; + guest_info->has_acpi_build = pcmc->has_acpi_build; guest_info->has_reserved_memory = has_reserved_memory;if (pcmc->smbios_defaults) {
@@ -290,7 +289,6 @@ static void pc_compat_1_6(MachineState *machine)pc_compat_1_7 (machine); has_pci_info = false; rom_file_has_mr = false; - has_acpi_build = false; }static void pc_compat_1_5 (MachineState *machine)
@@ -415,6 +413,7 @@ static TypeInfo pc_q35_machine_v1_7_type_info = {static void pc_q35_machine_v1_6_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_1_6 , {/* end of list */ }
@@ -423,6 +422,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data) mc->init = pc_q35_init_1_6;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.6" ; + pcmc->has_acpi_build = false; }static TypeInfo pc_q35_machine_v1_6_type_info = {
include/hw/i386/pc.h +1 -0
@@ -57,6 +57,7 @@ struct PCMachineClass {bool kvmclock_enabled;bool smbios_legacy_mode;bool smbios_defaults; +bool has_acpi_build; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 26/35 pc: Move has_pci_info to PCMachineClass
In reply to Eduardo HabkostInterestingly, no existing code sets has_pci_info=true at all.
A has_pci_info=false line was added to isapc class_init, just in case we enable it on the other PC machine-types one day.
--- hw/i386/pc_piix.c | 6 ++---- hw/i386/pc_q35.c | 4 +--- include/hw/i386/pc.h | 1 + 3 files changed, 4 insertions(+), 7 deletions(-)
hw/i386/pc_piix.c +2 -4
@@ -59,7 +59,6 @@ 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 has_pci_info;/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * pages in the host.
@@ -161,7 +160,7 @@ static void pc_init1(MachineState *machine) guest_info->has_acpi_build = pcmc->has_acpi_build; - guest_info->has_pci_info = has_pci_info; + guest_info->has_pci_info = pcmc->has_pci_info; guest_info->isapc_ram_fw = !pci_enabled; guest_info->has_reserved_memory = has_reserved_memory;
@@ -308,7 +307,6 @@ static void pc_compat_1_7(MachineState *machine)static void pc_compat_1_6 (MachineState *machine) {pc_compat_1_7 (machine); - has_pci_info = false; rom_file_has_mr = false; }
@@ -395,7 +393,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)static void pc_init_isa (MachineState *machine) { - has_pci_info = false; gigabyte_align = false; has_reserved_memory = false; option_rom_has_mr = true;
@@ -972,6 +969,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)machine_class_add_compat_props (mc, compat_props); pcmc->smbios_defaults = false; pcmc->has_acpi_build = false; + pcmc->has_pci_info = false; }static const TypeInfo isapc_machine_type_info = {
hw/i386/pc_q35.c +1 -3
@@ -49,7 +49,6 @@/* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6 -static bool has_pci_info;/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * pages in the host.
@@ -148,7 +147,7 @@ static void pc_q35_init(MachineState *machine) } guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); - guest_info->has_pci_info = has_pci_info; + guest_info->has_pci_info = pcmc->has_pci_info; guest_info->isapc_ram_fw = false; guest_info->has_acpi_build = pcmc->has_acpi_build; guest_info->has_reserved_memory = has_reserved_memory;
@@ -287,7 +286,6 @@ static void pc_compat_1_7(MachineState *machine)static void pc_compat_1_6 (MachineState *machine) {pc_compat_1_7 (machine); - has_pci_info = false; rom_file_has_mr = false; }
include/hw/i386/pc.h +1 -0
@@ -58,6 +58,7 @@ struct PCMachineClass {bool smbios_legacy_mode;bool smbios_defaults;bool has_acpi_build; +bool has_pci_info; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 27/35 pc: Move gigabyte_align to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 11 +++-------- hw/i386/pc_q35.c | 9 ++------- include/hw/i386/pc.h | 5 +++++ 4 files changed, 11 insertions(+), 15 deletions(-)
hw/i386/pc.c +1 -0
@@ -1666,6 +1666,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->kvmclock_enabled = true; pcmc->smbios_defaults = true; pcmc->has_acpi_build = true; + pcmc->gigabyte_align = true; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->default_boot_order ="cad" ; mc->hot_add_cpu = pc_hot_add_cpu;
hw/i386/pc_piix.c +3 -8
@@ -59,11 +59,6 @@ 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 }; -/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to -* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte -* pages in the host. -*/ -static bool gigabyte_align = true;static bool has_reserved_memory = true;/* PC hardware initialisation */
@@ -105,7 +100,7 @@ static void pc_init1(MachineState *machine)* breaking migration. */ if (machine->ram_size >=0xe0000000 ) { - lowmem = gigabyte_align ?0xc0000000 :0xe0000000 ; + lowmem = pcmc->gigabyte_align ?0xc0000000 :0xe0000000 ; }else { lowmem =0xe0000000 ; }
@@ -299,7 +294,6 @@ static void pc_compat_2_0(MachineState *machine)static void pc_compat_1_7 (MachineState *machine) {pc_compat_2_0 (machine); - gigabyte_align = false; option_rom_has_mr = true;x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); }
@@ -393,7 +387,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)static void pc_init_isa (MachineState *machine) { - gigabyte_align = false; has_reserved_memory = false; option_rom_has_mr = true; rom_file_has_mr = false;
@@ -488,6 +481,7 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data) mc->name ="pc-i440fx-1.7" ;machine_class_add_compat_props (mc, compat_props); pcmc->smbios_defaults = false; + pcmc->gigabyte_align = false; }static const TypeInfo pc_i440fx_machine_v1_7_type_info = {
@@ -970,6 +964,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data) pcmc->smbios_defaults = false; pcmc->has_acpi_build = false; pcmc->has_pci_info = false; + pcmc->gigabyte_align = false; }static const TypeInfo isapc_machine_type_info = {
hw/i386/pc_q35.c +2 -7
@@ -49,11 +49,6 @@/* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6 -/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to -* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte -* pages in the host. -*/ -static bool gigabyte_align = true;static bool has_reserved_memory = true;/* PC hardware initialisation */
@@ -95,7 +90,7 @@ static void pc_q35_init(MachineState *machine)* breaking migration. */ if (machine->ram_size >=0xb0000000 ) { - lowmem = gigabyte_align ?0x80000000 :0xb0000000 ; + lowmem = pcmc->gigabyte_align ?0x80000000 :0xb0000000 ; }else { lowmem =0xb0000000 ; }
@@ -278,7 +273,6 @@ static void pc_compat_2_0(MachineState *machine)static void pc_compat_1_7 (MachineState *machine) {pc_compat_2_0 (machine); - gigabyte_align = false; option_rom_has_mr = true;x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); }
@@ -400,6 +394,7 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.7" ; pcmc->smbios_defaults = false; + pcmc->gigabyte_align = false; }static TypeInfo pc_q35_machine_v1_7_type_info = {
include/hw/i386/pc.h +5 -0
@@ -59,6 +59,11 @@ struct PCMachineClass {bool smbios_defaults;bool has_acpi_build;bool has_pci_info; +/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to +* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte +* pages in the host. +*/ +bool gigabyte_align; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 28/35 pc: Move has_reserved_memory to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 8 +++----- hw/i386/pc_q35.c | 6 ++---- include/hw/i386/pc.h | 1 + 4 files changed, 7 insertions(+), 9 deletions(-)
hw/i386/pc.c +1 -0
@@ -1667,6 +1667,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->smbios_defaults = true; pcmc->has_acpi_build = true; pcmc->gigabyte_align = true; + pcmc->has_reserved_memory = true; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->default_boot_order ="cad" ; mc->hot_add_cpu = pc_hot_add_cpu;
hw/i386/pc_piix.c +3 -5
@@ -59,8 +59,6 @@ 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 has_reserved_memory = true; -/* PC hardware initialisation */ static void pc_init1 (MachineState *machine) {
@@ -157,7 +155,7 @@ static void pc_init1(MachineState *machine) guest_info->has_pci_info = pcmc->has_pci_info; guest_info->isapc_ram_fw = !pci_enabled; - guest_info->has_reserved_memory = has_reserved_memory; + guest_info->has_reserved_memory = pcmc->has_reserved_memory;if (pcmc->smbios_defaults) {MachineClass *mc =MACHINE_GET_CLASS (machine);
@@ -288,7 +286,6 @@ static void pc_init_pci(MachineState *machine)static void pc_compat_2_0 (MachineState *machine) { - has_reserved_memory = false; }static void pc_compat_1_7 (MachineState *machine)
@@ -387,7 +384,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)static void pc_init_isa (MachineState *machine) { - has_reserved_memory = false; option_rom_has_mr = true; rom_file_has_mr = false;if (!machine->cpu_model) {
@@ -459,6 +455,7 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data) mc->name ="pc-i440fx-2.0" ;machine_class_add_compat_props (mc, compat_props); pcmc->smbios_legacy_mode = true; + pcmc->has_reserved_memory = false; }static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
@@ -965,6 +962,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data) pcmc->has_acpi_build = false; pcmc->has_pci_info = false; pcmc->gigabyte_align = false; + pcmc->has_reserved_memory = false; }static const TypeInfo isapc_machine_type_info = {
hw/i386/pc_q35.c +2 -4
@@ -49,8 +49,6 @@/* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6 -static bool has_reserved_memory = true; -/* PC hardware initialisation */ static void pc_q35_init (MachineState *machine) {
@@ -145,7 +143,7 @@ static void pc_q35_init(MachineState *machine) guest_info->has_pci_info = pcmc->has_pci_info; guest_info->isapc_ram_fw = false; guest_info->has_acpi_build = pcmc->has_acpi_build; - guest_info->has_reserved_memory = has_reserved_memory; + guest_info->has_reserved_memory = pcmc->has_reserved_memory;if (pcmc->smbios_defaults) {MachineClass *mc =MACHINE_GET_CLASS (machine);
@@ -267,7 +265,6 @@ static void pc_q35_init(MachineState *machine)static void pc_compat_2_0 (MachineState *machine) { - has_reserved_memory = false; }static void pc_compat_1_7 (MachineState *machine)
@@ -372,6 +369,7 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-2.0" ; pcmc->smbios_legacy_mode = true; + pcmc->has_reserved_memory = false; }static TypeInfo pc_q35_machine_v2_0_type_info = {
include/hw/i386/pc.h +1 -0
@@ -64,6 +64,7 @@ struct PCMachineClass {* pages in the host. */ bool gigabyte_align; +bool has_reserved_memory; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 29/35 pc: Move option_rom_has_mr/rom_file_has_mr to MachineClass
In reply to Eduardo HabkostThis way, these settings can be simply set on the class_init function, instead of requiring a separate machine init function just to set global variables.
--- hw/core/loader.c | 12 +++++++----- hw/core/machine.c | 1 + hw/i386/pc_piix.c | 8 ++++---- hw/i386/pc_q35.c | 4 ++-- include/hw/boards.h | 2 ++ 5 files changed, 16 insertions(+), 11 deletions(-)
hw/core/loader.c +7 -5
@@ -51,12 +51,10 @@#include "hw/nvram/fw_cfg.h" #include "exec/memory.h" #include "exec/address-spaces.h" +#include "hw/boards.h" #include <zlib.h> -bool option_rom_has_mr = false; -bool rom_file_has_mr = true; -static int roms_loaded;/* return the size or -1 if error */
@@ -646,6 +644,8 @@ int rom_add_file(const char *file, const char *fw_dir, hwaddr addr, int32_t bootindex, bool option_rom) { + MachineState *machine = current_machine; +MachineClass *mc =MACHINE_GET_CLASS (machine);Rom *rom;int rc, fd =-1 ;char devpath[100 ];
@@ -696,7 +696,7 @@ int rom_add_file(const char *file, const char *fw_dir, basename);snprintf (devpath,sizeof (devpath),"/rom@%s" , fw_file_name); -if ((!option_rom || option_rom_has_mr) && rom_file_has_mr) { +if ((!option_rom || mc->option_rom_has_mr) && mc->rom_file_has_mr) { data =rom_set_mr (rom,OBJECT (fw_cfg), devpath); }else { data = rom->data;
@@ -724,6 +724,8 @@ void *rom_add_blob(const char *name, const void *blob, size_t len, hwaddr addr, const char *fw_file_name, FWCfgReadCallback fw_callback, void *callback_opaque) { + MachineState *machine = current_machine; +MachineClass *mc =MACHINE_GET_CLASS (machine);Rom *rom;void *data =NULL ;
@@ -740,7 +742,7 @@ void *rom_add_blob(const char *name, const void *blob, size_t len,snprintf (devpath,sizeof (devpath),"/rom@%s" , fw_file_name); -if (rom_file_has_mr) { +if (mc->rom_file_has_mr) { data =rom_set_mr (rom,OBJECT (fw_cfg), devpath); }else { data = rom->data;
hw/core/machine.c +1 -0
@@ -302,6 +302,7 @@ static void machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc);QTAILQ_INIT (&mc->compat_props); + mc->rom_file_has_mr = true; }static const TypeInfo machine_info = {
hw/i386/pc_piix.c +4 -4
@@ -291,14 +291,12 @@ static void pc_compat_2_0(MachineState *machine)static void pc_compat_1_7 (MachineState *machine) {pc_compat_2_0 (machine); - option_rom_has_mr = true;x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); }static void pc_compat_1_6 (MachineState *machine) {pc_compat_1_7 (machine); - rom_file_has_mr = false; }static void pc_compat_1_5 (MachineState *machine)
@@ -384,8 +382,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)static void pc_init_isa (MachineState *machine) { - option_rom_has_mr = true; - rom_file_has_mr = false;if (!machine->cpu_model) { machine->cpu_model ="486" ; }
@@ -476,6 +472,7 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data) mc->default_machine_opts =NULL ; mc->init = pc_init_pci_1_7; mc->name ="pc-i440fx-1.7" ; + mc->option_rom_has_mr = true;machine_class_add_compat_props (mc, compat_props); pcmc->smbios_defaults = false; pcmc->gigabyte_align = false;
@@ -498,6 +495,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)pc_i440fx_machine_v1_7_class_init (oc, data); mc->init = pc_init_pci_1_6; mc->name ="pc-i440fx-1.6" ; + mc->rom_file_has_mr = false;machine_class_add_compat_props (mc, compat_props); pcmc->has_acpi_build = false; }
@@ -957,6 +955,8 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =1 ; mc->hot_add_cpu =NULL ; mc->name ="isapc" ; + mc->option_rom_has_mr = true; + mc->rom_file_has_mr = false;machine_class_add_compat_props (mc, compat_props); pcmc->smbios_defaults = false; pcmc->has_acpi_build = false;
hw/i386/pc_q35.c +2 -2
@@ -270,14 +270,12 @@ static void pc_compat_2_0(MachineState *machine)static void pc_compat_1_7 (MachineState *machine) {pc_compat_2_0 (machine); - option_rom_has_mr = true;x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); }static void pc_compat_1_6 (MachineState *machine) {pc_compat_1_7 (machine); - rom_file_has_mr = false; }static void pc_compat_1_5 (MachineState *machine)
@@ -389,6 +387,7 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)pc_q35_machine_v2_0_class_init (oc, data); mc->default_machine_opts =NULL ; mc->init = pc_q35_init_1_7; + mc->option_rom_has_mr = true;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.7" ; pcmc->smbios_defaults = false;
@@ -411,6 +410,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data) };pc_q35_machine_v1_7_class_init (oc, data); mc->init = pc_q35_init_1_6; + mc->rom_file_has_mr = false;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.6" ; pcmc->has_acpi_build = false;
include/hw/boards.h +2 -0
@@ -99,6 +99,8 @@ struct MachineClass {const char *default_boot_order;GlobalPropertyList compat_props;const char *hw_version; +bool option_rom_has_mr; +bool rom_file_has_mr; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);
Signature · 1 line
1.9.3
RFC v3 30/35 piix: Eliminate pc_init_pci()
In reply to Eduardo HabkostNow pc_init1() can be called directly.
--- hw/i386/pc_piix.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
hw/i386/pc_piix.c +10 -15
@@ -279,11 +279,6 @@ static void pc_init1(MachineState *machine) } } -static void pc_init_pci (MachineState *machine) -{ -pc_init1 (machine); -} -static void pc_compat_2_0 (MachineState *machine) { }
@@ -333,51 +328,51 @@ static void pc_compat_0_13(MachineState *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, and reused by xenfv */ 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)
@@ -395,7 +390,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 ) {
@@ -425,7 +420,7 @@ static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc); mc->default_machine_opts ="firmware=bios-256k.bin" ; mc->alias ="pc" ; - mc->init = pc_init_pci; + mc->init = pc_init1; mc->is_default =1 ; mc->name ="pc-i440fx-2.1" ; }
Signature · 1 line
1.9.3
RFC v3 31/35 piix: Introduce struct PCI440FXMachineClass
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +15 -2
@@ -399,6 +399,20 @@ static void pc_xen_hvm_init(MachineState *machine) }#endif +/** +* PCI440FXMachineClass; +*/ +typedef struct PCI440FXMachineClass { +/*< private >*/ +PCMachineClass parent_class; +}PCI440FXMachineClass ; + +#define TYPE_PC_I440FX_MACHINE "pc-i440fx" TYPE_MACHINE_SUFFIX +#define PC_I440FX_MACHINE_CLASS (klass) \ + OBJECT_CLASS_CHECK(PCI440FXMachineClass, (klass), TYPE_PC_I440FX_MACHINE) +#define PC_I440FX_MACHINE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(PCI440FXMachineClass, (obj), TYPE_PC_I440FX_MACHINE) +static void pc_i440fx_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -406,12 +420,11 @@ static void pc_i440fx_machine_class_init(ObjectClass *oc, void *data) mc->hot_add_cpu = pc_hot_add_cpu; } -#define TYPE_PC_I440FX_MACHINE "pc-i440fx" TYPE_MACHINE_SUFFIX -static TypeInfo pc_i440fx_machine_type_info = { .name =TYPE_PC_I440FX_MACHINE , .parent =TYPE_PC_MACHINE , .class_init = pc_i440fx_machine_class_init, + .class_size =sizeof (PCI440FXMachineClass), .abstract = true, };
Signature · 1 line
1.9.3
RFC v3 32/35 pc: Create common machine init function
In reply to Eduardo HabkostThis allows us to eliminate all the trivial pc_init_*() functions which just call a compat function followed by pc_init1(), and slowly move duplicate code from piix and q35 init functions into common PC code.
--- hw/i386/pc.c | 12 ++++++++ hw/i386/pc_piix.c | 83 +++++++++++++--------------------------------------- hw/i386/pc_q35.c | 45 ++++++---------------------- include/hw/i386/pc.h | 4 +++ 4 files changed, 45 insertions(+), 99 deletions(-)
hw/i386/pc.c +12 -0
@@ -1655,6 +1655,17 @@ static void pc_machine_initfn(Object *obj) NULL, NULL, NULL); } +static void pc_machine_init (MachineState *machine) +{ +PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine); +if (pcmc->compat_func) { + pcmc->compat_func (machine); + } +if (pcmc->finish_init) { + pcmc->finish_init (machine); + } +} +static void pc_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1668,6 +1679,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->has_acpi_build = true; pcmc->gigabyte_align = true; pcmc->has_reserved_memory = true; + mc->init = pc_machine_init; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->default_boot_order ="cad" ; mc->hot_add_cpu = pc_hot_add_cpu;
hw/i386/pc_piix.c +20 -63
231 lines not on this page · raw message
hw/i386/pc_q35.c +9 -36
115 lines not on this page · raw message
include/hw/i386/pc.h +4 -0
@@ -45,6 +45,8 @@ struct PCMachineState {/** * PCMachineClass: * @get_hotplug_handler: pointer to parent class callback @get_hotplug_handler +* @finish_init: Subclass-specific function to finish initialization. +* @compat_func: Compatiblity function to be called before initialization. */ struct PCMachineClass {/*< private >*/
@@ -65,6 +67,8 @@ struct PCMachineClass {*/ bool gigabyte_align;bool has_reserved_memory; +void (*finish_init)(MachineState *machine); +void (*compat_func)(MachineState *machine); };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.3
RFC v3 33/35 pc: Eliminate empty or trivial compat functions
In reply to Eduardo HabkostWhen all a compat function does is to call the previous compat function, we don't need to set compat_func, as the previous class_init function already set it.
--- hw/i386/pc_piix.c | 29 +---------------------------- hw/i386/pc_q35.c | 21 +-------------------- 2 files changed, 2 insertions(+), 48 deletions(-)
hw/i386/pc_piix.c +1 -28
@@ -279,29 +279,14 @@ static void pc_init1(MachineState *machine) } } -static void pc_compat_2_0 (MachineState *machine) -{ -} -static void pc_compat_1_7 (MachineState *machine) { -pc_compat_2_0 (machine);x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); } -static void pc_compat_1_6 (MachineState *machine) -{ -pc_compat_1_7 (machine); -} - -static void pc_compat_1_5 (MachineState *machine) -{ -pc_compat_1_6 (machine); -} -static void pc_compat_1_4 (MachineState *machine) { -pc_compat_1_5 (machine); +pc_compat_1_7 (machine);x86_cpu_compat_set_features ("n270" ,FEAT_1_ECX ,0 ,CPUID_EXT_MOVBE );x86_cpu_compat_set_features ("Westmere" ,FEAT_1_ECX ,0 ,CPUID_EXT_PCLMULQDQ ); }
@@ -312,19 +297,12 @@ static void pc_compat_1_3(MachineState *machine)enable_compat_apic_id_mode (); } -/* PC compat function for pc-0.14 to pc-1.2 */ static void pc_compat_1_2 (MachineState *machine) {pc_compat_1_3 (machine);x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); } -/* PC compat function for pc-0.10 to pc-0.13 */ -static void pc_compat_0_13 (MachineState *machine) -{ -pc_compat_1_2 (machine); -} -static void pc_compat_isa (MachineState *machine) {if (!machine->cpu_model) {
@@ -409,7 +387,6 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)machine_class_add_compat_props (mc, compat_props); pcmc->smbios_legacy_mode = true; pcmc->has_reserved_memory = false; - pcmc->compat_func = pc_compat_2_0; }static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
@@ -455,7 +432,6 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data) mc->rom_file_has_mr = false;machine_class_add_compat_props (mc, compat_props); pcmc->has_acpi_build = false; - pcmc->compat_func = pc_compat_1_6; }static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
@@ -467,7 +443,6 @@ static const TypeInfo pc_i440fx_machine_v1_6_type_info = {static void pc_i440fx_machine_v1_5_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); -PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_1_5 , {/* end of list */ }
@@ -475,7 +450,6 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)pc_i440fx_machine_v1_6_class_init (oc, data); mc->name ="pc-i440fx-1.5" ;machine_class_add_compat_props (mc, compat_props); - pcmc->compat_func = pc_compat_1_5; }static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
@@ -775,7 +749,6 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data) mc->hw_version ="0.13" ; mc->name ="pc-0.13" ;machine_class_add_compat_props (mc, compat_props); - pcmc->compat_func = pc_compat_0_13; pcmc->kvmclock_enabled = false; }
hw/i386/pc_q35.c +1 -20
@@ -263,29 +263,14 @@ static void pc_q35_init(MachineState *machine) } } -static void pc_compat_2_0 (MachineState *machine) -{ -} -static void pc_compat_1_7 (MachineState *machine) { -pc_compat_2_0 (machine);x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); } -static void pc_compat_1_6 (MachineState *machine) -{ -pc_compat_1_7 (machine); -} - -static void pc_compat_1_5 (MachineState *machine) -{ -pc_compat_1_6 (machine); -} -static void pc_compat_1_4 (MachineState *machine) { -pc_compat_1_5 (machine); +pc_compat_1_7 (machine);x86_cpu_compat_set_features ("n270" ,FEAT_1_ECX ,0 ,CPUID_EXT_MOVBE );x86_cpu_compat_set_features ("Westmere" ,FEAT_1_ECX ,0 ,CPUID_EXT_PCLMULQDQ ); }
@@ -338,7 +323,6 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data) mc->name ="pc-q35-2.0" ; pcmc->smbios_legacy_mode = true; pcmc->has_reserved_memory = false; - pcmc->compat_func = pc_compat_2_0; }static TypeInfo pc_q35_machine_v2_0_type_info = {
@@ -383,7 +367,6 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data) mc->rom_file_has_mr = false;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.6" ; - pcmc->compat_func = pc_compat_1_6; pcmc->has_acpi_build = false; }
@@ -396,7 +379,6 @@ static TypeInfo pc_q35_machine_v1_6_type_info = {static void pc_q35_machine_v1_5_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); -PCMachineClass *pcmc =PC_MACHINE_CLASS (oc);static GlobalProperty compat_props[] = {PC_COMPAT_1_5 , {/* end of list */ }
@@ -404,7 +386,6 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)pc_q35_machine_v1_6_class_init (oc, data);machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-1.5" ; - pcmc->compat_func = pc_compat_1_5; }static TypeInfo pc_q35_machine_v1_5_type_info = {
Signature · 1 line
1.9.3
RFC v3 34/35 piix: Move compat/init functions closer to corresponding class_init
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 92 +++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 47 deletions(-)
hw/i386/pc_piix.c +45 -47
@@ -279,53 +279,6 @@ static void pc_init1(MachineState *machine) } } -static void pc_compat_1_7 (MachineState *machine) -{ -x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); -} - -static void pc_compat_1_4 (MachineState *machine) -{ -pc_compat_1_7 (machine); -x86_cpu_compat_set_features ("n270" ,FEAT_1_ECX ,0 ,CPUID_EXT_MOVBE ); -x86_cpu_compat_set_features ("Westmere" ,FEAT_1_ECX ,0 ,CPUID_EXT_PCLMULQDQ ); -} - -static void pc_compat_1_3 (MachineState *machine) -{ -pc_compat_1_4 (machine); -enable_compat_apic_id_mode (); -} - -static void pc_compat_1_2 (MachineState *machine) -{ -pc_compat_1_3 (machine); -x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); -} - -static void pc_compat_isa (MachineState *machine) -{ -if (!machine->cpu_model) { - machine->cpu_model ="486" ; - } -x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); -enable_compat_apic_id_mode (); -} - -#ifdef CONFIG_XEN -static void pc_xen_hvm_init (MachineState *machine) -{ -PCIBus *bus; - -pc_init1 (machine); - - bus =pci_find_primary_bus (); -if (bus !=NULL ) { -pci_create_simple (bus,-1 ,"xen-platform" ); - } -} -#endif -/** * PCI440FXMachineClass; */
@@ -395,6 +348,11 @@ static const TypeInfo pc_i440fx_machine_v2_0_type_info = { .class_init = pc_i440fx_machine_v2_0_class_init, }; +static void pc_compat_1_7 (MachineState *machine) +{ +x86_cpu_compat_disable_kvm_features (FEAT_1_ECX ,CPUID_EXT_X2APIC ); +} +static void pc_i440fx_machine_v1_7_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -458,6 +416,13 @@ static const TypeInfo pc_i440fx_machine_v1_5_type_info = { .class_init = pc_i440fx_machine_v1_5_class_init, }; +static void pc_compat_1_4 (MachineState *machine) +{ +pc_compat_1_7 (machine); +x86_cpu_compat_set_features ("n270" ,FEAT_1_ECX ,0 ,CPUID_EXT_MOVBE ); +x86_cpu_compat_set_features ("Westmere" ,FEAT_1_ECX ,0 ,CPUID_EXT_PCLMULQDQ ); +} +static void pc_i440fx_machine_v1_4_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -498,6 +463,12 @@ static const TypeInfo pc_i440fx_machine_v1_4_type_info = { .value = "off",\ } +static void pc_compat_1_3 (MachineState *machine) +{ +pc_compat_1_4 (machine); +enable_compat_apic_id_mode (); +} +static void pc_machine_v1_3_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -545,6 +516,12 @@ static const TypeInfo pc_machine_v1_3_type_info = { .value = "off",\ } +static void pc_compat_1_2 (MachineState *machine) +{ +pc_compat_1_3 (machine); +x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); +} +static void pc_machine_v1_2_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -877,6 +854,15 @@ static const TypeInfo pc_machine_v0_10_type_info = { .class_init = pc_machine_v0_10_class_init, }; +static void pc_compat_isa (MachineState *machine) +{ +if (!machine->cpu_model) { + machine->cpu_model ="486" ; + } +x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); +enable_compat_apic_id_mode (); +} +static void isapc_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -909,6 +895,18 @@ static const TypeInfo isapc_machine_type_info = { };#ifdef CONFIG_XEN +static void pc_xen_hvm_init (MachineState *machine) +{ +PCIBus *bus; + +pc_init1 (machine); + + bus =pci_find_primary_bus (); +if (bus !=NULL ) { +pci_create_simple (bus,-1 ,"xen-platform" ); + } +} +static void xenfv_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
Signature · 1 line
1.9.3
RFC v3 35/35 pc: Move {ram, pci, rom}_memory variables to PCMachineState
In reply to Eduardo Habkost---
Changes v2:
* Use PCMachineState fields inside pc_memory_init() too
--- hw/i386/pc.c | 8 +++----- hw/i386/pc_piix.c | 19 ++++++++----------- hw/i386/pc_q35.c | 22 +++++++++------------- include/hw/i386/pc.h | 5 +++-- 4 files changed, 23 insertions(+), 31 deletions(-)
hw/i386/pc.c +3 -5
@@ -1194,8 +1194,6 @@ FWCfgState *pc_memory_init(MachineState *machine,MemoryRegion *system_memory, ram_addr_t below_4g_mem_size, ram_addr_t above_4g_mem_size, - MemoryRegion *rom_memory, - MemoryRegion **ram_memory, PcGuestInfo *guest_info) { int linux_boot, i;
@@ -1215,7 +1213,7 @@ FWCfgState *pc_memory_init(MachineState *machine, ram =g_malloc (sizeof (*ram));memory_region_allocate_system_memory (ram,NULL ,"pc.ram" , machine->ram_size); - *ram_memory = ram; + pcms->ram_memory = ram; ram_below_4g =g_malloc (sizeof (*ram_below_4g));memory_region_init_alias (ram_below_4g,NULL ,"ram-below-4g" , ram,0 , below_4g_mem_size);
@@ -1269,12 +1267,12 @@ FWCfgState *pc_memory_init(MachineState *machine, }/* Initialize PC system firmware */ -pc_system_firmware_init (rom_memory, guest_info->isapc_ram_fw); +pc_system_firmware_init (pcms->rom_memory, guest_info->isapc_ram_fw); option_rom_mr =g_malloc (sizeof (*option_rom_mr));memory_region_init_ram (option_rom_mr,NULL ,"pc.rom" ,PC_ROM_SIZE );vmstate_register_ram_global (option_rom_mr); -memory_region_add_subregion_overlap (rom_memory, +memory_region_add_subregion_overlap (pcms->rom_memory,PC_ROM_MIN_VGA , option_rom_mr,1 );
hw/i386/pc_piix.c +8 -11
@@ -82,9 +82,6 @@ static void pc_init1(MachineState *machine)BusState *idebus[MAX_IDE_BUS ];ISADevice *rtc_state;ISADevice *floppy; -MemoryRegion *ram_memory; -MemoryRegion *pci_memory; -MemoryRegion *rom_memory;DeviceState *icc_bridge;FWCfgState *fw_cfg =NULL ;PcGuestInfo *guest_info;
@@ -125,7 +122,7 @@ static void pc_init1(MachineState *machine) }if (xen_enabled () &&xen_hvm_init (&below_4g_mem_size, &above_4g_mem_size, - &ram_memory) !=0 ) { + &pcms->ram_memory) !=0 ) {fprintf (stderr,"xen hardware virtual machine initialisation failed\n" );exit (1 ); }
@@ -141,12 +138,12 @@ static void pc_init1(MachineState *machine) }if (pci_enabled) { - pci_memory =g_new (MemoryRegion,1 ); -memory_region_init (pci_memory,NULL ,"pci" ,UINT64_MAX ); - rom_memory = pci_memory; + pcms->pci_memory =g_new (MemoryRegion,1 ); +memory_region_init (pcms->pci_memory,NULL ,"pci" ,UINT64_MAX ); + pcms->rom_memory = pcms->pci_memory; }else { - pci_memory =NULL ; - rom_memory = system_memory; + pcms->pci_memory =NULL ; + pcms->rom_memory = system_memory; } guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size);
@@ -168,7 +165,7 @@ static void pc_init1(MachineState *machine)if (!xen_enabled ()) { fw_cfg =pc_memory_init (machine, system_memory, below_4g_mem_size, above_4g_mem_size, - rom_memory, &ram_memory, guest_info); + guest_info); } gsi_state =g_malloc0 (sizeof (*gsi_state));
@@ -185,7 +182,7 @@ static void pc_init1(MachineState *machine) system_memory, system_io, machine->ram_size, below_4g_mem_size, above_4g_mem_size, - pci_memory, ram_memory); + pcms->pci_memory, pcms->ram_memory); }else { pci_bus =NULL ; i440fx_state =NULL ;
hw/i386/pc_q35.c +9 -13
@@ -63,9 +63,6 @@ static void pc_q35_init(MachineState *machine)BusState *idebus[MAX_SATA_PORTS ];ISADevice *rtc_state;ISADevice *floppy; -MemoryRegion *pci_memory; -MemoryRegion *rom_memory; -MemoryRegion *ram_memory;GSIState *gsi_state;ISABus *isa_bus;qemu_irq *cpu_irq;
@@ -115,7 +112,7 @@ static void pc_q35_init(MachineState *machine) }if (xen_enabled () &&xen_hvm_init (&below_4g_mem_size, &above_4g_mem_size, - &ram_memory) !=0 ) { + &pcms->ram_memory) !=0 ) {fprintf (stderr,"xen hardware virtual machine initialisation failed\n" );exit (1 ); }
@@ -131,12 +128,12 @@ static void pc_q35_init(MachineState *machine)/* pci enabled */ if (pci_enabled) { - pci_memory =g_new (MemoryRegion,1 ); -memory_region_init (pci_memory,NULL ,"pci" ,UINT64_MAX ); - rom_memory = pci_memory; + pcms->pci_memory =g_new (MemoryRegion,1 ); +memory_region_init (pcms->pci_memory,NULL ,"pci" ,UINT64_MAX ); + pcms->rom_memory = pcms->pci_memory; }else { - pci_memory =NULL ; - rom_memory =get_system_memory (); + pcms->pci_memory =NULL ; + pcms->rom_memory =get_system_memory (); } guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size);
@@ -155,8 +152,7 @@ static void pc_q35_init(MachineState *machine)/* allocate ram and load rom/bios */ if (!xen_enabled ()) {pc_memory_init (machine,get_system_memory (), - below_4g_mem_size, above_4g_mem_size, - rom_memory, &ram_memory, guest_info); + below_4g_mem_size, above_4g_mem_size, guest_info); }/* irq lines */
@@ -173,8 +169,8 @@ static void pc_q35_init(MachineState *machine) q35_host =Q35_HOST_DEVICE (qdev_create (NULL ,TYPE_Q35_HOST_DEVICE ));object_property_add_child (qdev_get_machine (),"q35" ,OBJECT (q35_host),NULL ); - q35_host->mch.ram_memory = ram_memory; - q35_host->mch.pci_address_space = pci_memory; + q35_host->mch.ram_memory = pcms->ram_memory; + q35_host->mch.pci_address_space = pcms->pci_memory; q35_host->mch.system_memory =get_system_memory (); q35_host->mch.address_space_io =get_system_io (); q35_host->mch.below_4g_mem_size = below_4g_mem_size;
include/hw/i386/pc.h +3 -2
@@ -32,6 +32,9 @@ struct PCMachineState {/* <public> */ ram_addr_t hotplug_memory_base;MemoryRegion hotplug_memory; +MemoryRegion *ram_memory; +MemoryRegion *pci_memory; +MemoryRegion *rom_memory;HotplugHandler *acpi_dev;
@@ -208,8 +211,6 @@ FWCfgState *pc_memory_init(MachineState *machine,MemoryRegion *system_memory, ram_addr_t below_4g_mem_size, ram_addr_t above_4g_mem_size, - MemoryRegion *rom_memory, - MemoryRegion **ram_memory, PcGuestInfo *guest_info);qemu_irq *pc_allocate_cpu_irq (void );DeviceState *pc_vga_init (ISABus *isa_bus,PCIBus *pci_bus);
Signature · 1 line
1.9.3