Convert PC machine-types to QOM classes
v2 cover Convert PC machine-types to QOM classes
Now with lots of cleanup, so you can see how the end result will look like after the conversion.
My goal is that _all_ PC machine-types should be declared using only a class_init + TypeInfo pair, and nothing else. The only thing I couldn't eliminate yet were the pc_compat_*() functions, because we still need them for the KVM CPUID compat stuff.
Eduardo Habkost (39):
q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props
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 vl.c: Use qdev_prop_register_global() for single globals
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 *machine_options macros
piix: Make all *machine_options() functions call the previous one
pc: Eliminate all *_machine_options() functions
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: Rename pc_machine variable to pcms
pc: Move {ram,pci,rom}_memory variables to PCMachineState
pc: Move duplicate Xen init code to pc_machine_init()
pc: Move icc_bridge variable to PCMachineState
pc: Move duplicate icc-bridge and CPU initalization to
pc_machine_init()
pc: Make pc_cpus_init() static
pc: Make pc_cpus_init() use PCMachineState
machine: Eliminate QEMUMachine.compat_props
hw/core/loader.c | 12 +- hw/core/machine.c | 17 + hw/core/qdev-properties.c | 9 +- hw/i386/pc.c | 83 ++--- hw/i386/pc_piix.c | 802 +++++++++++++++++++++++-------------------- hw/i386/pc_q35.c | 288 ++++++++-------- include/hw/boards.h | 13 +- include/hw/i386/pc.h | 44 +-- include/hw/qdev-core.h | 2 + include/hw/qdev-properties.h | 2 +- vl.c | 44 +-- 11 files changed, 688 insertions(+), 628 deletions(-)
Signature · 1 line
1.9.0
RFC v2 1/39 q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props
pc-q35-1.4 was incorrectly using PC_COMPAT_1_4 instead of PC_Q35_COMPAT_1_4.
The only side-effect was that the hpet compat property (inherited from PC_Q35_COMPAT_1_7) was missing.
Without this patch, pc-q35-1.4 incorrectly initializes hpet-intcap to 0xff0104 (behavior introduced in QEMU 2.0, by commit 7a10ef51c2397ac4323bc786af02c58b413b5cd2).
---
Cc: Liu Ping Fan <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>
Cc: Paolo Bonzini <[email protected]>
--- hw/i386/pc_q35.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_q35.c +1 -1
@@ -390,7 +390,7 @@ static QEMUMachine pc_q35_machine_v1_4 = { .name = "pc-q35-1.4", .init = pc_q35_init_1_4, .compat_props = (GlobalProperty []) { -PC_COMPAT_1_4 , +PC_Q35_COMPAT_1_4 , {/* end of list */ } }, };
Signature · 1 line
1.9.0
RFC v2 2/39 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
@@ -655,6 +655,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 = {
@@ -662,15 +670,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.0
RFC v2 3/39 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
@@ -685,6 +685,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 \
@@ -697,10 +701,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.0
RFC v2 5/39 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 scsi-disk.ver on pc-0.1 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
@@ -757,6 +757,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 = {
@@ -764,15 +772,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.0
RFC v2 6/39 vl.c: Use qdev_prop_register_global() for single globals
In reply to Eduardo HabkostInstead of using an array when registeting a single global, simply call qdev_prop_register().
--- vl.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-)
vl.c +15 -24
@@ -812,16 +812,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 {
@@ -3697,16 +3694,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:
@@ -3748,18 +3742,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.0
RFC v2 7/39 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
@@ -1532,8 +1532,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"
@@ -93,7 +94,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,
@@ -101,6 +102,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
@@ -254,6 +254,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
@@ -179,7 +179,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
@@ -1616,8 +1616,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)
@@ -4468,9 +4470,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.0
RFC v2 8/39 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.
Having the PC code converted to pure QOM registration code will help us move PC-specific machine state that is currently held in static variables inside PC machine objects, and reduce duplication between pc_piix.c and pc_q35.c.
---
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
--- 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
@@ -1508,50 +1508,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
@@ -7,6 +7,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.0
RFC v2 9/39 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
@@ -1617,6 +1617,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
@@ -967,7 +967,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 ;
@@ -996,7 +995,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.0
RFC v2 10/39 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. If we just make isapc set hot_add_cpu to NULL, we can move pc_default_machine_options() 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
@@ -1618,6 +1618,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
@@ -407,7 +407,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; }
@@ -970,6 +969,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
@@ -321,7 +321,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.0
RFC v2 11/39 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
@@ -405,15 +405,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" ; }
@@ -429,7 +439,7 @@ static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)static 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, };
@@ -450,12 +460,10 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)static 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);
@@ -463,7 +471,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);
@@ -471,12 +478,10 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)static 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);
@@ -484,7 +489,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);
@@ -492,7 +496,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)static 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, };
@@ -503,7 +507,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);
@@ -511,13 +514,12 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)static 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 ; }
@@ -536,7 +538,7 @@ static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)static 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, };
@@ -575,7 +577,7 @@ static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)static 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, };
@@ -627,7 +629,7 @@ static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)static 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, };
@@ -677,7 +679,7 @@ static void pc_machine_v1_1_class_init(ObjectClass *oc, void *data)static 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, };
@@ -716,7 +718,7 @@ static void pc_machine_v1_0_class_init(ObjectClass *oc, void *data)static 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, };
@@ -738,7 +740,7 @@ static void pc_machine_v0_15_class_init(ObjectClass *oc, void *data)static 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, };
@@ -785,7 +787,7 @@ static void pc_machine_v0_14_class_init(ObjectClass *oc, void *data)static 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, };
@@ -834,7 +836,7 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)static 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, };
@@ -877,7 +879,7 @@ static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)static 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, };
@@ -916,7 +918,7 @@ static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)static 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, };
@@ -956,7 +958,7 @@ static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)static 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, };
@@ -1013,6 +1015,7 @@ static 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.0
RFC v2 13/39 q35: Eliminate pc_q35_1_4_machine_options()
In reply to Eduardo Habkost--- hw/i386/pc_q35.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
hw/i386/pc_q35.c +1 -6
@@ -430,11 +430,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);
@@ -442,7 +437,7 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data) PC_Q35_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.0
RFC v2 12/39 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
@@ -319,15 +319,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" ; }
@@ -342,7 +351,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, };
@@ -363,12 +372,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);
@@ -376,7 +383,6 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data) PC_Q35_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" ;
@@ -384,12 +390,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);
@@ -397,7 +401,6 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data) PC_Q35_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" ;
@@ -405,7 +408,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, };
@@ -416,7 +419,6 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data) PC_Q35_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" ;
@@ -424,13 +426,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 ; }
@@ -449,12 +450,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.0
RFC v2 14/39 pc: Eliminate *machine_options macros
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 4 +--- hw/i386/pc_q35.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
hw/i386/pc_piix.c +1 -3
@@ -443,8 +443,6 @@ static 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);
@@ -452,7 +450,7 @@ 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_2_1_machine_options (mc); mc->init = pc_init_pci_2_0; mc->name ="pc-i440fx-2.0" ;machine_class_add_compat_props (mc, compat_props);
hw/i386/pc_q35.c +1 -3
@@ -355,8 +355,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);
@@ -364,7 +362,7 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data) PC_Q35_COMPAT_2_0, {/* end of list */ } }; -pc_q35_2_0_machine_options (mc); +pc_q35_2_1_machine_options (mc); mc->init = pc_q35_init_2_0;machine_class_add_compat_props (mc, compat_props); mc->name ="pc-q35-2.0" ;
Signature · 1 line
1.9.0
RFC v2 15/39 piix: Make all *machine_options() functions call the previous one
In reply to Eduardo HabkostThis adds a little more boilerplate code, but makes all *machine_options() and *class_init() functions follow exactly the same nesting pattern, making it much easier to eliminate *machine_options() later.
--- hw/i386/pc_piix.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/i386/pc_piix.c +10 -0
@@ -462,6 +462,12 @@ static TypeInfo pc_i440fx_machine_v2_0_type_info = { .class_init = pc_i440fx_machine_v2_0_class_init, }; +static void pc_i440fx_1_7_machine_options (MachineClass *mc) +{ +pc_i440fx_2_1_machine_options (mc); + mc->default_machine_opts =NULL ; +} +static void pc_i440fx_machine_v1_7_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -469,6 +475,7 @@ 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);
@@ -487,6 +494,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_6, {/* end of list */ } }; +pc_i440fx_1_7_machine_options (mc); mc->init = pc_init_pci_1_6; mc->name ="pc-i440fx-1.6" ;machine_class_add_compat_props (mc, compat_props);
@@ -505,6 +513,7 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_5, {/* end of list */ } }; +pc_i440fx_1_7_machine_options (mc); mc->init = pc_init_pci_1_5; mc->name ="pc-i440fx-1.5" ;machine_class_add_compat_props (mc, compat_props);
@@ -518,6 +527,7 @@ static TypeInfo pc_i440fx_machine_v1_5_type_info = {static void pc_i440fx_1_4_machine_options (MachineClass *mc) { +pc_i440fx_1_7_machine_options (mc); mc->hot_add_cpu =NULL ; }
Signature · 1 line
1.9.0
RFC v2 16/39 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.
As a side-effect, we fix duplication of PC_COMPAT_* variables on the PC_Q35_COMPAT_* macros, which were expanded as the following tree:
PC_Q35_COMPAT_1_4:
PC_COMPAT_1_4:
PC_COMPAT_1_5:
PC_COMPAT_1_6:
PC_COMPAT_1_7:
PC_COMPAT_2_0:
[pc-2.0 vars]
[pc-1.7 vars]
[pc-1.6 vars]
[pc-1.5 vars]
[pc-1.5 vars]
PC_Q35_COMPAT_1_5:
PC_COMPAT_1_5:
PC_COMPAT_1_6:
PC_COMPAT_1_7:
PC_COMPAT_2_0:
[pc-2.0 vars]
[pc-1.7 vars]
[pc-1.6 vars]
[pc-1.5 vars]
PC_Q35_COMPAT_1_6:
PC_COMPAT_1_6:
PC_COMPAT_1_7:
PC_COMPAT_2_0:
[pc-2.0 vars]
[pc-1.7 vars]
[pc-1.6 vars]
PC_Q35_COMPAT_1_7:
PC_COMPAT_1_7:
PC_COMPAT_2_0:
[pc-2.0 vars]
[pc-1.7 vars]
PC_Q35_COMPAT_2_0:
PC_COMPAT_2_0:
[pc-2.0 vars]
[pc-q35-2.0 vars]
[pc-q35-1.7 vars]
[pc-q35-1.6 vars]
[pc-q35-1.5 vars]
[pc-q35-1.4 vars]In other words, the contents of PC_COMPAT_2_0 appeared 5 times inside PC_Q35_COMPAT_1_4.
--- hw/i386/pc_piix.c | 84 ++++++++++++++-------------------------------------- hw/i386/pc_q35.c | 15 +++++----- include/hw/i386/pc.h | 14 ++------- 3 files changed, 33 insertions(+), 80 deletions(-)
hw/i386/pc_piix.c +22 -62
@@ -421,16 +421,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 ;
@@ -450,7 +444,9 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data) PC_COMPAT_2_0, {/* end of list */ } }; -pc_i440fx_2_1_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);
@@ -462,12 +458,6 @@ static TypeInfo pc_i440fx_machine_v2_0_type_info = { .class_init = pc_i440fx_machine_v2_0_class_init, }; -static void pc_i440fx_1_7_machine_options (MachineClass *mc) -{ -pc_i440fx_2_1_machine_options (mc); - mc->default_machine_opts =NULL ; -} -static void pc_i440fx_machine_v1_7_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -475,7 +465,8 @@ 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); +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);
@@ -494,7 +485,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_6, {/* end of list */ } }; -pc_i440fx_1_7_machine_options (mc); +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);
@@ -513,7 +504,7 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data) PC_COMPAT_1_5, {/* end of list */ } }; -pc_i440fx_1_7_machine_options (mc); +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);
@@ -525,12 +516,6 @@ static 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) -{ -pc_i440fx_1_7_machine_options (mc); - mc->hot_add_cpu =NULL ; -} -static void pc_i440fx_machine_v1_4_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -538,7 +523,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);
@@ -551,7 +537,6 @@ static TypeInfo pc_i440fx_machine_v1_4_type_info = { };#define PC_COMPAT_1_3 \ - PC_COMPAT_1_4, \ {\ .driver = "usb-tablet",\ .property = "usb_version",\
@@ -577,7 +562,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);
@@ -590,7 +575,6 @@ static TypeInfo pc_machine_v1_3_type_info = { };#define PC_COMPAT_1_2 \ - PC_COMPAT_1_3,\ {\ .driver = "nec-usb-xhci",\ .property = "msi",\
@@ -617,12 +601,6 @@ static 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);
@@ -630,7 +608,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); }
@@ -642,7 +621,6 @@ static TypeInfo pc_machine_v1_2_type_info = { };#define PC_COMPAT_1_1 \ - PC_COMPAT_1_2,\ {\ .driver = "virtio-scsi-pci",\ .property = "hotplug",\
@@ -680,7 +658,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); }
@@ -718,7 +696,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);
@@ -730,20 +708,12 @@ static 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 TypeInfo pc_machine_v0_15_type_info = {
@@ -753,7 +723,6 @@ static TypeInfo pc_machine_v0_15_type_info = { };#define PC_COMPAT_0_14 \ - PC_COMPAT_0_15,\ {\ .driver = "virtio-blk-pci",\ .property = "event_idx",\
@@ -787,7 +756,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);
@@ -800,7 +769,6 @@ static TypeInfo pc_machine_v0_14_type_info = { };#define PC_COMPAT_0_13 \ - PC_COMPAT_0_14,\ {\ .driver = TYPE_PCI_DEVICE,\ .property = "command_serr_enable",\
@@ -823,12 +791,6 @@ static 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);
@@ -836,7 +798,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);
@@ -849,7 +812,6 @@ static TypeInfo pc_machine_v0_13_type_info = { };#define PC_COMPAT_0_12 \ - PC_COMPAT_0_13,\ {\ .driver = "virtio-serial-pci",\ .property = "max_ports",\
@@ -879,7 +841,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);
@@ -892,7 +854,6 @@ static TypeInfo pc_machine_v0_12_type_info = { };#define PC_COMPAT_0_11 \ - PC_COMPAT_0_12,\ {\ .driver = "virtio-blk-pci",\ .property = "vectors",\
@@ -918,7 +879,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);
@@ -934,7 +895,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" ,
@@ -958,7 +918,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 -7
@@ -335,15 +335,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" ;
@@ -362,7 +357,8 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data) PC_Q35_COMPAT_2_0, {/* end of list */ } }; -pc_q35_2_1_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" ;
@@ -381,6 +377,8 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data) PC_Q35_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" ;
@@ -399,6 +397,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data) PC_Q35_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" ;
@@ -417,6 +416,7 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data) PC_Q35_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" ;
@@ -435,6 +435,7 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data) PC_Q35_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 +3 -11
@@ -303,7 +303,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);#define PC_Q35_COMPAT_1_7 \ PC_COMPAT_1_7, \ - PC_Q35_COMPAT_2_0, \ {\ .driver = "hpet",\ .property = HPET_INTCAP,\
@@ -311,16 +310,13 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); }#define PC_Q35_COMPAT_1_6 \ - PC_COMPAT_1_6, \ - PC_Q35_COMPAT_1_7 + PC_COMPAT_1_6#define PC_Q35_COMPAT_1_5 \ - PC_COMPAT_1_5, \ - PC_Q35_COMPAT_1_6 + PC_COMPAT_1_5#define PC_Q35_COMPAT_1_4 \ - PC_COMPAT_1_4, \ - PC_Q35_COMPAT_1_5 + PC_COMPAT_1_4#define PC_COMPAT_2_0 \ {\
@@ -355,7 +351,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 +363,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 +386,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 +429,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.0
RFC v2 17/39 pc: Move pci_enabled parameter to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 11 +++++++---- include/hw/i386/pc.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-)
hw/i386/pc_piix.c +7 -4
@@ -71,10 +71,11 @@ static bool has_reserved_memory = true;/* PC hardware initialisation */ static void pc_init1 (MachineState *machine, -int pci_enabled,int kvmclock_enabled) {PCMachineState *pc_machine =PC_MACHINE (machine); +PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pc_machine); +bool pci_enabled = pcmc->pci_enabled;MemoryRegion *system_memory =get_system_memory ();MemoryRegion *system_io =get_system_io ();int i;
@@ -273,7 +274,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)
@@ -375,7 +376,7 @@ static void pc_init_pci_no_kvmclock(MachineState *machine) smbios_defaults = false;x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI );enable_compat_apic_id_mode (); -pc_init1 (machine,1 ,0 ); +pc_init1 (machine,0 ); }static void pc_init_isa (MachineState *machine)
@@ -388,7 +389,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,1 ); }#ifdef CONFIG_XEN
@@ -424,11 +425,13 @@ static TypeInfo pc_i440fx_machine_type_info = {static void pc_i440fx_machine_v2_1_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PCMachineClass *pcmc =PC_MACHINE_CLASS (oc); mc->default_machine_opts ="firmware=bios-256k.bin" ; mc->alias ="pc" ; mc->init = pc_init_pci; mc->is_default =1 ; mc->name ="pc-i440fx-2.1" ; + pcmc->pci_enabled = true; }static TypeInfo pc_i440fx_machine_v2_1_type_info = {
include/hw/i386/pc.h +1 -0
@@ -49,6 +49,7 @@ struct PCMachineClass {/*< public >*/ HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); +bool pci_enabled; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.0
RFC v2 18/39 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
@@ -63,6 +63,8 @@ static bool has_reserved_memory = true;static void pc_q35_init (MachineState *machine) {PCMachineState *pc_machine =PC_MACHINE (machine); +PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine); +bool pci_enabled = pcmc->pci_enabled;ram_addr_t below_4g_mem_size, above_4g_mem_size;Q35PCIHost *q35_host;PCIHostState *phb;
@@ -76,7 +78,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;
@@ -322,8 +323,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.0
RFC v2 19/39 pc: Move kvmclock_enabled to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 12 +++++++----- include/hw/i386/pc.h | 1 + 3 files changed, 9 insertions(+), 5 deletions(-)
hw/i386/pc.c +1 -0
@@ -1616,6 +1616,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->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 +7 -5
@@ -70,12 +70,12 @@ static bool gigabyte_align = true;static bool has_reserved_memory = true;/* PC hardware initialisation */ -static void pc_init1 (MachineState *machine, -int kvmclock_enabled) +static void pc_init1 (MachineState *machine) {PCMachineState *pc_machine =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pc_machine);bool pci_enabled = pcmc->pci_enabled; +bool kvmclock_enabled = pcmc->kvmclock_enabled;MemoryRegion *system_memory =get_system_memory ();MemoryRegion *system_io =get_system_io ();int i;
@@ -274,7 +274,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)
@@ -376,7 +376,7 @@ static void pc_init_pci_no_kvmclock(MachineState *machine) smbios_defaults = false;x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI );enable_compat_apic_id_mode (); -pc_init1 (machine,0 ); +pc_init1 (machine); }static void pc_init_isa (MachineState *machine)
@@ -389,7 +389,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,1 ); +pc_init1 (machine); }#ifdef CONFIG_XEN
@@ -797,6 +797,7 @@ static 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 */ }
@@ -806,6 +807,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 TypeInfo pc_machine_v0_13_type_info = {
include/hw/i386/pc.h +1 -0
@@ -50,6 +50,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.0
RFC v2 20/39 pc: Move smbios_legacy_mode to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 7 ++++--- hw/i386/pc_q35.c | 7 ++++--- include/hw/i386/pc.h | 1 + 3 files changed, 9 insertions(+), 6 deletions(-)
hw/i386/pc_piix.c +4 -3
@@ -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; -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.
@@ -150,9 +149,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 */
@@ -279,7 +279,6 @@ static void pc_init_pci(MachineState *machine)static void pc_compat_2_0 (MachineState *machine) { - smbios_legacy_mode = true; has_reserved_memory = false; }
@@ -443,6 +442,7 @@ static 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 */ }
@@ -453,6 +453,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 TypeInfo pc_i440fx_machine_v2_0_type_info = {
hw/i386/pc_q35.c +4 -3
@@ -51,7 +51,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.
@@ -137,9 +136,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 */
@@ -257,7 +257,6 @@ static void pc_q35_init(MachineState *machine)static void pc_compat_2_0 (MachineState *machine) { - smbios_legacy_mode = true; has_reserved_memory = false; }
@@ -356,6 +355,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_Q35_COMPAT_2_0 , {/* end of list */ }
@@ -365,6 +365,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
@@ -51,6 +51,7 @@ struct PCMachineClass { DeviceState *dev);bool pci_enabled;bool kvmclock_enabled; +bool smbios_legacy_mode; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.0
RFC v2 21/39 pc: Move smbios_defaults to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 12 ++++++------ hw/i386/pc_q35.c | 7 +++---- include/hw/i386/pc.h | 1 + 4 files changed, 11 insertions(+), 10 deletions(-)
hw/i386/pc.c +1 -0
@@ -1617,6 +1617,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->get_hotplug_handler = mc->get_hotplug_handler; 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 +6 -6
@@ -60,7 +60,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.
@@ -147,9 +146,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);
@@ -285,7 +283,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 );
@@ -372,7 +369,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine) { has_pci_info = false; has_acpi_build = false; - smbios_defaults = false;x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI );enable_compat_apic_id_mode ();pc_init1 (machine);
@@ -382,7 +378,6 @@ static void pc_init_isa(MachineState *machine) { has_pci_info = false; has_acpi_build = false; - smbios_defaults = false;if (!machine->cpu_model) { machine->cpu_model ="486" ; }
@@ -465,6 +460,7 @@ static 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 */ }
@@ -474,6 +470,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 TypeInfo pc_i440fx_machine_v1_7_type_info = {
@@ -939,6 +936,8 @@ static 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 */ } };
@@ -948,6 +947,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 TypeInfo isapc_machine_type_info = {
hw/i386/pc_q35.c +3 -4
@@ -50,7 +50,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.
@@ -134,9 +133,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);
@@ -263,7 +261,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 );
@@ -377,6 +374,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_Q35_COMPAT_1_7 , {/* end of list */ }
@@ -386,6 +384,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
@@ -52,6 +52,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.0
RFC v2 22/39 pc: Move has_acpi_build to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 10 +++++----- hw/i386/pc_q35.c | 6 +++--- include/hw/i386/pc.h | 1 + 4 files changed, 10 insertions(+), 8 deletions(-)
hw/i386/pc.c +1 -0
@@ -1618,6 +1618,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->get_hotplug_handler = mc->get_hotplug_handler; 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 +5 -5
@@ -59,7 +59,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.
@@ -140,7 +139,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;
@@ -293,7 +292,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)
@@ -368,7 +366,6 @@ static void pc_init_pci_1_2(MachineState *machine)static void pc_init_pci_no_kvmclock (MachineState *machine) { has_pci_info = false; - has_acpi_build = false;x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI );enable_compat_apic_id_mode ();pc_init1 (machine);
@@ -377,7 +374,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;if (!machine->cpu_model) { machine->cpu_model ="486" ; }
@@ -482,6 +478,7 @@ static 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 */ }
@@ -490,6 +487,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 TypeInfo pc_i440fx_machine_v1_6_type_info = {
@@ -806,6 +804,7 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data) mc->name ="pc-0.13" ;machine_class_add_compat_props (mc, compat_props); pcmc->kvmclock_enabled = false; + pcmc->has_acpi_build = false; }static TypeInfo pc_machine_v0_13_type_info = {
@@ -948,6 +947,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 TypeInfo isapc_machine_type_info = {
hw/i386/pc_q35.c +3 -3
@@ -49,7 +49,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.
@@ -130,7 +129,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) {
@@ -271,7 +270,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)
@@ -396,6 +394,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_Q35_COMPAT_1_6 , {/* end of list */ }
@@ -404,6 +403,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
@@ -53,6 +53,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.0
RFC v2 23/39 pc: Move has_pci_info to PCMachineClass
In reply to Eduardo HabkostInterestingly, no existing code sets has_pci_info=true at all.
--- hw/i386/pc_piix.c | 6 +----- hw/i386/pc_q35.c | 4 +--- include/hw/i386/pc.h | 1 + 3 files changed, 3 insertions(+), 8 deletions(-)
hw/i386/pc_piix.c +1 -5
@@ -58,7 +58,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.
@@ -141,7 +140,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;
@@ -290,7 +289,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; }
@@ -365,7 +363,6 @@ 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;x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI );enable_compat_apic_id_mode ();pc_init1 (machine);
@@ -373,7 +370,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)static void pc_init_isa (MachineState *machine) { - has_pci_info = false;if (!machine->cpu_model) { machine->cpu_model ="486" ; }
hw/i386/pc_q35.c +1 -3
@@ -48,7 +48,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.
@@ -127,7 +126,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;
@@ -268,7 +267,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
@@ -54,6 +54,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.0
RFC v2 24/39 pc: Move gigabyte_align to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 9 ++------- hw/i386/pc_q35.c | 9 ++------- include/hw/i386/pc.h | 5 +++++ 4 files changed, 10 insertions(+), 14 deletions(-)
hw/i386/pc.c +1 -0
@@ -1619,6 +1619,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 +2 -7
@@ -58,11 +58,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 */
@@ -119,7 +114,7 @@ static void pc_init1(MachineState *machine)* breaking migration. */ if (machine->ram_size >=0xe0000000 ) { -ram_addr_t lowmem = gigabyte_align ?0xc0000000 :0xe0000000 ; +ram_addr_t lowmem = pcmc->gigabyte_align ?0xc0000000 :0xe0000000 ; above_4g_mem_size = machine->ram_size - lowmem; below_4g_mem_size = lowmem; }else {
@@ -281,7 +276,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 ); }
@@ -463,6 +457,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 TypeInfo pc_i440fx_machine_v1_7_type_info = {
hw/i386/pc_q35.c +2 -7
@@ -48,11 +48,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 */
@@ -107,7 +102,7 @@ static void pc_q35_init(MachineState *machine)* breaking migration. */ if (machine->ram_size >=0xb0000000 ) { -ram_addr_t lowmem = gigabyte_align ?0x80000000 :0xb0000000 ; +ram_addr_t lowmem = pcmc->gigabyte_align ?0x80000000 :0xb0000000 ; above_4g_mem_size = machine->ram_size - lowmem; below_4g_mem_size = lowmem; }else {
@@ -259,7 +254,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 ); }
@@ -381,6 +375,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
@@ -55,6 +55,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.0
RFC v2 4/39 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 all 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
@@ -689,6 +689,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 \
@@ -700,15 +708,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",
@@ -743,15 +742,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.0
RFC v2 25/39 pc: Move has_reserved_memory to PCMachineClass
In reply to Eduardo Habkost--- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 6 ++---- hw/i386/pc_q35.c | 6 ++---- include/hw/i386/pc.h | 1 + 4 files changed, 6 insertions(+), 8 deletions(-)
hw/i386/pc.c +1 -0
@@ -1620,6 +1620,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 +2 -4
@@ -58,8 +58,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) {
@@ -137,7 +135,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);
@@ -270,7 +268,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)
@@ -435,6 +432,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 TypeInfo pc_i440fx_machine_v2_0_type_info = {
hw/i386/pc_q35.c +2 -4
@@ -48,8 +48,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) {
@@ -124,7 +122,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);
@@ -248,7 +246,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)
@@ -353,6 +350,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
@@ -60,6 +60,7 @@ struct PCMachineClass {* pages in the host. */ bool gigabyte_align; +bool has_reserved_memory; };typedef struct PCMachineState PCMachineState ;
Signature · 1 line
1.9.0
RFC v2 26/39 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 | 2 ++ hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- include/hw/boards.h | 2 ++ 5 files changed, 15 insertions(+), 9 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 +2 -0
@@ -302,6 +302,8 @@ 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 +2 -2
@@ -273,14 +273,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)
@@ -453,6 +451,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;
@@ -475,6 +474,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; }
hw/i386/pc_q35.c +2 -2
@@ -251,14 +251,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)
@@ -370,6 +368,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;
@@ -392,6 +391,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
@@ -96,6 +96,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.0
RFC v2 27/39 piix: Eliminate pc_init_pci()
In reply to Eduardo HabkostNow pc_init1() can be called directly.
--- hw/i386/pc_piix.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
hw/i386/pc_piix.c +9 -14
@@ -261,11 +261,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) { }
@@ -309,44 +304,44 @@ static void pc_compat_1_2(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 */
@@ -372,7 +367,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 ) {
@@ -403,7 +398,7 @@ static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)PCMachineClass *pcmc =PC_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" ; pcmc->pci_enabled = true;
Signature · 1 line
1.9.0
RFC v2 28/39 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
@@ -376,6 +376,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);
@@ -383,12 +397,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.0
RFC v2 29/39 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 | 80 ++++++++++++++-------------------------------------- hw/i386/pc_q35.c | 45 ++++++----------------------- include/hw/i386/pc.h | 4 +++ 4 files changed, 46 insertions(+), 95 deletions(-)
hw/i386/pc.c +12 -0
@@ -1609,6 +1609,17 @@ static void pc_machine_initfn(Object *obj) NULL, 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);
@@ -1621,6 +1632,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 +21 -59
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
@@ -41,6 +41,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 >*/
@@ -61,6 +63,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.0
RFC v2 30/39 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 | 21 +-------------------- hw/i386/pc_q35.c | 21 +-------------------- 2 files changed, 2 insertions(+), 40 deletions(-)
hw/i386/pc_piix.c +1 -20
@@ -261,29 +261,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 ); }
@@ -393,7 +378,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 TypeInfo pc_i440fx_machine_v2_0_type_info = {
@@ -439,7 +423,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 TypeInfo pc_i440fx_machine_v1_6_type_info = {
@@ -451,7 +434,6 @@ static 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 */ }
@@ -459,7 +441,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 TypeInfo pc_i440fx_machine_v1_5_type_info = {
hw/i386/pc_q35.c +1 -20
@@ -244,29 +244,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 ); }
@@ -319,7 +304,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 = {
@@ -364,7 +348,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; }
@@ -377,7 +360,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_Q35_COMPAT_1_5 , {/* end of list */ }
@@ -385,7 +367,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.0
RFC v2 31/39 piix: Move compat/init functions closer to corresponding class_init
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 105 ++++++++++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 54 deletions(-)
hw/i386/pc_piix.c +51 -54
@@ -261,60 +261,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 (); -} - -/* 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 ); -} - -static void pc_compat_0_13 (MachineState *machine) -{ -x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); -enable_compat_apic_id_mode (); -} - -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; */
@@ -386,6 +332,11 @@ static 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);
@@ -449,6 +400,13 @@ static 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);
@@ -489,6 +447,12 @@ static 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);
@@ -536,6 +500,12 @@ static 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);
@@ -727,6 +697,12 @@ static TypeInfo pc_machine_v0_14_type_info = { .value = stringify(0),\ } +static void pc_compat_0_13 (MachineState *machine) +{ +x86_cpu_compat_disable_kvm_features (FEAT_KVM ,KVM_FEATURE_PV_EOI ); +enable_compat_apic_id_mode (); +} +static void pc_machine_v0_13_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -870,6 +846,15 @@ static 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);
@@ -896,6 +881,18 @@ static 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.0
RFC v2 32/39 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 | 6 +++--- hw/i386/pc_q35.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
hw/i386/pc_piix.c +3 -3
@@ -61,8 +61,8 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };/* PC hardware initialisation */ static void pc_init1 (MachineState *machine) { -PCMachineState *pc_machine =PC_MACHINE (machine); -PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pc_machine); +PCMachineState *pcms =PC_MACHINE (machine); +PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pcms);bool pci_enabled = pcmc->pci_enabled;bool kvmclock_enabled = pcmc->kvmclock_enabled;MemoryRegion *system_memory =get_system_memory ();
@@ -249,7 +249,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 +2 -2
@@ -51,7 +51,7 @@/* PC hardware initialisation */ static void pc_q35_init (MachineState *machine) { -PCMachineState *pc_machine =PC_MACHINE (machine); +PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine);bool pci_enabled = pcmc->pci_enabled;ram_addr_t below_4g_mem_size, above_4g_mem_size;
@@ -172,7 +172,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.0
RFC v2 33/39 pc: Move {ram, pci, rom}_memory variables to PCMachineState
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 19 ++++++++----------- hw/i386/pc_q35.c | 21 +++++++++------------ include/hw/i386/pc.h | 3 +++ 3 files changed, 20 insertions(+), 23 deletions(-)
hw/i386/pc_piix.c +8 -11
@@ -82,14 +82,11 @@ 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; -if (xen_enabled () &&xen_hvm_init (&ram_memory) !=0 ) { +if (xen_enabled () &&xen_hvm_init (&pcms->ram_memory) !=0 ) {fprintf (stderr,"xen hardware virtual machine initialisation failed\n" );exit (1 ); }
@@ -121,12 +118,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);
@@ -150,7 +147,7 @@ static void pc_init1(MachineState *machine) machine->kernel_filename, machine->kernel_cmdline, machine->initrd_filename, below_4g_mem_size, above_4g_mem_size, - rom_memory, &ram_memory, guest_info); + pcms->rom_memory, &pcms->ram_memory, guest_info); } gsi_state =g_malloc0 (sizeof (*gsi_state));
@@ -167,7 +164,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 -12
@@ -62,9 +62,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;
@@ -76,7 +73,7 @@ static void pc_q35_init(MachineState *machine)DeviceState *icc_bridge;PcGuestInfo *guest_info; -if (xen_enabled () &&xen_hvm_init (&ram_memory) !=0 ) { +if (xen_enabled () &&xen_hvm_init (&pcms->ram_memory) !=0 ) {fprintf (stderr,"xen hardware virtual machine initialisation failed\n" );exit (1 ); }
@@ -110,12 +107,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);
@@ -137,7 +134,7 @@ static void pc_q35_init(MachineState *machine) machine->kernel_filename, machine->kernel_cmdline, machine->initrd_filename, below_4g_mem_size, above_4g_mem_size, - rom_memory, &ram_memory, guest_info); + pcms->rom_memory, &pcms->ram_memory, guest_info); }/* irq lines */
@@ -154,8 +151,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 -0
@@ -31,6 +31,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; };
Signature · 1 line
1.9.0
RFC v2 34/39 pc: Move duplicate Xen init code to pc_machine_init()
In reply to Eduardo Habkost--- hw/i386/pc.c | 7 +++++++ hw/i386/pc_piix.c | 5 ----- hw/i386/pc_q35.c | 5 ----- 3 files changed, 7 insertions(+), 10 deletions(-)
hw/i386/pc.c +7 -0
@@ -1611,10 +1611,17 @@ static void pc_machine_initfn(Object *obj)static void pc_machine_init (MachineState *machine) { +PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine);if (pcmc->compat_func) { pcmc->compat_func (machine); } + +if (xen_enabled () &&xen_hvm_init (&pcms->ram_memory) !=0 ) { +fprintf (stderr,"xen hardware virtual machine initialisation failed\n" ); +exit (1 ); + } +if (pcmc->finish_init) { pcmc->finish_init (machine); }
hw/i386/pc_piix.c +0 -5
@@ -86,11 +86,6 @@ static void pc_init1(MachineState *machine)FWCfgState *fw_cfg =NULL ;PcGuestInfo *guest_info; -if (xen_enabled () &&xen_hvm_init (&pcms->ram_memory) !=0 ) { -fprintf (stderr,"xen hardware virtual machine initialisation failed\n" ); -exit (1 ); - } - icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE );object_property_add_child (qdev_get_machine (),"icc-bridge" ,OBJECT (icc_bridge),NULL );
hw/i386/pc_q35.c +0 -5
@@ -73,11 +73,6 @@ static void pc_q35_init(MachineState *machine)DeviceState *icc_bridge;PcGuestInfo *guest_info; -if (xen_enabled () &&xen_hvm_init (&pcms->ram_memory) !=0 ) { -fprintf (stderr,"xen hardware virtual machine initialisation failed\n" ); -exit (1 ); - } - icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE );object_property_add_child (qdev_get_machine (),"icc-bridge" ,OBJECT (icc_bridge),NULL );
Signature · 1 line
1.9.0
RFC v2 35/39 pc: Move icc_bridge variable to PCMachineState
In reply to Eduardo Habkost--- hw/i386/pc_piix.c | 9 ++++----- hw/i386/pc_q35.c | 9 ++++----- include/hw/i386/pc.h | 1 + 3 files changed, 9 insertions(+), 10 deletions(-)
hw/i386/pc_piix.c +4 -5
@@ -82,15 +82,14 @@ static void pc_init1(MachineState *machine)BusState *idebus[MAX_IDE_BUS ];ISADevice *rtc_state;ISADevice *floppy; -DeviceState *icc_bridge;FWCfgState *fw_cfg =NULL ;PcGuestInfo *guest_info; - icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE ); + pcms->icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE );object_property_add_child (qdev_get_machine (),"icc-bridge" , -OBJECT (icc_bridge),NULL ); +OBJECT (pcms->icc_bridge),NULL ); -pc_cpus_init (machine->cpu_model, icc_bridge); +pc_cpus_init (machine->cpu_model, pcms->icc_bridge);if (kvm_enabled () && kvmclock_enabled) {kvmclock_create ();
@@ -183,7 +182,7 @@ static void pc_init1(MachineState *machine)if (pci_enabled) {ioapic_init_gsi (gsi_state,"i440fx" ); } -qdev_init_nofail (icc_bridge); +qdev_init_nofail (pcms->icc_bridge);pc_register_ferr_irq (gsi[13 ]);
hw/i386/pc_q35.c +4 -5
@@ -70,14 +70,13 @@ static void pc_q35_init(MachineState *machine)int i;ICH9LPCState *ich9_lpc;PCIDevice *ahci; -DeviceState *icc_bridge;PcGuestInfo *guest_info; - icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE ); + pcms->icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE );object_property_add_child (qdev_get_machine (),"icc-bridge" , -OBJECT (icc_bridge),NULL ); +OBJECT (pcms->icc_bridge),NULL ); -pc_cpus_init (machine->cpu_model, icc_bridge); +pc_cpus_init (machine->cpu_model, pcms->icc_bridge);pc_acpi_init ("q35-acpi-dsdt.aml" );kvmclock_create ();
@@ -196,7 +195,7 @@ static void pc_q35_init(MachineState *machine)if (pci_enabled) {ioapic_init_gsi (gsi_state,NULL ); } -qdev_init_nofail (icc_bridge); +qdev_init_nofail (pcms->icc_bridge);pc_register_ferr_irq (gsi[13 ]);
include/hw/i386/pc.h +1 -0
@@ -34,6 +34,7 @@ struct PCMachineState {MemoryRegion *ram_memory;MemoryRegion *pci_memory;MemoryRegion *rom_memory; +DeviceState *icc_bridge;HotplugHandler *acpi_dev; };
Signature · 1 line
1.9.0
RFC v2 36/39 pc: Move duplicate icc-bridge and CPU initalization to pc_machine_init()
In reply to Eduardo Habkost--- hw/i386/pc.c | 6 ++++++ hw/i386/pc_piix.c | 6 ------ hw/i386/pc_q35.c | 5 ----- 3 files changed, 6 insertions(+), 11 deletions(-)
hw/i386/pc.c +6 -0
@@ -1622,6 +1622,12 @@ static void pc_machine_init(MachineState *machine)exit (1 ); } + pcms->icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE ); +object_property_add_child (qdev_get_machine (),"icc-bridge" , +OBJECT (pcms->icc_bridge),NULL ); + +pc_cpus_init (machine->cpu_model, icc_bridge); +if (pcmc->finish_init) { pcmc->finish_init (machine); }
hw/i386/pc_piix.c +0 -6
@@ -85,12 +85,6 @@ static void pc_init1(MachineState *machine)FWCfgState *fw_cfg =NULL ;PcGuestInfo *guest_info; - pcms->icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE ); -object_property_add_child (qdev_get_machine (),"icc-bridge" , -OBJECT (pcms->icc_bridge),NULL ); - -pc_cpus_init (machine->cpu_model, pcms->icc_bridge); -if (kvm_enabled () && kvmclock_enabled) {kvmclock_create (); }
hw/i386/pc_q35.c +0 -5
@@ -72,11 +72,6 @@ static void pc_q35_init(MachineState *machine)PCIDevice *ahci;PcGuestInfo *guest_info; - pcms->icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE ); -object_property_add_child (qdev_get_machine (),"icc-bridge" , -OBJECT (pcms->icc_bridge),NULL ); - -pc_cpus_init (machine->cpu_model, pcms->icc_bridge);pc_acpi_init ("q35-acpi-dsdt.aml" );kvmclock_create ();
Signature · 1 line
1.9.0
RFC v2 37/39 pc: Make pc_cpus_init() static
In reply to Eduardo Habkost--- hw/i386/pc.c | 2 +- include/hw/i386/pc.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
hw/i386/pc.c +1 -1
@@ -1017,7 +1017,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)pc_new_cpu (current_cpu_model, apic_id, icc_bridge, errp); } -void pc_cpus_init (const char *cpu_model,DeviceState *icc_bridge) +static void pc_cpus_init (PCMachineState *pcms) {int i;X86CPU *cpu =NULL ;
include/hw/i386/pc.h +0 -1
@@ -186,7 +186,6 @@ extern int fd_bootchk;void pc_register_ferr_irq (qemu_irq irq);void pc_acpi_smi_interrupt (void *opaque,int irq,int level); -void pc_cpus_init (const char *cpu_model,DeviceState *icc_bridge);void pc_hot_add_cpu (const int64_t id,Error **errp);void pc_acpi_init (const char *default_dsdt);
Signature · 1 line
1.9.0
RFC v2 38/39 pc: Make pc_cpus_init() use PCMachineState
In reply to Eduardo Habkost--- hw/i386/pc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
hw/i386/pc.c +5 -3
@@ -1019,10 +1019,12 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)static void pc_cpus_init (PCMachineState *pcms) { +MachineState *machine =MACHINE (pcms);int i;X86CPU *cpu =NULL ;Error *error =NULL ;unsigned long apic_id_limit; +const char *cpu_model = machine->cpu_model;/* init CPUs */ if (cpu_model ==NULL ) {
@@ -1043,7 +1045,7 @@ static void pc_cpus_init(PCMachineState *pcms)for (i =0 ; i < smp_cpus; i++) { cpu =pc_new_cpu (cpu_model,x86_cpu_apic_id_from_index (i), - icc_bridge, &error); + pcms->icc_bridge, &error);if (error) {error_report ("%s" ,error_get_pretty (error));error_free (error);
@@ -1054,7 +1056,7 @@ static void pc_cpus_init(PCMachineState *pcms)/* map APIC MMIO area if CPU has APIC */ if (cpu && cpu->apic_state) {/* XXX: what if the base changes? */ -sysbus_mmio_map_overlap (SYS_BUS_DEVICE (icc_bridge),0 , +sysbus_mmio_map_overlap (SYS_BUS_DEVICE (pcms->icc_bridge),0 ,APIC_DEFAULT_ADDRESS ,0x1000 ); }
@@ -1626,7 +1628,7 @@ static void pc_machine_init(MachineState *machine)object_property_add_child (qdev_get_machine (),"icc-bridge" ,OBJECT (pcms->icc_bridge),NULL ); -pc_cpus_init (machine->cpu_model, icc_bridge); +pc_cpus_init (pcms);if (pcmc->finish_init) { pcmc->finish_init (machine);
Signature · 1 line
1.9.0
RFC v2 39/39 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
@@ -1617,9 +1617,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.0
Quoted 7 lines · Eduardo Habkost
Now with lots of cleanup, so you can see how the end result will look like after the conversion.
My goal is that _all_ PC machine-types should be declared using only a
class_init+ TypeInfo pair, and nothing else. The only thing I couldn't eliminate yet were the pc_compat_*() functions, because we still need them for the KVM CPUID compat stuff.
Git tree:
https://github.com/ehabkost/qemu-hacks/tree/pc-machine-class.v2
This is based on Michael's pci tree.
The basic steps of the conversion (which I forgot to include in the cover letter):
* PC_COMPAT_* cleanup, so all follow the same nesting pattern
* Make MachineClass.compat_props a linked list
* Mechanical conversion of current code to QOM (like the previous RFC I sent)
* Elimination of *machine_options() functions
* Moving global variables to PCMachineClass
* Common pc_machine_init() function, with a compat_func hook
* Some piix/q35 duplication elimination, just as a proof of concept of how we can proceed
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC v2 01/39] q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props
In reply to Eduardo HabkostAm 13.06.2014 21:43, schrieb Eduardo Habkost:
Quoted 11 lines
pc-q35-1.4 was incorrectly using
PC_COMPAT_1_4instead ofPC_Q35_COMPAT_1_4.The only side-effect was that the hpet compat property (inherited from
PC_Q35_COMPAT_1_7) was missing.Without this patch, pc-q35-1.4 incorrectly initializes hpet-intcap to
0xff0104(behavior introduced in QEMU 2.0, by commit7a10ef51c2397ac4323bc786af02c58b413b5cd2).Signed-off-by Eduardo Habkost <[email protected]>
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [RFC v2 06/39] vl.c: Use qdev_prop_register_global() for single globals
In reply to Eduardo HabkostAm 13.06.2014 21:43, schrieb Eduardo Habkost:
Quoted 4 lines
Instead of using an array when registeting a single global, simply call
qdev_prop_register().Signed-off-by Eduardo Habkost <[email protected]>
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [RFC v2 08/39] pc: Register machine classes directly instead of using QEMUMachine
In reply to Eduardo HabkostAm 13.06.2014 21:43, schrieb Eduardo Habkost:
Quoted 22 lines
This is a (mostly) blind and mechanical conversion of the PC QEMUMachine definitions to corresponding class registration code.
Having the PC code converted to pure QOM registration code will help us move PC-specific machine state that is currently held in static variables inside PC machine objects, and reduce duplication between
pc_piix.candpc_q35.c.Signed-off-by Eduardo Habkost <[email protected]>Cc Igor Mammedov <[email protected]>---
Changes v1 -> v2:
* Remove unusedPC_DEFAULT_MACHINE_OPTIONSmacro leftover
* Usemachine_class_register_global_props_array()
* Rebase on top of Michael's pci tree
* Eliminateqemu_register_pc_machine(), as it is not needed anymore--- 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(-)
[...]
Quoted 37 lines
hw/i386/pc_piix.c +14
-15@@ -405,81 +405,140 @@ static void pc_xen_hvm_init(MachineState *machine) }#endif -#define PC_I440FX_MACHINE_OPTIONS \ - PC_DEFAULT_MACHINE_OPTIONS, \ - .desc = "Standard PC (i440FX + PIIX, 1996)", \ - .hot_add_cpu = pc_hot_add_cpu - -#define PC_I440FX_2_1_MACHINE_OPTIONS \ - PC_I440FX_MACHINE_OPTIONS, \ - .default_machine_opts = "firmware=bios-256k.bin" - -static QEMUMachine pc_i440fx_machine_v2_1 = { -PC_I440FX_2_1_MACHINE_OPTIONS , - .name ="pc-i440fx-2.1" , - .alias ="pc" , - .init = pc_init_pci, - .is_default =1 , +static void pc_i440fx_machine_options (MachineClass *mc) +{ +pc_default_machine_options (mc); + mc->desc ="Standard PC (i440FX + PIIX, 1996)" ; + mc->hot_add_cpu = pc_hot_add_cpu; +} + +static void pc_i440fx_2_1_machine_options (MachineClass *mc) +{ +pc_i440fx_machine_options (mc); + mc->default_machine_opts ="firmware=bios-256k.bin" ; +} + +static void pc_i440fx_machine_v2_1_class_init (ObjectClass *oc,void *data)
hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 431
Quoted 10 lines
hw/i386/pc_piix.c +10
-0+{ +MachineClass *mc =MACHINE_CLASS (oc); +pc_i440fx_2_1_machine_options (mc); + mc->alias ="pc" ; + mc->init = pc_init_pci; + mc->is_default =1 ; + mc->name ="pc-i440fx-2.1" ; +} + +static TypeInfo pc_i440fx_machine_v2_1_type_info = {
static const TypeInfo please, or explain why not. (recurring issue)
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [RFC v2 09/39] pc: Eliminate pc_common_machine_options()
In reply to Eduardo HabkostAm 13.06.2014 21:43, schrieb Eduardo Habkost:
Quoted 4 lines
The
TYPE_PC_MACHINEparent class can initialize the common options for all PC machines.Signed-off-by Eduardo Habkost <[email protected]>
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [RFC v2 08/39] pc: Register machine classes directly instead of using QEMUMachine
In reply to Andreas FärberQuoted 1 line · Andreas Färber
Am 13.06.2014 21:43, schrieb Eduardo Habkost:
[...]
Quoted 3 lines
Quoted 1 line
+static TypeInfo
pc_i440fx_machine_v2_1_type_info= {static const TypeInfo please, or explain why not. (recurring issue)
I will fix it on the next version. Thanks!
Signature · 1 line
Eduardo