* [Qemu-devel] [RFC v3 01/35] pc_piix: Add missing compat code to pc-0.1[0123]
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 02/35] target-i385: Add kvmclock_enabled static Eduardo Habkost
` (33 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
pc-0.13 and older were missing some compat code that is present on newer
machine-types:
* x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
(pc-i440fx-1.7 and older)
* x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
(pc-i440fx-1.4 and older)
* x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
(pc-i440fx-1.4 and older)
Add those missing bits to pc_init_pci_no_kvmclock(), to make sure
pc-0.13 and older are compatible with the older QEMU versions. While at
it, reorder pc_init_pci_no_kvmclock() and document where each line is
was copied from.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 2dccb34..802cd1a 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -389,16 +389,31 @@ static void pc_init_pci_1_2(MachineState *machine)
/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */
static void pc_init_pci_no_kvmclock(MachineState *machine)
{
- has_pci_info = false;
- has_acpi_build = false;
- smbios_defaults = false;
- gigabyte_align = false;
+ /* Copy from pc_compat_2_0(): */
smbios_legacy_mode = true;
has_reserved_memory = false;
+
+ /* Copy from pc_compat_1_7(): */
+ smbios_defaults = false;
+ gigabyte_align = false;
option_rom_has_mr = true;
+ x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
+
+ /* Copy from pc_compat_1_6(): */
+ has_pci_info = false;
rom_file_has_mr = false;
- x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
+ has_acpi_build = false;
+
+ /* Copy from pc_compat_1_4(): */
+ x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
+ x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
+
+ /* Copy from pc_compat_1_3(): */
enable_compat_apic_id_mode();
+
+ /* Copy from pc_compat_1_2(): */
+ x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
+
pc_init1(machine, 1, 0);
}
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 02/35] target-i385: Add kvmclock_enabled static
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 01/35] pc_piix: Add missing compat code to pc-0.1[0123] Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 03/35] pc_piix: Reuse pc_compat_1_2() on pc_init_pci_no_kvmclock() Eduardo Habkost
` (32 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
This looks like a step backwards, but it will allow pc-0.1[0123] reuse
pc_compat_1_2() instead of duplicating the code from all pc_compat_*()
functions.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 802cd1a..c8ded9d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -69,11 +69,11 @@ static bool smbios_legacy_mode;
*/
static bool gigabyte_align = true;
static bool has_reserved_memory = true;
+static bool kvmclock_enabled = true;
/* PC hardware initialisation */
static void pc_init1(MachineState *machine,
- int pci_enabled,
- int kvmclock_enabled)
+ int pci_enabled)
{
PCMachineState *pc_machine = PC_MACHINE(machine);
MemoryRegion *system_memory = get_system_memory();
@@ -292,7 +292,7 @@ static void pc_init1(MachineState *machine,
static void pc_init_pci(MachineState *machine)
{
- pc_init1(machine, 1, 1);
+ pc_init1(machine, 1);
}
static void pc_compat_2_0(MachineState *machine)
@@ -414,7 +414,10 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)
/* Copy from pc_compat_1_2(): */
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
- pc_init1(machine, 1, 0);
+ /* Specific to pc-0.13 and older: */
+ kvmclock_enabled = false;
+
+ pc_init_pci(machine);
}
static void pc_init_isa(MachineState *machine)
@@ -432,7 +435,7 @@ static void pc_init_isa(MachineState *machine)
}
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode();
- pc_init1(machine, 0, 1);
+ pc_init1(machine, 0);
}
#ifdef CONFIG_XEN
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 03/35] pc_piix: Reuse pc_compat_1_2() on pc_init_pci_no_kvmclock()
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 01/35] pc_piix: Add missing compat code to pc-0.1[0123] Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 02/35] target-i385: Add kvmclock_enabled static Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 04/35] pc: Replace tabs with spaces on pc.h Eduardo Habkost
` (31 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Instead of following a different pattern from all other PC init
functions, make pc-0.13 and older reuse pc_compat_1_2() and simply set
kvmclock_enabled=false.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 36 ++++++++----------------------------
1 file changed, 8 insertions(+), 28 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index c8ded9d..0261f2e 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -343,6 +343,13 @@ static void pc_compat_1_2(MachineState *machine)
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
}
+/* PC compat function for pc-0.10 to pc-0.13 */
+static void pc_compat_0_13(MachineState *machine)
+{
+ pc_compat_1_2(machine);
+ kvmclock_enabled = false;
+}
+
static void pc_init_pci_2_0(MachineState *machine)
{
pc_compat_2_0(machine);
@@ -389,34 +396,7 @@ static void pc_init_pci_1_2(MachineState *machine)
/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */
static void pc_init_pci_no_kvmclock(MachineState *machine)
{
- /* Copy from pc_compat_2_0(): */
- smbios_legacy_mode = true;
- has_reserved_memory = false;
-
- /* Copy from pc_compat_1_7(): */
- smbios_defaults = false;
- gigabyte_align = false;
- option_rom_has_mr = true;
- x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
-
- /* Copy from pc_compat_1_6(): */
- has_pci_info = false;
- rom_file_has_mr = false;
- has_acpi_build = false;
-
- /* Copy from pc_compat_1_4(): */
- x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
- x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
-
- /* Copy from pc_compat_1_3(): */
- enable_compat_apic_id_mode();
-
- /* Copy from pc_compat_1_2(): */
- x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
-
- /* Specific to pc-0.13 and older: */
- kvmclock_enabled = false;
-
+ pc_compat_0_13(machine);
pc_init_pci(machine);
}
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 04/35] pc: Replace tabs with spaces on pc.h
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (2 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 03/35] pc_piix: Reuse pc_compat_1_2() on pc_init_pci_no_kvmclock() Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 05/35] vl.c: Use qdev_prop_register_global() for single globals Eduardo Habkost
` (30 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/hw/i386/pc.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 1c0c382..4a9eb46 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -440,23 +440,23 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.driver = "scsi-hd",\
.property = "discard_granularity",\
.value = stringify(0),\
- },{\
+ },{\
.driver = "scsi-cd",\
.property = "discard_granularity",\
.value = stringify(0),\
- },{\
+ },{\
.driver = "scsi-disk",\
.property = "discard_granularity",\
.value = stringify(0),\
- },{\
+ },{\
.driver = "ide-hd",\
.property = "discard_granularity",\
.value = stringify(0),\
- },{\
+ },{\
.driver = "ide-cd",\
.property = "discard_granularity",\
.value = stringify(0),\
- },{\
+ },{\
.driver = "ide-drive",\
.property = "discard_granularity",\
.value = stringify(0),\
@@ -464,7 +464,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.driver = "virtio-blk-pci",\
.property = "discard_granularity",\
.value = stringify(0),\
- },{\
+ },{\
.driver = "virtio-serial-pci",\
.property = "vectors",\
/* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 05/35] vl.c: Use qdev_prop_register_global() for single globals
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (3 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 04/35] pc: Replace tabs with spaces on pc.h Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 06/35] piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14 Eduardo Habkost
` (29 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Instead of using an array when registering a single global, simply call
qdev_prop_register().
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
vl.c | 39 +++++++++++++++------------------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/vl.c b/vl.c
index 6e084c2..732b0d4 100644
--- a/vl.c
+++ b/vl.c
@@ -861,16 +861,13 @@ static void configure_rtc(QemuOpts *opts)
value = qemu_opt_get(opts, "driftfix");
if (value) {
if (!strcmp(value, "slew")) {
- static GlobalProperty slew_lost_ticks[] = {
- {
- .driver = "mc146818rtc",
- .property = "lost_tick_policy",
- .value = "slew",
- },
- { /* end of list */ }
+ static GlobalProperty slew_lost_ticks = {
+ .driver = "mc146818rtc",
+ .property = "lost_tick_policy",
+ .value = "slew",
};
- qdev_prop_register_global_list(slew_lost_ticks);
+ qdev_prop_register_global(&slew_lost_ticks);
} else if (!strcmp(value, "none")) {
/* discard is default */
} else {
@@ -3633,16 +3630,13 @@ int main(int argc, char **argv, char **envp)
win2k_install_hack = 1;
break;
case QEMU_OPTION_rtc_td_hack: {
- static GlobalProperty slew_lost_ticks[] = {
- {
- .driver = "mc146818rtc",
- .property = "lost_tick_policy",
- .value = "slew",
- },
- { /* end of list */ }
+ static GlobalProperty slew_lost_ticks = {
+ .driver = "mc146818rtc",
+ .property = "lost_tick_policy",
+ .value = "slew",
};
- qdev_prop_register_global_list(slew_lost_ticks);
+ qdev_prop_register_global(&slew_lost_ticks);
break;
}
case QEMU_OPTION_acpitable:
@@ -3684,18 +3678,15 @@ int main(int argc, char **argv, char **envp)
break;
}
case QEMU_OPTION_no_kvm_pit_reinjection: {
- static GlobalProperty kvm_pit_lost_tick_policy[] = {
- {
- .driver = "kvm-pit",
- .property = "lost_tick_policy",
- .value = "discard",
- },
- { /* end of list */ }
+ static GlobalProperty kvm_pit_lost_tick_policy = {
+ .driver = "kvm-pit",
+ .property = "lost_tick_policy",
+ .value = "discard",
};
fprintf(stderr, "Warning: option deprecated, use "
"lost_tick_policy property of kvm-pit instead.\n");
- qdev_prop_register_global_list(kvm_pit_lost_tick_policy);
+ qdev_prop_register_global(&kvm_pit_lost_tick_policy);
break;
}
case QEMU_OPTION_usb:
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 06/35] piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (4 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 05/35] vl.c: Use qdev_prop_register_global() for single globals Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 07/35] piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13 Eduardo Habkost
` (28 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Alon Levy, Gerd Hoffmann, Igor Mammedov, Andreas Färber
Those 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Alon Levy <alevy@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
---
hw/i386/pc_piix.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 0261f2e..332aee1 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -682,6 +682,14 @@ static QEMUMachine pc_machine_v0_15 = {
.driver = "virtio-balloon-pci",\
.property = "event_idx",\
.value = "off",\
+ },{\
+ .driver = "qxl",\
+ .property = "revision",\
+ .value = stringify(2),\
+ },{\
+ .driver = "qxl-vga",\
+ .property = "revision",\
+ .value = stringify(2),\
}
static QEMUMachine pc_machine_v0_14 = {
@@ -689,15 +697,6 @@ static QEMUMachine pc_machine_v0_14 = {
.name = "pc-0.14",
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_14,
- {
- .driver = "qxl",
- .property = "revision",
- .value = stringify(2),
- },{
- .driver = "qxl-vga",
- .property = "revision",
- .value = stringify(2),
- },
{ /* end of list */ }
},
.hw_version = "0.14",
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 07/35] piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (5 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 06/35] piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14 Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 08/35] piix: Move pc-0.1[23] rombar compat props " Eduardo Habkost
` (27 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Gerd Hoffmann, Igor Mammedov, Andreas Färber,
Aneesh Kumar K.V
The 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
hw/i386/pc_piix.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 332aee1..cf3318d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -712,6 +712,10 @@ static QEMUMachine pc_machine_v0_14 = {
.driver = "AC97",\
.property = "use_broken_id",\
.value = stringify(1),\
+ },{\
+ .driver = "virtio-9p-pci",\
+ .property = "vectors",\
+ .value = stringify(0),\
}
#define PC_I440FX_0_13_MACHINE_OPTIONS \
@@ -724,10 +728,6 @@ static QEMUMachine pc_machine_v0_13 = {
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_13,
{
- .driver = "virtio-9p-pci",
- .property = "vectors",
- .value = stringify(0),
- },{
.driver = "VGA",
.property = "rombar",
.value = stringify(0),
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 08/35] piix: Move pc-0.1[23] rombar compat props to PC_COMPAT_0_13
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (6 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 07/35] piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13 Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 09/35] piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11 Eduardo Habkost
` (26 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Stefan Weil, Michael S. Tsirkin, Alexander Graf,
Don Slutz, Gerd Hoffmann, Igor Mammedov, Andreas Färber
The VGA and vmware-svga rombar compat properties were added by commit
281a26b15b4adcecb8604216738975abd754bea8, but only to pc-0.13 and
pc-0.12. This breaks the PC_COMPAT_* nesting pattern we currently
follow.
The new variables will now be inherited by pc-0.11 and older, but
pc-0.11 and pc-0.10 already have PCI.rombar=0 on compat_props, so they
shouldn't be affected at all.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Stefan Weil <sw@weilnetz.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
---
hw/i386/pc_piix.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index cf3318d..21c9720 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -716,6 +716,14 @@ static QEMUMachine pc_machine_v0_14 = {
.driver = "virtio-9p-pci",\
.property = "vectors",\
.value = stringify(0),\
+ },{\
+ .driver = "VGA",\
+ .property = "rombar",\
+ .value = stringify(0),\
+ },{\
+ .driver = "vmware-svga",\
+ .property = "rombar",\
+ .value = stringify(0),\
}
#define PC_I440FX_0_13_MACHINE_OPTIONS \
@@ -727,15 +735,6 @@ static QEMUMachine pc_machine_v0_13 = {
.name = "pc-0.13",
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_13,
- {
- .driver = "VGA",
- .property = "rombar",
- .value = stringify(0),
- },{
- .driver = "vmware-svga",
- .property = "rombar",
- .value = stringify(0),
- },
{ /* end of list */ }
},
.hw_version = "0.13",
@@ -770,15 +769,6 @@ static QEMUMachine pc_machine_v0_12 = {
.name = "pc-0.12",
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_12,
- {
- .driver = "VGA",
- .property = "rombar",
- .value = stringify(0),
- },{
- .driver = "vmware-svga",
- .property = "rombar",
- .value = stringify(0),
- },
{ /* end of list */ }
},
.hw_version = "0.12",
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 09/35] piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (7 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 08/35] piix: Move pc-0.1[23] rombar compat props " Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 10/35] machine: Make compat_props a linked list Eduardo Habkost
` (25 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Gerd Hoffmann, Igor Mammedov, Andreas Färber
The current code setting ide-drive.ver and scsi-disk.ver on pc-0.11
breaks the PC_COMPAT_* nesting pattern we currently use.
As those variables are overwritten in pc-0.10 too, they can be inherited
by pc-0.10 with no side-effects at all.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
---
hw/i386/pc_piix.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 21c9720..2ef90f2 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -784,6 +784,14 @@ static QEMUMachine pc_machine_v0_12 = {
.driver = TYPE_PCI_DEVICE,\
.property = "rombar",\
.value = stringify(0),\
+ },{\
+ .driver = "ide-drive",\
+ .property = "ver",\
+ .value = "0.11",\
+ },{\
+ .driver = "scsi-disk",\
+ .property = "ver",\
+ .value = "0.11",\
}
static QEMUMachine pc_machine_v0_11 = {
@@ -791,15 +799,6 @@ static QEMUMachine pc_machine_v0_11 = {
.name = "pc-0.11",
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_11,
- {
- .driver = "ide-drive",
- .property = "ver",
- .value = "0.11",
- },{
- .driver = "scsi-disk",
- .property = "ver",
- .value = "0.11",
- },
{ /* end of list */ }
},
.hw_version = "0.11",
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 10/35] machine: Make compat_props a linked list
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (8 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 09/35] piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11 Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 11/35] pc: Register machine classes directly instead of using QEMUMachine Eduardo Habkost
` (24 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
This will make it easier to write reusable class_init code which adds
properties to MachineClass.compat_props.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index cbba679..a4d928e 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -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,
};
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3d12560..7f6509c 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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);
}
}
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 2cf22b1..6755c80 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1531,8 +1531,10 @@ static void pc_generic_machine_class_init(ObjectClass *oc, void *data)
mc->is_default = qm->is_default;
mc->default_machine_opts = qm->default_machine_opts;
mc->default_boot_order = qm->default_boot_order;
- mc->compat_props = qm->compat_props;
mc->hw_version = qm->hw_version;
+ if (qm->compat_props) {
+ machine_class_add_compat_props(mc, qm->compat_props);
+ }
}
void qemu_register_pc_machine(QEMUMachine *m)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 605a970..15d6ac7 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -4,6 +4,7 @@
#define HW_BOARDS_H
#include "qemu/typedefs.h"
+#include "qemu/queue.h"
#include "sysemu/blockdev.h"
#include "hw/qdev.h"
#include "qom/object.h"
@@ -97,7 +98,7 @@ struct MachineClass {
int is_default;
const char *default_machine_opts;
const char *default_boot_order;
- GlobalProperty *compat_props;
+ GlobalPropertyList compat_props;
const char *hw_version;
HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
@@ -105,6 +106,13 @@ struct MachineClass {
};
/**
+ * machine_class_add_compat_props:
+ *
+ * Adds compat props from an array to the MachineClass compat_props list.
+ */
+void machine_class_add_compat_props(MachineClass *mc, GlobalProperty *props);
+
+/**
* MachineState:
*/
struct MachineState {
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 0799ff2..d93fbba 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -255,6 +255,8 @@ typedef struct GlobalProperty {
QTAILQ_ENTRY(GlobalProperty) next;
} GlobalProperty;
+typedef QTAILQ_HEAD(GlobalPropertyList, GlobalProperty) GlobalPropertyList;
+
/*** Board API. This should go away once we have a machine config file. ***/
DeviceState *qdev_create(BusState *bus, const char *name);
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 77fe3a1..b28ca37 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -176,7 +176,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
void qdev_prop_register_global(GlobalProperty *prop);
-void qdev_prop_register_global_list(GlobalProperty *props);
+void qdev_prop_register_global_list(GlobalPropertyList *props);
int qdev_prop_check_global(void);
void qdev_prop_set_globals(DeviceState *dev, Error **errp);
void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
diff --git a/vl.c b/vl.c
index 732b0d4..578c1d6 100644
--- a/vl.c
+++ b/vl.c
@@ -1569,8 +1569,10 @@ static void machine_class_init(ObjectClass *oc, void *data)
mc->is_default = qm->is_default;
mc->default_machine_opts = qm->default_machine_opts;
mc->default_boot_order = qm->default_boot_order;
- mc->compat_props = qm->compat_props;
mc->hw_version = qm->hw_version;
+ if (qm->compat_props) {
+ machine_class_add_compat_props(mc, qm->compat_props);
+ }
}
int qemu_register_machine(QEMUMachine *m)
@@ -4374,9 +4376,7 @@ int main(int argc, char **argv, char **envp)
exit (i == 1 ? 1 : 0);
}
- if (machine_class->compat_props) {
- qdev_prop_register_global_list(machine_class->compat_props);
- }
+ qdev_prop_register_global_list(&machine_class->compat_props);
qemu_add_globals();
qdev_machine_init();
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 11/35] pc: Register machine classes directly instead of using QEMUMachine
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (9 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 10/35] machine: Make compat_props a linked list Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 12/35] pc: Eliminate pc_common_machine_options() Eduardo Habkost
` (23 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
This is a (mostly) blind and mechanical conversion of the PC QEMUMachine
definitions to corresponding class registration code.
Existing duplication and unnecessary complexity on macro/function reuse
is being kept, to keep the conversion simple to review. The complexity
and duplication will be gradually removed by the next patches.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
---
Changes v1 -> v2:
* Remove unused PC_DEFAULT_MACHINE_OPTIONS macro leftover
* Use machine_class_register_global_props_array()
* Rebase on top of Michael's pci tree
* Eliminate qemu_register_pc_machine(), as it is not needed anymore
Changes v2 -> v3:
* Make static TypeInfo structs const
Suggested-by: Andreas Färber <afaerber@suse.de>
---
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(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 6755c80..1fd8ec1 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1507,50 +1507,6 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
}
}
-static void pc_generic_machine_class_init(ObjectClass *oc, void *data)
-{
- MachineClass *mc = MACHINE_CLASS(oc);
- QEMUMachine *qm = data;
-
- mc->name = qm->name;
- mc->alias = qm->alias;
- mc->desc = qm->desc;
- mc->init = qm->init;
- mc->reset = qm->reset;
- mc->hot_add_cpu = qm->hot_add_cpu;
- mc->kvm_type = qm->kvm_type;
- mc->block_default_type = qm->block_default_type;
- mc->max_cpus = qm->max_cpus;
- mc->no_serial = qm->no_serial;
- mc->no_parallel = qm->no_parallel;
- mc->use_virtcon = qm->use_virtcon;
- mc->use_sclp = qm->use_sclp;
- mc->no_floppy = qm->no_floppy;
- mc->no_cdrom = qm->no_cdrom;
- mc->no_sdcard = qm->no_sdcard;
- mc->is_default = qm->is_default;
- mc->default_machine_opts = qm->default_machine_opts;
- mc->default_boot_order = qm->default_boot_order;
- mc->hw_version = qm->hw_version;
- if (qm->compat_props) {
- machine_class_add_compat_props(mc, qm->compat_props);
- }
-}
-
-void qemu_register_pc_machine(QEMUMachine *m)
-{
- char *name = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL);
- TypeInfo ti = {
- .name = name,
- .parent = TYPE_PC_MACHINE,
- .class_init = pc_generic_machine_class_init,
- .class_data = (void *)m,
- };
-
- type_register(&ti);
- g_free(name);
-}
-
static void pc_dimm_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 2ef90f2..247fc17 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -432,81 +432,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)
+{
+ 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 const TypeInfo pc_i440fx_machine_v2_1_type_info = {
+ .name = "pc-i440fx-2.1" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v2_1_class_init,
};
-#define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
+#define pc_i440fx_2_0_machine_options pc_i440fx_2_1_machine_options
-static QEMUMachine pc_i440fx_machine_v2_0 = {
- PC_I440FX_2_0_MACHINE_OPTIONS,
- .name = "pc-i440fx-2.0",
- .init = pc_init_pci_2_0,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_2_0,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_2_0_machine_options(mc);
+ mc->init = pc_init_pci_2_0;
+ mc->name = "pc-i440fx-2.0";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
+ .name = "pc-i440fx-2.0" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v2_0_class_init,
};
-#define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
+#define pc_i440fx_1_7_machine_options pc_i440fx_machine_options
-static QEMUMachine pc_i440fx_machine_v1_7 = {
- PC_I440FX_1_7_MACHINE_OPTIONS,
- .name = "pc-i440fx-1.7",
- .init = pc_init_pci_1_7,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
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);
+}
+
+static const TypeInfo pc_i440fx_machine_v1_7_type_info = {
+ .name = "pc-i440fx-1.7" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v1_7_class_init,
};
-#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
+#define pc_i440fx_1_6_machine_options pc_i440fx_machine_options
-static QEMUMachine pc_i440fx_machine_v1_6 = {
- PC_I440FX_1_6_MACHINE_OPTIONS,
- .name = "pc-i440fx-1.6",
- .init = pc_init_pci_1_6,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
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);
+}
+
+static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
+ .name = "pc-i440fx-1.6" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v1_6_class_init,
};
-static QEMUMachine pc_i440fx_machine_v1_5 = {
- PC_I440FX_1_6_MACHINE_OPTIONS,
- .name = "pc-i440fx-1.5",
- .init = pc_init_pci_1_5,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
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);
+}
+
+static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
+ .name = "pc-i440fx-1.5" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v1_5_class_init,
};
-#define PC_I440FX_1_4_MACHINE_OPTIONS \
- PC_I440FX_1_6_MACHINE_OPTIONS, \
- .hot_add_cpu = NULL
+static void pc_i440fx_1_4_machine_options(MachineClass *mc)
+{
+ pc_i440fx_1_6_machine_options(mc);
+ mc->hot_add_cpu = NULL;
+}
-static QEMUMachine pc_i440fx_machine_v1_4 = {
- PC_I440FX_1_4_MACHINE_OPTIONS,
- .name = "pc-i440fx-1.4",
- .init = pc_init_pci_1_4,
- .compat_props = (GlobalProperty[]) {
+static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_4,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_4_machine_options(mc);
+ mc->init = pc_init_pci_1_4;
+ mc->name = "pc-i440fx-1.4";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_i440fx_machine_v1_4_type_info = {
+ .name = "pc-i440fx-1.4" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_v1_4_class_init,
};
#define PC_COMPAT_1_3 \
@@ -529,14 +588,23 @@ static QEMUMachine pc_i440fx_machine_v1_4 = {
.value = "off",\
}
-static QEMUMachine pc_machine_v1_3 = {
- PC_I440FX_1_4_MACHINE_OPTIONS,
- .name = "pc-1.3",
- .init = pc_init_pci_1_3,
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_3,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_4_machine_options(mc);
+ mc->init = pc_init_pci_1_3;
+ mc->name = "pc-1.3";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v1_3_type_info = {
+ .name = "pc-1.3" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v1_3_class_init,
};
#define PC_COMPAT_1_2 \
@@ -567,17 +635,28 @@ static QEMUMachine pc_machine_v1_3 = {
.value = "off",\
}
-#define PC_I440FX_1_2_MACHINE_OPTIONS \
- PC_I440FX_1_4_MACHINE_OPTIONS, \
- .init = pc_init_pci_1_2
+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 QEMUMachine pc_machine_v1_2 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-1.2",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_2,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->name = "pc-1.2";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v1_2_type_info = {
+ .name = "pc-1.2" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v1_2_class_init,
};
#define PC_COMPAT_1_1 \
@@ -612,13 +691,22 @@ static QEMUMachine pc_machine_v1_2 = {
.value = "off",\
}
-static QEMUMachine pc_machine_v1_1 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-1.1",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v1_1_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_1,
{ /* end of list */ }
- },
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->name = "pc-1.1";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v1_1_type_info = {
+ .name = "pc-1.1" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v1_1_class_init,
};
#define PC_COMPAT_1_0 \
@@ -641,27 +729,45 @@ static QEMUMachine pc_machine_v1_1 = {
.value = "no",\
}
-static QEMUMachine pc_machine_v1_0 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-1.0",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v1_0_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_0,
{ /* end of list */ }
- },
- .hw_version = "1.0",
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->hw_version = "1.0";
+ mc->name = "pc-1.0";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v1_0_type_info = {
+ .name = "pc-1.0" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v1_0_class_init,
};
#define PC_COMPAT_0_15 \
PC_COMPAT_1_0
-static QEMUMachine pc_machine_v0_15 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-0.15",
- .compat_props = (GlobalProperty[]) {
+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 */ }
- },
- .hw_version = "0.15",
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->hw_version = "0.15";
+ mc->name = "pc-0.15";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v0_15_type_info = {
+ .name = "pc-0.15" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_15_class_init,
};
#define PC_COMPAT_0_14 \
@@ -692,14 +798,23 @@ static QEMUMachine pc_machine_v0_15 = {
.value = stringify(2),\
}
-static QEMUMachine pc_machine_v0_14 = {
- PC_I440FX_1_2_MACHINE_OPTIONS,
- .name = "pc-0.14",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_14_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_14,
{ /* end of list */ }
- },
- .hw_version = "0.14",
+ };
+ pc_i440fx_1_2_machine_options(mc);
+ mc->hw_version = "0.14";
+ mc->name = "pc-0.14";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v0_14_type_info = {
+ .name = "pc-0.14" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_14_class_init,
};
#define PC_COMPAT_0_13 \
@@ -726,18 +841,29 @@ static QEMUMachine pc_machine_v0_14 = {
.value = stringify(0),\
}
-#define PC_I440FX_0_13_MACHINE_OPTIONS \
- PC_I440FX_1_2_MACHINE_OPTIONS, \
- .init = pc_init_pci_no_kvmclock
+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 QEMUMachine pc_machine_v0_13 = {
- PC_I440FX_0_13_MACHINE_OPTIONS,
- .name = "pc-0.13",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_13,
{ /* end of list */ }
- },
- .hw_version = "0.13",
+ };
+ pc_i440fx_0_13_machine_options(mc);
+ mc->hw_version = "0.13";
+ mc->name = "pc-0.13";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v0_13_type_info = {
+ .name = "pc-0.13" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_13_class_init,
};
#define PC_COMPAT_0_12 \
@@ -764,14 +890,23 @@ static QEMUMachine pc_machine_v0_13 = {
.value = "1",\
}
-static QEMUMachine pc_machine_v0_12 = {
- PC_I440FX_0_13_MACHINE_OPTIONS,
- .name = "pc-0.12",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_12,
{ /* end of list */ }
- },
- .hw_version = "0.12",
+ };
+ pc_i440fx_0_13_machine_options(mc);
+ mc->hw_version = "0.12";
+ mc->name = "pc-0.12";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v0_12_type_info = {
+ .name = "pc-0.12" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_12_class_init,
};
#define PC_COMPAT_0_11 \
@@ -794,20 +929,29 @@ static QEMUMachine pc_machine_v0_12 = {
.value = "0.11",\
}
-static QEMUMachine pc_machine_v0_11 = {
- PC_I440FX_0_13_MACHINE_OPTIONS,
- .name = "pc-0.11",
- .compat_props = (GlobalProperty[]) {
+static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_0_11,
{ /* end of list */ }
- },
- .hw_version = "0.11",
+ };
+ pc_i440fx_0_13_machine_options(mc);
+ mc->hw_version = "0.11";
+ mc->name = "pc-0.11";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v0_11_type_info = {
+ .name = "pc-0.11" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_11_class_init,
};
-static QEMUMachine pc_machine_v0_10 = {
- PC_I440FX_0_13_MACHINE_OPTIONS,
- .name = "pc-0.10",
- .compat_props = (GlobalProperty[]) {
+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",
@@ -831,31 +975,44 @@ static QEMUMachine pc_machine_v0_10 = {
.value = "0.10",
},
{ /* end of list */ }
- },
- .hw_version = "0.10",
+ };
+ pc_i440fx_0_13_machine_options(mc);
+ mc->hw_version = "0.10";
+ mc->name = "pc-0.10";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo pc_machine_v0_10_type_info = {
+ .name = "pc-0.10" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_machine_v0_10_class_init,
};
-static QEMUMachine isapc_machine = {
- PC_COMMON_MACHINE_OPTIONS,
- .name = "isapc",
- .desc = "ISA-only PC",
- .init = pc_init_isa,
- .max_cpus = 1,
- .compat_props = (GlobalProperty[]) {
+static void isapc_machine_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ 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;
+ mc->name = "isapc";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo isapc_machine_type_info = {
+ .name = "isapc" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = isapc_machine_class_init,
};
#ifdef CONFIG_XEN
-static QEMUMachine xenfv_machine = {
- PC_COMMON_MACHINE_OPTIONS,
- .name = "xenfv",
- .desc = "Xen Fully-virtualized PC",
- .init = pc_xen_hvm_init,
- .max_cpus = HVM_MAX_VCPUS,
- .default_machine_opts = "accel=xen",
- .hot_add_cpu = pc_hot_add_cpu,
- .compat_props = (GlobalProperty[]) {
+static void xenfv_machine_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
/* xenfv has no fwcfg and so does not load acpi from QEMU.
* as such new acpi features don't work.
*/
@@ -865,31 +1022,45 @@ static QEMUMachine xenfv_machine = {
.value = "off",
},
{ /* 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;
+ mc->default_machine_opts = "accel=xen";
+ mc->hot_add_cpu = pc_hot_add_cpu;
+ mc->name = "xenfv";
+ machine_class_add_compat_props(mc, compat_props);
+}
+
+static const TypeInfo xenfv_machine_type_info = {
+ .name = "xenfv" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = xenfv_machine_class_init,
};
#endif
static void pc_machine_init(void)
{
- qemu_register_pc_machine(&pc_i440fx_machine_v2_1);
- qemu_register_pc_machine(&pc_i440fx_machine_v2_0);
- qemu_register_pc_machine(&pc_i440fx_machine_v1_7);
- qemu_register_pc_machine(&pc_i440fx_machine_v1_6);
- qemu_register_pc_machine(&pc_i440fx_machine_v1_5);
- qemu_register_pc_machine(&pc_i440fx_machine_v1_4);
- qemu_register_pc_machine(&pc_machine_v1_3);
- qemu_register_pc_machine(&pc_machine_v1_2);
- qemu_register_pc_machine(&pc_machine_v1_1);
- qemu_register_pc_machine(&pc_machine_v1_0);
- qemu_register_pc_machine(&pc_machine_v0_15);
- qemu_register_pc_machine(&pc_machine_v0_14);
- qemu_register_pc_machine(&pc_machine_v0_13);
- qemu_register_pc_machine(&pc_machine_v0_12);
- qemu_register_pc_machine(&pc_machine_v0_11);
- qemu_register_pc_machine(&pc_machine_v0_10);
- qemu_register_pc_machine(&isapc_machine);
+ 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);
+ type_register_static(&pc_i440fx_machine_v1_6_type_info);
+ type_register_static(&pc_i440fx_machine_v1_5_type_info);
+ type_register_static(&pc_i440fx_machine_v1_4_type_info);
+ type_register_static(&pc_machine_v1_3_type_info);
+ type_register_static(&pc_machine_v1_2_type_info);
+ type_register_static(&pc_machine_v1_1_type_info);
+ type_register_static(&pc_machine_v1_0_type_info);
+ type_register_static(&pc_machine_v0_15_type_info);
+ type_register_static(&pc_machine_v0_14_type_info);
+ type_register_static(&pc_machine_v0_13_type_info);
+ type_register_static(&pc_machine_v0_12_type_info);
+ type_register_static(&pc_machine_v0_11_type_info);
+ type_register_static(&pc_machine_v0_10_type_info);
+ type_register_static(&isapc_machine_type_info);
#ifdef CONFIG_XEN
- qemu_register_pc_machine(&xenfv_machine);
+ type_register_static(&xenfv_machine_type_info);
#endif
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 36b6ab0..f97bd8a 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -338,90 +338,149 @@ static void pc_q35_init_1_4(MachineState *machine)
pc_q35_init(machine);
}
-#define PC_Q35_MACHINE_OPTIONS \
- PC_DEFAULT_MACHINE_OPTIONS, \
- .desc = "Standard PC (Q35 + ICH9, 2009)", \
- .hot_add_cpu = pc_hot_add_cpu
-
-#define PC_Q35_2_1_MACHINE_OPTIONS \
- PC_Q35_MACHINE_OPTIONS, \
- .default_machine_opts = "firmware=bios-256k.bin"
-
-static QEMUMachine pc_q35_machine_v2_1 = {
- PC_Q35_2_1_MACHINE_OPTIONS,
- .name = "pc-q35-2.1",
- .alias = "q35",
- .init = pc_q35_init,
+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;
+}
+
+static void pc_q35_2_1_machine_options(MachineClass *mc)
+{
+ pc_q35_machine_options(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->alias = "q35";
+ mc->init = pc_q35_init;
+ mc->name = "pc-q35-2.1";
+}
+
+static TypeInfo pc_q35_machine_v2_1_type_info = {
+ .name = "pc-q35-2.1" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v2_1_class_init,
};
-#define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
+#define pc_q35_2_0_machine_options pc_q35_2_1_machine_options
-static QEMUMachine pc_q35_machine_v2_0 = {
- PC_Q35_2_0_MACHINE_OPTIONS,
- .name = "pc-q35-2.0",
- .init = pc_q35_init_2_0,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_2_0,
{ /* end of list */ }
- },
+ };
+ pc_q35_2_0_machine_options(mc);
+ mc->init = pc_q35_init_2_0;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-2.0";
+}
+
+static TypeInfo pc_q35_machine_v2_0_type_info = {
+ .name = "pc-q35-2.0" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v2_0_class_init,
};
-#define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
+#define pc_q35_1_7_machine_options pc_q35_machine_options
-static QEMUMachine pc_q35_machine_v1_7 = {
- PC_Q35_1_7_MACHINE_OPTIONS,
- .name = "pc-q35-1.7",
- .init = pc_q35_init_1_7,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_7,
{ /* end of list */ }
- },
+ };
+ pc_q35_1_7_machine_options(mc);
+ mc->init = pc_q35_init_1_7;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-1.7";
+}
+
+static TypeInfo pc_q35_machine_v1_7_type_info = {
+ .name = "pc-q35-1.7" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v1_7_class_init,
};
-#define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
+#define pc_q35_1_6_machine_options pc_q35_machine_options
-static QEMUMachine pc_q35_machine_v1_6 = {
- PC_Q35_1_6_MACHINE_OPTIONS,
- .name = "pc-q35-1.6",
- .init = pc_q35_init_1_6,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_6,
{ /* end of list */ }
- },
+ };
+ pc_q35_1_6_machine_options(mc);
+ mc->init = pc_q35_init_1_6;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-1.6";
+}
+
+static TypeInfo pc_q35_machine_v1_6_type_info = {
+ .name = "pc-q35-1.6" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v1_6_class_init,
};
-static QEMUMachine pc_q35_machine_v1_5 = {
- PC_Q35_1_6_MACHINE_OPTIONS,
- .name = "pc-q35-1.5",
- .init = pc_q35_init_1_5,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_5,
{ /* end of list */ }
- },
+ };
+ pc_q35_1_6_machine_options(mc);
+ mc->init = pc_q35_init_1_5;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-1.5";
+}
+
+static TypeInfo pc_q35_machine_v1_5_type_info = {
+ .name = "pc-q35-1.5" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v1_5_class_init,
};
-#define PC_Q35_1_4_MACHINE_OPTIONS \
- PC_Q35_1_6_MACHINE_OPTIONS, \
- .hot_add_cpu = NULL
+static void pc_q35_1_4_machine_options(MachineClass *mc)
+{
+ pc_q35_1_6_machine_options(mc);
+ mc->hot_add_cpu = NULL;
+}
-static QEMUMachine pc_q35_machine_v1_4 = {
- PC_Q35_1_4_MACHINE_OPTIONS,
- .name = "pc-q35-1.4",
- .init = pc_q35_init_1_4,
- .compat_props = (GlobalProperty[]) {
+static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ static GlobalProperty compat_props[] = {
PC_COMPAT_1_4,
{ /* end of list */ }
- },
+ };
+ pc_q35_1_4_machine_options(mc);
+ mc->init = pc_q35_init_1_4;
+ machine_class_add_compat_props(mc, compat_props);
+ mc->name = "pc-q35-1.4";
+}
+
+static TypeInfo pc_q35_machine_v1_4_type_info = {
+ .name = "pc-q35-1.4" TYPE_MACHINE_SUFFIX,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_v1_4_class_init,
};
static void pc_q35_machine_init(void)
{
- qemu_register_pc_machine(&pc_q35_machine_v2_1);
- qemu_register_pc_machine(&pc_q35_machine_v2_0);
- qemu_register_pc_machine(&pc_q35_machine_v1_7);
- qemu_register_pc_machine(&pc_q35_machine_v1_6);
- qemu_register_pc_machine(&pc_q35_machine_v1_5);
- qemu_register_pc_machine(&pc_q35_machine_v1_4);
+ 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);
+ type_register_static(&pc_q35_machine_v1_6_type_info);
+ type_register_static(&pc_q35_machine_v1_5_type_info);
+ type_register_static(&pc_q35_machine_v1_4_type_info);
}
machine_init(pc_q35_machine_init);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 4a9eb46..7459778 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -8,6 +8,7 @@
#include "hw/block/fdc.h"
#include "net/net.h"
#include "hw/i386/ioapic.h"
+#include "hw/boards.h"
#include "qemu/range.h"
#include "qemu/bitmap.h"
@@ -499,12 +500,16 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.value = stringify(0),\
}
-#define PC_COMMON_MACHINE_OPTIONS \
- .default_boot_order = "cad"
+static inline void pc_common_machine_options(MachineClass *mc)
+{
+ mc->default_boot_order = "cad";
+}
-#define PC_DEFAULT_MACHINE_OPTIONS \
- PC_COMMON_MACHINE_OPTIONS, \
- .hot_add_cpu = pc_hot_add_cpu, \
- .max_cpus = 255
+static inline void pc_default_machine_options(MachineClass *mc)
+{
+ pc_common_machine_options(mc);
+ mc->hot_add_cpu = pc_hot_add_cpu;
+ mc->max_cpus = 255;
+}
#endif
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 12/35] pc: Eliminate pc_common_machine_options()
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (10 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 11/35] pc: Register machine classes directly instead of using QEMUMachine Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 13/35] pc: Eliminate pc_default_machine_options() Eduardo Habkost
` (22 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
The TYPE_PC_MACHINE parent class can initialize the common options for
all PC machines.
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 2 --
include/hw/i386/pc.h | 6 ------
3 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 1fd8ec1..d812ab7 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1663,6 +1663,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->get_hotplug_handler = mc->get_hotplug_handler;
mc->get_hotplug_handler = pc_get_hotpug_handler;
+ mc->default_boot_order = "cad";
hc->plug = pc_machine_device_plug_cb;
}
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 247fc17..16c948a 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -994,7 +994,6 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
static GlobalProperty compat_props[] = {
{ /* end of list */ }
};
- pc_common_machine_options(mc);
mc->desc = "ISA-only PC";
mc->init = pc_init_isa;
mc->max_cpus = 1;
@@ -1023,7 +1022,6 @@ static void xenfv_machine_class_init(ObjectClass *oc, void *data)
},
{ /* end of list */ }
};
- pc_common_machine_options(mc);
mc->desc = "Xen Fully-virtualized PC";
mc->init = pc_xen_hvm_init;
mc->max_cpus = HVM_MAX_VCPUS;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 7459778..5d5d193 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -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;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 13/35] pc: Eliminate pc_default_machine_options()
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (11 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 12/35] pc: Eliminate pc_common_machine_options() Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 14/35] piix: Eliminate pc_i440fx_machine_options() Eduardo Habkost
` (21 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
The only PC machines that didn't call pc_default_machine_options() were
isaps and xenfv. Both were already overwriting max_cpus, and only isapc
was not overwriting hot_add_cpu.
After making isapc set hot_add_cpu to NULL, we can move the
pc_default_machine_options() code the PC common class_init.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index d812ab7..7a6aa66 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1664,6 +1664,8 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->get_hotplug_handler = mc->get_hotplug_handler;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->default_boot_order = "cad";
+ mc->hot_add_cpu = pc_hot_add_cpu;
+ mc->max_cpus = 255;
hc->plug = pc_machine_device_plug_cb;
}
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 16c948a..dab2085 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -434,7 +434,6 @@ static void pc_xen_hvm_init(MachineState *machine)
static void pc_i440fx_machine_options(MachineClass *mc)
{
- pc_default_machine_options(mc);
mc->desc = "Standard PC (i440FX + PIIX, 1996)";
mc->hot_add_cpu = pc_hot_add_cpu;
}
@@ -997,6 +996,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
mc->desc = "ISA-only PC";
mc->init = pc_init_isa;
mc->max_cpus = 1;
+ mc->hot_add_cpu = NULL;
mc->name = "isapc";
machine_class_add_compat_props(mc, compat_props);
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index f97bd8a..29bc4db 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -340,7 +340,6 @@ static void pc_q35_init_1_4(MachineState *machine)
static void pc_q35_machine_options(MachineClass *mc)
{
- pc_default_machine_options(mc);
mc->desc = "Standard PC (Q35 + ICH9, 2009)";
mc->hot_add_cpu = pc_hot_add_cpu;
}
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 5d5d193..e140b1e 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -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
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 14/35] piix: Eliminate pc_i440fx_machine_options()
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (12 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 13/35] pc: Eliminate pc_default_machine_options() Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 15/35] q35: Eliminate pc_q35_machine_options() Eduardo Habkost
` (20 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Instead of calling it on every i440fx class_init function, just register
a common parent class for all i440fx machine-types.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 55 +++++++++++++++++++++++++++++--------------------------
1 file changed, 29 insertions(+), 26 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index dab2085..7081243 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -432,15 +432,25 @@ static void pc_xen_hvm_init(MachineState *machine)
}
#endif
-static void pc_i440fx_machine_options(MachineClass *mc)
+static void pc_i440fx_machine_class_init(ObjectClass *oc, void *data)
{
+ MachineClass *mc = MACHINE_CLASS(oc);
mc->desc = "Standard PC (i440FX + PIIX, 1996)";
mc->hot_add_cpu = pc_hot_add_cpu;
}
+#define TYPE_PC_I440FX_MACHINE "pc-i440fx" TYPE_MACHINE_SUFFIX
+
+static TypeInfo pc_i440fx_machine_type_info = {
+ .name = TYPE_PC_I440FX_MACHINE,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_i440fx_machine_class_init,
+ .abstract = true,
+};
+
+
static void pc_i440fx_2_1_machine_options(MachineClass *mc)
{
- pc_i440fx_machine_options(mc);
mc->default_machine_opts = "firmware=bios-256k.bin";
}
@@ -456,7 +466,7 @@ static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_i440fx_machine_v2_1_type_info = {
.name = "pc-i440fx-2.1" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_i440fx_machine_v2_1_class_init,
};
@@ -477,12 +487,10 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
.name = "pc-i440fx-2.0" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_i440fx_machine_v2_0_class_init,
};
-#define pc_i440fx_1_7_machine_options pc_i440fx_machine_options
-
static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -490,7 +498,6 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_7,
{ /* end of list */ }
};
- pc_i440fx_1_7_machine_options(mc);
mc->init = pc_init_pci_1_7;
mc->name = "pc-i440fx-1.7";
machine_class_add_compat_props(mc, compat_props);
@@ -498,12 +505,10 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_i440fx_machine_v1_7_type_info = {
.name = "pc-i440fx-1.7" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_i440fx_machine_v1_7_class_init,
};
-#define pc_i440fx_1_6_machine_options pc_i440fx_machine_options
-
static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -511,7 +516,6 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_6,
{ /* end of list */ }
};
- pc_i440fx_1_6_machine_options(mc);
mc->init = pc_init_pci_1_6;
mc->name = "pc-i440fx-1.6";
machine_class_add_compat_props(mc, compat_props);
@@ -519,7 +523,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
.name = "pc-i440fx-1.6" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_i440fx_machine_v1_6_class_init,
};
@@ -530,7 +534,6 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_5,
{ /* end of list */ }
};
- pc_i440fx_1_6_machine_options(mc);
mc->init = pc_init_pci_1_5;
mc->name = "pc-i440fx-1.5";
machine_class_add_compat_props(mc, compat_props);
@@ -538,13 +541,12 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
.name = "pc-i440fx-1.5" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_i440fx_machine_v1_5_class_init,
};
static void pc_i440fx_1_4_machine_options(MachineClass *mc)
{
- pc_i440fx_1_6_machine_options(mc);
mc->hot_add_cpu = NULL;
}
@@ -563,7 +565,7 @@ static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_i440fx_machine_v1_4_type_info = {
.name = "pc-i440fx-1.4" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_i440fx_machine_v1_4_class_init,
};
@@ -602,7 +604,7 @@ static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v1_3_type_info = {
.name = "pc-1.3" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v1_3_class_init,
};
@@ -654,7 +656,7 @@ static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v1_2_type_info = {
.name = "pc-1.2" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v1_2_class_init,
};
@@ -704,7 +706,7 @@ static void pc_machine_v1_1_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v1_1_type_info = {
.name = "pc-1.1" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v1_1_class_init,
};
@@ -743,7 +745,7 @@ static void pc_machine_v1_0_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v1_0_type_info = {
.name = "pc-1.0" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v1_0_class_init,
};
@@ -765,7 +767,7 @@ static void pc_machine_v0_15_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v0_15_type_info = {
.name = "pc-0.15" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v0_15_class_init,
};
@@ -812,7 +814,7 @@ static void pc_machine_v0_14_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v0_14_type_info = {
.name = "pc-0.14" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v0_14_class_init,
};
@@ -861,7 +863,7 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v0_13_type_info = {
.name = "pc-0.13" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v0_13_class_init,
};
@@ -904,7 +906,7 @@ static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v0_12_type_info = {
.name = "pc-0.12" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v0_12_class_init,
};
@@ -943,7 +945,7 @@ static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v0_11_type_info = {
.name = "pc-0.11" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v0_11_class_init,
};
@@ -983,7 +985,7 @@ static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)
static const TypeInfo pc_machine_v0_10_type_info = {
.name = "pc-0.10" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_I440FX_MACHINE,
.class_init = pc_machine_v0_10_class_init,
};
@@ -1040,6 +1042,7 @@ static const TypeInfo xenfv_machine_type_info = {
static void pc_machine_init(void)
{
+ type_register_static(&pc_i440fx_machine_type_info);
type_register_static(&pc_i440fx_machine_v2_1_type_info);
type_register_static(&pc_i440fx_machine_v2_0_type_info);
type_register_static(&pc_i440fx_machine_v1_7_type_info);
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 15/35] q35: Eliminate pc_q35_machine_options()
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (13 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 14/35] piix: Eliminate pc_i440fx_machine_options() Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 16/35] q35: Eliminate pc_q35_1_4_machine_options() Eduardo Habkost
` (19 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Instead of calling it on every q35 class_init function, just register a
common parent class for all q35 machine-types.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_q35.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 29bc4db..bf85c17 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -338,15 +338,24 @@ static void pc_q35_init_1_4(MachineState *machine)
pc_q35_init(machine);
}
-static void pc_q35_machine_options(MachineClass *mc)
+static void pc_q35_machine_class_init(ObjectClass *oc, void *data)
{
+ MachineClass *mc = MACHINE_CLASS(oc);
mc->desc = "Standard PC (Q35 + ICH9, 2009)";
mc->hot_add_cpu = pc_hot_add_cpu;
}
+#define TYPE_PC_Q35_MACHINE "pc-q35" TYPE_MACHINE_SUFFIX
+
+static TypeInfo pc_q35_machine_type_info = {
+ .name = TYPE_PC_Q35_MACHINE,
+ .parent = TYPE_PC_MACHINE,
+ .class_init = pc_q35_machine_class_init,
+ .abstract = true,
+};
+
static void pc_q35_2_1_machine_options(MachineClass *mc)
{
- pc_q35_machine_options(mc);
mc->default_machine_opts = "firmware=bios-256k.bin";
}
@@ -361,7 +370,7 @@ static void pc_q35_machine_v2_1_class_init(ObjectClass *oc, void *data)
static TypeInfo pc_q35_machine_v2_1_type_info = {
.name = "pc-q35-2.1" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_Q35_MACHINE,
.class_init = pc_q35_machine_v2_1_class_init,
};
@@ -382,12 +391,10 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
static TypeInfo pc_q35_machine_v2_0_type_info = {
.name = "pc-q35-2.0" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_Q35_MACHINE,
.class_init = pc_q35_machine_v2_0_class_init,
};
-#define pc_q35_1_7_machine_options pc_q35_machine_options
-
static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -395,7 +402,6 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_7,
{ /* end of list */ }
};
- pc_q35_1_7_machine_options(mc);
mc->init = pc_q35_init_1_7;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.7";
@@ -403,12 +409,10 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
static TypeInfo pc_q35_machine_v1_7_type_info = {
.name = "pc-q35-1.7" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_Q35_MACHINE,
.class_init = pc_q35_machine_v1_7_class_init,
};
-#define pc_q35_1_6_machine_options pc_q35_machine_options
-
static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -416,7 +420,6 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_6,
{ /* end of list */ }
};
- pc_q35_1_6_machine_options(mc);
mc->init = pc_q35_init_1_6;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.6";
@@ -424,7 +427,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
static TypeInfo pc_q35_machine_v1_6_type_info = {
.name = "pc-q35-1.6" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_Q35_MACHINE,
.class_init = pc_q35_machine_v1_6_class_init,
};
@@ -435,7 +438,6 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_5,
{ /* end of list */ }
};
- pc_q35_1_6_machine_options(mc);
mc->init = pc_q35_init_1_5;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.5";
@@ -443,13 +445,12 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
static TypeInfo pc_q35_machine_v1_5_type_info = {
.name = "pc-q35-1.5" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_Q35_MACHINE,
.class_init = pc_q35_machine_v1_5_class_init,
};
static void pc_q35_1_4_machine_options(MachineClass *mc)
{
- pc_q35_1_6_machine_options(mc);
mc->hot_add_cpu = NULL;
}
@@ -468,12 +469,13 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
static TypeInfo pc_q35_machine_v1_4_type_info = {
.name = "pc-q35-1.4" TYPE_MACHINE_SUFFIX,
- .parent = TYPE_PC_MACHINE,
+ .parent = TYPE_PC_Q35_MACHINE,
.class_init = pc_q35_machine_v1_4_class_init,
};
static void pc_q35_machine_init(void)
{
+ type_register_static(&pc_q35_machine_type_info);
type_register_static(&pc_q35_machine_v2_1_type_info);
type_register_static(&pc_q35_machine_v2_0_type_info);
type_register_static(&pc_q35_machine_v1_7_type_info);
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 16/35] q35: Eliminate pc_q35_1_4_machine_options()
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (14 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 15/35] q35: Eliminate pc_q35_machine_options() Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 17/35] pc: Eliminate all *_machine_options() functions Eduardo Habkost
` (18 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
The function was used only in a single place.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_q35.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index bf85c17..9eeeac6 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -449,11 +449,6 @@ static TypeInfo pc_q35_machine_v1_5_type_info = {
.class_init = pc_q35_machine_v1_5_class_init,
};
-static void pc_q35_1_4_machine_options(MachineClass *mc)
-{
- mc->hot_add_cpu = NULL;
-}
-
static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -461,7 +456,7 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_4,
{ /* end of list */ }
};
- pc_q35_1_4_machine_options(mc);
+ mc->hot_add_cpu = NULL;
mc->init = pc_q35_init_1_4;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.4";
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 17/35] pc: Eliminate all *_machine_options() functions
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (15 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 16/35] q35: Eliminate pc_q35_1_4_machine_options() Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 18/35] machine: Eliminate QEMUMachine.compat_props Eduardo Habkost
` (17 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Finally eliminate all *_machine_options() functions, and make the
class_init functions for older machine-types simply reuse the class_init
functions from newer machine-types.
To allow compat_props reuse, the the PC_COMPAT_* macros were changed to
not nest within the older PC_COMPAT_* macros anymore.
We can now make all pc-{i440fx,q36}-* class_init functions call the previous
one.
For reference (to help ensure the reuse of previous class_init functions
won't change any behavior), these are the fields that are touched by the
class_init functions:
* name: All machine-types set it, class_init reuse won't affect it.
* hw_version: All machines older than pc*-1.0 already set it, class_init reuse
won't affect it.
* desc: Only the base pc-{i440fx,q35} classes set it, so all classes already
reused it.
* hot_add_cpu:
* The base pc-{i440fx,q35} classes set it (so it was already reused by all
subclasses).
* pc-i440fx-1.4 was already overriding it inside
pc_i440fx_1_4_machine_options() (and all older machine-types already
reused it).
* On pc_q35.c, only pc-q-35-1.4 (which is the oldest pc-q35 subclass) set it.
* alias: Only pc*-2.1 was setting them, pc*-2.0 was now changed to unset both,
so only pc*-2.1 still have them set.
* is_default: Only pc-i440fx-2.1 was setting them, pc-i440fx-2.0 was now
changed to unset both, so only pc-i440fx-2.1 still have them set.
* init: pc*-1.3 to pc*-2.1 were already setting it. The only ones that didn't
set it were using the one set by previous *machine_options() functions.
* compat_props: All machine-types used PC_COMPAT_* macros that reused the
previous one. Now they will simply append to the compat_props list added by
the previous class_init function, and PC_COMPAT_* won't include the previous
macros inside them.
* default_machine_opts: It was set by pc_*_2_1_machine_options() and is
now set by pc-*-2.1 class_init(). pc*-1.7 and older didn't reuse
pc_*_2_1_machine_options(), so now pc*-1.7 class_init() set
default_machine_opts to NULL to ensure pc-*1.7 and older don't inherit
it.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 76 +++++++++++++++-------------------------------------
hw/i386/pc_q35.c | 17 ++++++------
include/hw/i386/pc.h | 4 ---
3 files changed, 30 insertions(+), 67 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 7081243..979bb40 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -448,16 +448,10 @@ static TypeInfo pc_i440fx_machine_type_info = {
.abstract = true,
};
-
-static void pc_i440fx_2_1_machine_options(MachineClass *mc)
-{
- mc->default_machine_opts = "firmware=bios-256k.bin";
-}
-
static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
- pc_i440fx_2_1_machine_options(mc);
+ mc->default_machine_opts = "firmware=bios-256k.bin";
mc->alias = "pc";
mc->init = pc_init_pci;
mc->is_default = 1;
@@ -470,8 +464,6 @@ static const TypeInfo pc_i440fx_machine_v2_1_type_info = {
.class_init = pc_i440fx_machine_v2_1_class_init,
};
-#define pc_i440fx_2_0_machine_options pc_i440fx_2_1_machine_options
-
static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -479,7 +471,9 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
PC_COMPAT_2_0,
{ /* end of list */ }
};
- pc_i440fx_2_0_machine_options(mc);
+ pc_i440fx_machine_v2_1_class_init(oc, data);
+ mc->alias = NULL;
+ mc->is_default = false;
mc->init = pc_init_pci_2_0;
mc->name = "pc-i440fx-2.0";
machine_class_add_compat_props(mc, compat_props);
@@ -498,6 +492,8 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_7,
{ /* end of list */ }
};
+ pc_i440fx_machine_v2_0_class_init(oc, data);
+ mc->default_machine_opts = NULL;
mc->init = pc_init_pci_1_7;
mc->name = "pc-i440fx-1.7";
machine_class_add_compat_props(mc, compat_props);
@@ -516,6 +512,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_6,
{ /* end of list */ }
};
+ pc_i440fx_machine_v1_7_class_init(oc, data);
mc->init = pc_init_pci_1_6;
mc->name = "pc-i440fx-1.6";
machine_class_add_compat_props(mc, compat_props);
@@ -534,6 +531,7 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_5,
{ /* end of list */ }
};
+ pc_i440fx_machine_v1_6_class_init(oc, data);
mc->init = pc_init_pci_1_5;
mc->name = "pc-i440fx-1.5";
machine_class_add_compat_props(mc, compat_props);
@@ -545,11 +543,6 @@ static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
.class_init = pc_i440fx_machine_v1_5_class_init,
};
-static void pc_i440fx_1_4_machine_options(MachineClass *mc)
-{
- mc->hot_add_cpu = NULL;
-}
-
static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -557,7 +550,8 @@ static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_4,
{ /* end of list */ }
};
- pc_i440fx_1_4_machine_options(mc);
+ pc_i440fx_machine_v1_5_class_init(oc, data);
+ mc->hot_add_cpu = NULL;
mc->init = pc_init_pci_1_4;
mc->name = "pc-i440fx-1.4";
machine_class_add_compat_props(mc, compat_props);
@@ -570,7 +564,6 @@ static const TypeInfo pc_i440fx_machine_v1_4_type_info = {
};
#define PC_COMPAT_1_3 \
- PC_COMPAT_1_4, \
{\
.driver = "usb-tablet",\
.property = "usb_version",\
@@ -596,7 +589,7 @@ static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_3,
{ /* end of list */ }
};
- pc_i440fx_1_4_machine_options(mc);
+ pc_i440fx_machine_v1_4_class_init(oc, data);
mc->init = pc_init_pci_1_3;
mc->name = "pc-1.3";
machine_class_add_compat_props(mc, compat_props);
@@ -609,7 +602,6 @@ static const TypeInfo pc_machine_v1_3_type_info = {
};
#define PC_COMPAT_1_2 \
- PC_COMPAT_1_3,\
{\
.driver = "nec-usb-xhci",\
.property = "msi",\
@@ -636,12 +628,6 @@ static const TypeInfo pc_machine_v1_3_type_info = {
.value = "off",\
}
-static void pc_i440fx_1_2_machine_options(MachineClass *mc)
-{
- pc_i440fx_1_4_machine_options(mc);
- mc->init = pc_init_pci_1_2;
-}
-
static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -649,7 +635,8 @@ static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_2,
{ /* end of list */ }
};
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v1_3_class_init(oc, data);
+ mc->init = pc_init_pci_1_2;
mc->name = "pc-1.2";
machine_class_add_compat_props(mc, compat_props);
}
@@ -661,7 +648,6 @@ static const TypeInfo pc_machine_v1_2_type_info = {
};
#define PC_COMPAT_1_1 \
- PC_COMPAT_1_2,\
{\
.driver = "virtio-scsi-pci",\
.property = "hotplug",\
@@ -699,7 +685,7 @@ static void pc_machine_v1_1_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_1,
{ /* end of list */ }
};
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v1_2_class_init(oc, data);
mc->name = "pc-1.1";
machine_class_add_compat_props(mc, compat_props);
}
@@ -737,7 +723,7 @@ static void pc_machine_v1_0_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_0,
{ /* end of list */ }
};
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v1_1_class_init(oc, data);
mc->hw_version = "1.0";
mc->name = "pc-1.0";
machine_class_add_compat_props(mc, compat_props);
@@ -749,20 +735,12 @@ static const TypeInfo pc_machine_v1_0_type_info = {
.class_init = pc_machine_v1_0_class_init,
};
-#define PC_COMPAT_0_15 \
- PC_COMPAT_1_0
-
static void pc_machine_v0_15_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
- static GlobalProperty compat_props[] = {
- PC_COMPAT_0_15,
- { /* end of list */ }
- };
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v1_0_class_init(oc, data);
mc->hw_version = "0.15";
mc->name = "pc-0.15";
- machine_class_add_compat_props(mc, compat_props);
}
static const TypeInfo pc_machine_v0_15_type_info = {
@@ -772,7 +750,6 @@ static const TypeInfo pc_machine_v0_15_type_info = {
};
#define PC_COMPAT_0_14 \
- PC_COMPAT_0_15,\
{\
.driver = "virtio-blk-pci",\
.property = "event_idx",\
@@ -806,7 +783,7 @@ static void pc_machine_v0_14_class_init(ObjectClass *oc, void *data)
PC_COMPAT_0_14,
{ /* end of list */ }
};
- pc_i440fx_1_2_machine_options(mc);
+ pc_machine_v0_15_class_init(oc, data);
mc->hw_version = "0.14";
mc->name = "pc-0.14";
machine_class_add_compat_props(mc, compat_props);
@@ -819,7 +796,6 @@ static const TypeInfo pc_machine_v0_14_type_info = {
};
#define PC_COMPAT_0_13 \
- PC_COMPAT_0_14,\
{\
.driver = TYPE_PCI_DEVICE,\
.property = "command_serr_enable",\
@@ -842,12 +818,6 @@ static const TypeInfo pc_machine_v0_14_type_info = {
.value = stringify(0),\
}
-static void pc_i440fx_0_13_machine_options(MachineClass *mc)
-{
- pc_i440fx_1_2_machine_options(mc);
- mc->init = pc_init_pci_no_kvmclock;
-}
-
static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -855,7 +825,8 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
PC_COMPAT_0_13,
{ /* end of list */ }
};
- pc_i440fx_0_13_machine_options(mc);
+ pc_machine_v0_14_class_init(oc, data);
+ mc->init = pc_init_pci_no_kvmclock;
mc->hw_version = "0.13";
mc->name = "pc-0.13";
machine_class_add_compat_props(mc, compat_props);
@@ -868,7 +839,6 @@ static const TypeInfo pc_machine_v0_13_type_info = {
};
#define PC_COMPAT_0_12 \
- PC_COMPAT_0_13,\
{\
.driver = "virtio-serial-pci",\
.property = "max_ports",\
@@ -898,7 +868,7 @@ static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)
PC_COMPAT_0_12,
{ /* end of list */ }
};
- pc_i440fx_0_13_machine_options(mc);
+ pc_machine_v0_13_class_init(oc, data);
mc->hw_version = "0.12";
mc->name = "pc-0.12";
machine_class_add_compat_props(mc, compat_props);
@@ -911,7 +881,6 @@ static const TypeInfo pc_machine_v0_12_type_info = {
};
#define PC_COMPAT_0_11 \
- PC_COMPAT_0_12,\
{\
.driver = "virtio-blk-pci",\
.property = "vectors",\
@@ -937,7 +906,7 @@ static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)
PC_COMPAT_0_11,
{ /* end of list */ }
};
- pc_i440fx_0_13_machine_options(mc);
+ pc_machine_v0_12_class_init(oc, data);
mc->hw_version = "0.11";
mc->name = "pc-0.11";
machine_class_add_compat_props(mc, compat_props);
@@ -953,7 +922,6 @@ static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
- PC_COMPAT_0_11,
{
.driver = "virtio-blk-pci",
.property = "class",
@@ -977,7 +945,7 @@ static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)
},
{ /* end of list */ }
};
- pc_i440fx_0_13_machine_options(mc);
+ pc_machine_v0_11_class_init(oc, data);
mc->hw_version = "0.10";
mc->name = "pc-0.10";
machine_class_add_compat_props(mc, compat_props);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 9eeeac6..74c6d3c 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -354,15 +354,10 @@ static TypeInfo pc_q35_machine_type_info = {
.abstract = true,
};
-static void pc_q35_2_1_machine_options(MachineClass *mc)
-{
- mc->default_machine_opts = "firmware=bios-256k.bin";
-}
-
static void pc_q35_machine_v2_1_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
- pc_q35_2_1_machine_options(mc);
+ mc->default_machine_opts = "firmware=bios-256k.bin";
mc->alias = "q35";
mc->init = pc_q35_init;
mc->name = "pc-q35-2.1";
@@ -374,8 +369,6 @@ static TypeInfo pc_q35_machine_v2_1_type_info = {
.class_init = pc_q35_machine_v2_1_class_init,
};
-#define pc_q35_2_0_machine_options pc_q35_2_1_machine_options
-
static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -383,7 +376,8 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
PC_COMPAT_2_0,
{ /* end of list */ }
};
- pc_q35_2_0_machine_options(mc);
+ pc_q35_machine_v2_1_class_init(oc, data);
+ mc->alias = NULL;
mc->init = pc_q35_init_2_0;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-2.0";
@@ -402,6 +396,8 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_7,
{ /* end of list */ }
};
+ pc_q35_machine_v2_0_class_init(oc, data);
+ mc->default_machine_opts = NULL;
mc->init = pc_q35_init_1_7;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.7";
@@ -420,6 +416,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_6,
{ /* end of list */ }
};
+ pc_q35_machine_v1_7_class_init(oc, data);
mc->init = pc_q35_init_1_6;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.6";
@@ -438,6 +435,7 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_5,
{ /* end of list */ }
};
+ pc_q35_machine_v1_6_class_init(oc, data);
mc->init = pc_q35_init_1_5;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.5";
@@ -456,6 +454,7 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_4,
{ /* end of list */ }
};
+ pc_q35_machine_v1_5_class_init(oc, data);
mc->hot_add_cpu = NULL;
mc->init = pc_q35_init_1_4;
machine_class_add_compat_props(mc, compat_props);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index e140b1e..318f2cc 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -350,7 +350,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
}
#define PC_COMPAT_1_7 \
- PC_COMPAT_2_0, \
{\
.driver = TYPE_USB_DEVICE,\
.property = "msos-desc",\
@@ -368,7 +367,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
}
#define PC_COMPAT_1_6 \
- PC_COMPAT_1_7, \
{\
.driver = "e1000",\
.property = "mitigation",\
@@ -392,7 +390,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
}
#define PC_COMPAT_1_5 \
- PC_COMPAT_1_6, \
{\
.driver = "Conroe-" TYPE_X86_CPU,\
.property = "model",\
@@ -436,7 +433,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
}
#define PC_COMPAT_1_4 \
- PC_COMPAT_1_5, \
{\
.driver = "scsi-hd",\
.property = "discard_granularity",\
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 18/35] machine: Eliminate QEMUMachine.compat_props
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (16 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 17/35] pc: Eliminate all *_machine_options() functions Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 19/35] pc: Rename pc_machine variable to pcms Eduardo Habkost
` (16 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
The only user of QEMUMachine.compat_props was the PC code, that was
already converted to QOM. We don't need that field anymore.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/hw/boards.h | 1 -
vl.c | 3 ---
2 files changed, 4 deletions(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 15d6ac7..69b76a1 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -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;
};
diff --git a/vl.c b/vl.c
index 578c1d6..43e65e6 100644
--- a/vl.c
+++ b/vl.c
@@ -1570,9 +1570,6 @@ static void machine_class_init(ObjectClass *oc, void *data)
mc->default_machine_opts = qm->default_machine_opts;
mc->default_boot_order = qm->default_boot_order;
mc->hw_version = qm->hw_version;
- if (qm->compat_props) {
- machine_class_add_compat_props(mc, qm->compat_props);
- }
}
int qemu_register_machine(QEMUMachine *m)
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 19/35] pc: Rename pc_machine variable to pcms
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (17 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 18/35] machine: Eliminate QEMUMachine.compat_props Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 20/35] pc: Move pci_enabled parameter to PCMachineClass Eduardo Habkost
` (15 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
"pcms" being the initials of "PCMachineState". The variable will be used
a lot, so it's better to make it short.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 10 +++++-----
hw/i386/pc_q35.c | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 979bb40..0f229e7 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -75,7 +75,7 @@ static bool kvmclock_enabled = true;
static void pc_init1(MachineState *machine,
int pci_enabled)
{
- PCMachineState *pc_machine = PC_MACHINE(machine);
+ PCMachineState *pcms = PC_MACHINE(machine);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
@@ -117,13 +117,13 @@ static void pc_init1(MachineState *machine,
/* Handle the machine opt max-ram-below-4g. It is basicly doing
* min(qemu limit, user limit).
*/
- if (lowmem > pc_machine->max_ram_below_4g) {
- lowmem = pc_machine->max_ram_below_4g;
+ if (lowmem > pcms->max_ram_below_4g) {
+ lowmem = pcms->max_ram_below_4g;
if (machine->ram_size - lowmem > lowmem &&
lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
") not a multiple of 1G; possible bad performance.",
- pc_machine->max_ram_below_4g);
+ pcms->max_ram_below_4g);
}
}
@@ -278,7 +278,7 @@ static void pc_init1(MachineState *machine,
object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
- (Object **)&pc_machine->acpi_dev,
+ (Object **)&pcms->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 74c6d3c..491fee7 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -63,7 +63,7 @@ static bool has_reserved_memory = true;
/* PC hardware initialisation */
static void pc_q35_init(MachineState *machine)
{
- PCMachineState *pc_machine = PC_MACHINE(machine);
+ PCMachineState *pcms = PC_MACHINE(machine);
ram_addr_t below_4g_mem_size, above_4g_mem_size;
Q35PCIHost *q35_host;
PCIHostState *phb;
@@ -106,13 +106,13 @@ static void pc_q35_init(MachineState *machine)
/* Handle the machine opt max-ram-below-4g. It is basicly doing
* min(qemu limit, user limit).
*/
- if (lowmem > pc_machine->max_ram_below_4g) {
- lowmem = pc_machine->max_ram_below_4g;
+ if (lowmem > pcms->max_ram_below_4g) {
+ lowmem = pcms->max_ram_below_4g;
if (machine->ram_size - lowmem > lowmem &&
lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
") not a multiple of 1G; possible bad performance.",
- pc_machine->max_ram_below_4g);
+ pcms->max_ram_below_4g);
}
}
@@ -201,7 +201,7 @@ static void pc_q35_init(MachineState *machine)
object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
- (Object **)&pc_machine->acpi_dev,
+ (Object **)&pcms->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(lpc),
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 20/35] pc: Move pci_enabled parameter to PCMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (18 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 19/35] pc: Rename pc_machine variable to pcms Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 21/35] q35: Use PCMachineClass.pci_enabled field Eduardo Habkost
` (14 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 11 +++++++----
include/hw/i386/pc.h | 1 +
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 7a6aa66..465efee 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1662,6 +1662,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
pcmc->get_hotplug_handler = mc->get_hotplug_handler;
+ pcmc->pci_enabled = true;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 0f229e7..4d5a31c 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -72,10 +72,11 @@ static bool has_reserved_memory = true;
static bool kvmclock_enabled = true;
/* PC hardware initialisation */
-static void pc_init1(MachineState *machine,
- int pci_enabled)
+static void pc_init1(MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
+ bool pci_enabled = pcmc->pci_enabled;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
@@ -292,7 +293,7 @@ static void pc_init1(MachineState *machine,
static void pc_init_pci(MachineState *machine)
{
- pc_init1(machine, 1);
+ pc_init1(machine);
}
static void pc_compat_2_0(MachineState *machine)
@@ -415,7 +416,7 @@ static void pc_init_isa(MachineState *machine)
}
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode();
- pc_init1(machine, 0);
+ pc_init1(machine);
}
#ifdef CONFIG_XEN
@@ -960,9 +961,11 @@ static const TypeInfo pc_machine_v0_10_type_info = {
static void isapc_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
{ /* end of list */ }
};
+ pcmc->pci_enabled = false;
mc->desc = "ISA-only PC";
mc->init = pc_init_isa;
mc->max_cpus = 1;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 318f2cc..8244db5 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -53,6 +53,7 @@ struct PCMachineClass {
/*< public >*/
HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
DeviceState *dev);
+ bool pci_enabled;
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 21/35] q35: Use PCMachineClass.pci_enabled field
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (19 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 20/35] pc: Move pci_enabled parameter to PCMachineClass Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 22/35] pc: Move kvmclock_enabled to PCMachineClass Eduardo Habkost
` (13 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Little step towards making the q35 and piix init functions converge, to
eliminate duplication.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_q35.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 491fee7..d50dd89 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -64,6 +64,8 @@ static bool has_reserved_memory = true;
static void pc_q35_init(MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
+ bool pci_enabled = pcmc->pci_enabled;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
Q35PCIHost *q35_host;
PCIHostState *phb;
@@ -77,7 +79,6 @@ static void pc_q35_init(MachineState *machine)
MemoryRegion *ram_memory;
GSIState *gsi_state;
ISABus *isa_bus;
- int pci_enabled = 1;
qemu_irq *cpu_irq;
qemu_irq *gsi;
qemu_irq *i8259;
@@ -341,8 +342,10 @@ static void pc_q35_init_1_4(MachineState *machine)
static void pc_q35_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
mc->desc = "Standard PC (Q35 + ICH9, 2009)";
mc->hot_add_cpu = pc_hot_add_cpu;
+ pcmc->pci_enabled = true;
}
#define TYPE_PC_Q35_MACHINE "pc-q35" TYPE_MACHINE_SUFFIX
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 22/35] pc: Move kvmclock_enabled to PCMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (20 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 21/35] q35: Use PCMachineClass.pci_enabled field Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 23/35] pc: Move smbios_legacy_mode " Eduardo Habkost
` (12 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 6 +++---
include/hw/i386/pc.h | 1 +
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 465efee..ef4b586 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1663,6 +1663,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->get_hotplug_handler = mc->get_hotplug_handler;
pcmc->pci_enabled = true;
+ pcmc->kvmclock_enabled = true;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 4d5a31c..e26fedd 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -69,7 +69,6 @@ static bool smbios_legacy_mode;
*/
static bool gigabyte_align = true;
static bool has_reserved_memory = true;
-static bool kvmclock_enabled = true;
/* PC hardware initialisation */
static void pc_init1(MachineState *machine)
@@ -148,7 +147,7 @@ static void pc_init1(MachineState *machine)
pc_cpus_init(machine->cpu_model, icc_bridge);
- if (kvm_enabled() && kvmclock_enabled) {
+ if (kvm_enabled() && pcmc->kvmclock_enabled) {
kvmclock_create();
}
@@ -348,7 +347,6 @@ static void pc_compat_1_2(MachineState *machine)
static void pc_compat_0_13(MachineState *machine)
{
pc_compat_1_2(machine);
- kvmclock_enabled = false;
}
static void pc_init_pci_2_0(MachineState *machine)
@@ -822,6 +820,7 @@ static const TypeInfo pc_machine_v0_14_type_info = {
static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_0_13,
{ /* end of list */ }
@@ -831,6 +830,7 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
mc->hw_version = "0.13";
mc->name = "pc-0.13";
machine_class_add_compat_props(mc, compat_props);
+ pcmc->kvmclock_enabled = false;
}
static const TypeInfo pc_machine_v0_13_type_info = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 8244db5..c08ab37 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -54,6 +54,7 @@ struct PCMachineClass {
HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
DeviceState *dev);
bool pci_enabled;
+ bool kvmclock_enabled;
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 23/35] pc: Move smbios_legacy_mode to PCMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (21 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 22/35] pc: Move kvmclock_enabled to PCMachineClass Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 24/35] pc: Move smbios_defaults " Eduardo Habkost
` (11 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 9 +++++----
hw/i386/pc_q35.c | 7 ++++---
include/hw/i386/pc.h | 1 +
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index e26fedd..22388c1 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -62,7 +62,6 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
static bool has_pci_info;
static bool has_acpi_build = true;
static bool smbios_defaults = true;
-static bool smbios_legacy_mode;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host.
@@ -170,9 +169,10 @@ static void pc_init1(MachineState *machine)
if (smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(mc);
/* These values are guest ABI, do not change */
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
- mc->name, smbios_legacy_mode);
+ mc->name, pcmc->smbios_legacy_mode);
}
/* allocate ram and load rom/bios */
@@ -297,7 +297,6 @@ static void pc_init_pci(MachineState *machine)
static void pc_compat_2_0(MachineState *machine)
{
- smbios_legacy_mode = true;
has_reserved_memory = false;
}
@@ -405,7 +404,6 @@ static void pc_init_isa(MachineState *machine)
has_acpi_build = false;
smbios_defaults = false;
gigabyte_align = false;
- smbios_legacy_mode = true;
has_reserved_memory = false;
option_rom_has_mr = true;
rom_file_has_mr = false;
@@ -466,6 +464,7 @@ static const TypeInfo pc_i440fx_machine_v2_1_type_info = {
static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_2_0,
{ /* end of list */ }
@@ -476,6 +475,7 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
mc->init = pc_init_pci_2_0;
mc->name = "pc-i440fx-2.0";
machine_class_add_compat_props(mc, compat_props);
+ pcmc->smbios_legacy_mode = true;
}
static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
@@ -966,6 +966,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
{ /* end of list */ }
};
pcmc->pci_enabled = false;
+ pcmc->smbios_legacy_mode = true;
mc->desc = "ISA-only PC";
mc->init = pc_init_isa;
mc->max_cpus = 1;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index d50dd89..ad4ff5a 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -52,7 +52,6 @@
static bool has_pci_info;
static bool has_acpi_build = true;
static bool smbios_defaults = true;
-static bool smbios_legacy_mode;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host.
@@ -158,9 +157,10 @@ static void pc_q35_init(MachineState *machine)
if (smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
/* These values are guest ABI, do not change */
smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)",
- mc->name, smbios_legacy_mode);
+ mc->name, pcmc->smbios_legacy_mode);
}
/* allocate ram and load rom/bios */
@@ -276,7 +276,6 @@ static void pc_q35_init(MachineState *machine)
static void pc_compat_2_0(MachineState *machine)
{
- smbios_legacy_mode = true;
has_reserved_memory = false;
}
@@ -375,6 +374,7 @@ static TypeInfo pc_q35_machine_v2_1_type_info = {
static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_2_0,
{ /* end of list */ }
@@ -384,6 +384,7 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
mc->init = pc_q35_init_2_0;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-2.0";
+ pcmc->smbios_legacy_mode = true;
}
static TypeInfo pc_q35_machine_v2_0_type_info = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index c08ab37..65ba51e 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -55,6 +55,7 @@ struct PCMachineClass {
DeviceState *dev);
bool pci_enabled;
bool kvmclock_enabled;
+ bool smbios_legacy_mode;
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 24/35] pc: Move smbios_defaults to PCMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (22 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 23/35] pc: Move smbios_legacy_mode " Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 25/35] pc: Move has_acpi_build " Eduardo Habkost
` (10 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 9 ++++-----
hw/i386/pc_q35.c | 7 +++----
include/hw/i386/pc.h | 1 +
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index ef4b586..b2f7931 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1664,6 +1664,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->get_hotplug_handler = mc->get_hotplug_handler;
pcmc->pci_enabled = true;
pcmc->kvmclock_enabled = true;
+ pcmc->smbios_defaults = true;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 22388c1..cc7a249 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -61,7 +61,6 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
static bool has_pci_info;
static bool has_acpi_build = true;
-static bool smbios_defaults = true;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host.
@@ -167,9 +166,8 @@ static void pc_init1(MachineState *machine)
guest_info->isapc_ram_fw = !pci_enabled;
guest_info->has_reserved_memory = has_reserved_memory;
- if (smbios_defaults) {
+ if (pcmc->smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
- PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(mc);
/* These values are guest ABI, do not change */
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
mc->name, pcmc->smbios_legacy_mode);
@@ -303,7 +301,6 @@ static void pc_compat_2_0(MachineState *machine)
static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
- smbios_defaults = false;
gigabyte_align = false;
option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
@@ -402,7 +399,6 @@ static void pc_init_isa(MachineState *machine)
{
has_pci_info = false;
has_acpi_build = false;
- smbios_defaults = false;
gigabyte_align = false;
has_reserved_memory = false;
option_rom_has_mr = true;
@@ -487,6 +483,7 @@ static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_7,
{ /* end of list */ }
@@ -496,6 +493,7 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
mc->init = pc_init_pci_1_7;
mc->name = "pc-i440fx-1.7";
machine_class_add_compat_props(mc, compat_props);
+ pcmc->smbios_defaults = false;
}
static const TypeInfo pc_i440fx_machine_v1_7_type_info = {
@@ -973,6 +971,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
mc->hot_add_cpu = NULL;
mc->name = "isapc";
machine_class_add_compat_props(mc, compat_props);
+ pcmc->smbios_defaults = false;
}
static const TypeInfo isapc_machine_type_info = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index ad4ff5a..5ff83d7 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -51,7 +51,6 @@
static bool has_pci_info;
static bool has_acpi_build = true;
-static bool smbios_defaults = true;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host.
@@ -155,9 +154,8 @@ static void pc_q35_init(MachineState *machine)
guest_info->has_acpi_build = has_acpi_build;
guest_info->has_reserved_memory = has_reserved_memory;
- if (smbios_defaults) {
+ if (pcmc->smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
- PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
/* These values are guest ABI, do not change */
smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)",
mc->name, pcmc->smbios_legacy_mode);
@@ -282,7 +280,6 @@ static void pc_compat_2_0(MachineState *machine)
static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
- smbios_defaults = false;
gigabyte_align = false;
option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
@@ -396,6 +393,7 @@ static TypeInfo pc_q35_machine_v2_0_type_info = {
static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_7,
{ /* end of list */ }
@@ -405,6 +403,7 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
mc->init = pc_q35_init_1_7;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.7";
+ pcmc->smbios_defaults = false;
}
static TypeInfo pc_q35_machine_v1_7_type_info = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 65ba51e..be60e30 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -56,6 +56,7 @@ struct PCMachineClass {
bool pci_enabled;
bool kvmclock_enabled;
bool smbios_legacy_mode;
+ bool smbios_defaults;
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 25/35] pc: Move has_acpi_build to PCMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (23 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 24/35] pc: Move smbios_defaults " Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 26/35] pc: Move has_pci_info " Eduardo Habkost
` (9 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 8 ++++----
hw/i386/pc_q35.c | 6 +++---
include/hw/i386/pc.h | 1 +
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index b2f7931..7f44b3b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1665,6 +1665,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->pci_enabled = true;
pcmc->kvmclock_enabled = true;
pcmc->smbios_defaults = true;
+ pcmc->has_acpi_build = true;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index cc7a249..8501578 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -60,7 +60,6 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
static bool has_pci_info;
-static bool has_acpi_build = true;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host.
@@ -160,7 +159,7 @@ static void pc_init1(MachineState *machine)
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
- guest_info->has_acpi_build = has_acpi_build;
+ guest_info->has_acpi_build = pcmc->has_acpi_build;
guest_info->has_pci_info = has_pci_info;
guest_info->isapc_ram_fw = !pci_enabled;
@@ -311,7 +310,6 @@ static void pc_compat_1_6(MachineState *machine)
pc_compat_1_7(machine);
has_pci_info = false;
rom_file_has_mr = false;
- has_acpi_build = false;
}
static void pc_compat_1_5(MachineState *machine)
@@ -398,7 +396,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)
static void pc_init_isa(MachineState *machine)
{
has_pci_info = false;
- has_acpi_build = false;
gigabyte_align = false;
has_reserved_memory = false;
option_rom_has_mr = true;
@@ -505,6 +502,7 @@ static const TypeInfo pc_i440fx_machine_v1_7_type_info = {
static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_6,
{ /* end of list */ }
@@ -513,6 +511,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
mc->init = pc_init_pci_1_6;
mc->name = "pc-i440fx-1.6";
machine_class_add_compat_props(mc, compat_props);
+ pcmc->has_acpi_build = false;
}
static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
@@ -972,6 +971,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
mc->name = "isapc";
machine_class_add_compat_props(mc, compat_props);
pcmc->smbios_defaults = false;
+ pcmc->has_acpi_build = false;
}
static const TypeInfo isapc_machine_type_info = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 5ff83d7..8f1258f 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -50,7 +50,6 @@
#define MAX_SATA_PORTS 6
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.
@@ -151,7 +150,7 @@ static void pc_q35_init(MachineState *machine)
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
guest_info->has_pci_info = has_pci_info;
guest_info->isapc_ram_fw = false;
- guest_info->has_acpi_build = has_acpi_build;
+ guest_info->has_acpi_build = pcmc->has_acpi_build;
guest_info->has_reserved_memory = has_reserved_memory;
if (pcmc->smbios_defaults) {
@@ -290,7 +289,6 @@ static void pc_compat_1_6(MachineState *machine)
pc_compat_1_7(machine);
has_pci_info = false;
rom_file_has_mr = false;
- has_acpi_build = false;
}
static void pc_compat_1_5(MachineState *machine)
@@ -415,6 +413,7 @@ static TypeInfo pc_q35_machine_v1_7_type_info = {
static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_6,
{ /* end of list */ }
@@ -423,6 +422,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
mc->init = pc_q35_init_1_6;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.6";
+ pcmc->has_acpi_build = false;
}
static TypeInfo pc_q35_machine_v1_6_type_info = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index be60e30..99bb5ce 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -57,6 +57,7 @@ struct PCMachineClass {
bool kvmclock_enabled;
bool smbios_legacy_mode;
bool smbios_defaults;
+ bool has_acpi_build;
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 26/35] pc: Move has_pci_info to PCMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (24 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 25/35] pc: Move has_acpi_build " Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 27/35] pc: Move gigabyte_align " Eduardo Habkost
` (8 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Interestingly, no existing code sets has_pci_info=true at all.
A has_pci_info=false line was added to isapc class_init, just in case we
enable it on the other PC machine-types one day.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 6 ++----
hw/i386/pc_q35.c | 4 +---
include/hw/i386/pc.h | 1 +
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 8501578..ca662b4 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -59,7 +59,6 @@ static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
-static bool has_pci_info;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host.
@@ -161,7 +160,7 @@ static void pc_init1(MachineState *machine)
guest_info->has_acpi_build = pcmc->has_acpi_build;
- guest_info->has_pci_info = has_pci_info;
+ guest_info->has_pci_info = pcmc->has_pci_info;
guest_info->isapc_ram_fw = !pci_enabled;
guest_info->has_reserved_memory = has_reserved_memory;
@@ -308,7 +307,6 @@ static void pc_compat_1_7(MachineState *machine)
static void pc_compat_1_6(MachineState *machine)
{
pc_compat_1_7(machine);
- has_pci_info = false;
rom_file_has_mr = false;
}
@@ -395,7 +393,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)
static void pc_init_isa(MachineState *machine)
{
- has_pci_info = false;
gigabyte_align = false;
has_reserved_memory = false;
option_rom_has_mr = true;
@@ -972,6 +969,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
machine_class_add_compat_props(mc, compat_props);
pcmc->smbios_defaults = false;
pcmc->has_acpi_build = false;
+ pcmc->has_pci_info = false;
}
static const TypeInfo isapc_machine_type_info = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 8f1258f..d8b304f 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -49,7 +49,6 @@
/* ICH9 AHCI has 6 ports */
#define MAX_SATA_PORTS 6
-static bool has_pci_info;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host.
@@ -148,7 +147,7 @@ static void pc_q35_init(MachineState *machine)
}
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
- guest_info->has_pci_info = has_pci_info;
+ guest_info->has_pci_info = pcmc->has_pci_info;
guest_info->isapc_ram_fw = false;
guest_info->has_acpi_build = pcmc->has_acpi_build;
guest_info->has_reserved_memory = has_reserved_memory;
@@ -287,7 +286,6 @@ static void pc_compat_1_7(MachineState *machine)
static void pc_compat_1_6(MachineState *machine)
{
pc_compat_1_7(machine);
- has_pci_info = false;
rom_file_has_mr = false;
}
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 99bb5ce..2b90dcb 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -58,6 +58,7 @@ struct PCMachineClass {
bool smbios_legacy_mode;
bool smbios_defaults;
bool has_acpi_build;
+ bool has_pci_info;
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 27/35] pc: Move gigabyte_align to PCMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (25 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 26/35] pc: Move has_pci_info " Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 28/35] pc: Move has_reserved_memory " Eduardo Habkost
` (7 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 11 +++--------
hw/i386/pc_q35.c | 9 ++-------
include/hw/i386/pc.h | 5 +++++
4 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 7f44b3b..3fe5764 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1666,6 +1666,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->kvmclock_enabled = true;
pcmc->smbios_defaults = true;
pcmc->has_acpi_build = true;
+ pcmc->gigabyte_align = true;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index ca662b4..1d58798 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -59,11 +59,6 @@ static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
-/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
- * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
- * pages in the host.
- */
-static bool gigabyte_align = true;
static bool has_reserved_memory = true;
/* PC hardware initialisation */
@@ -105,7 +100,7 @@ static void pc_init1(MachineState *machine)
* breaking migration.
*/
if (machine->ram_size >= 0xe0000000) {
- lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
+ lowmem = pcmc->gigabyte_align ? 0xc0000000 : 0xe0000000;
} else {
lowmem = 0xe0000000;
}
@@ -299,7 +294,6 @@ static void pc_compat_2_0(MachineState *machine)
static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
- gigabyte_align = false;
option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
@@ -393,7 +387,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)
static void pc_init_isa(MachineState *machine)
{
- gigabyte_align = false;
has_reserved_memory = false;
option_rom_has_mr = true;
rom_file_has_mr = false;
@@ -488,6 +481,7 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
mc->name = "pc-i440fx-1.7";
machine_class_add_compat_props(mc, compat_props);
pcmc->smbios_defaults = false;
+ pcmc->gigabyte_align = false;
}
static const TypeInfo pc_i440fx_machine_v1_7_type_info = {
@@ -970,6 +964,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
pcmc->smbios_defaults = false;
pcmc->has_acpi_build = false;
pcmc->has_pci_info = false;
+ pcmc->gigabyte_align = false;
}
static const TypeInfo isapc_machine_type_info = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index d8b304f..9b67a67 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -49,11 +49,6 @@
/* ICH9 AHCI has 6 ports */
#define MAX_SATA_PORTS 6
-/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
- * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
- * pages in the host.
- */
-static bool gigabyte_align = true;
static bool has_reserved_memory = true;
/* PC hardware initialisation */
@@ -95,7 +90,7 @@ static void pc_q35_init(MachineState *machine)
* breaking migration.
*/
if (machine->ram_size >= 0xb0000000) {
- lowmem = gigabyte_align ? 0x80000000 : 0xb0000000;
+ lowmem = pcmc->gigabyte_align ? 0x80000000 : 0xb0000000;
} else {
lowmem = 0xb0000000;
}
@@ -278,7 +273,6 @@ static void pc_compat_2_0(MachineState *machine)
static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
- gigabyte_align = false;
option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
@@ -400,6 +394,7 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.7";
pcmc->smbios_defaults = false;
+ pcmc->gigabyte_align = false;
}
static TypeInfo pc_q35_machine_v1_7_type_info = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 2b90dcb..c31c1bc 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -59,6 +59,11 @@ struct PCMachineClass {
bool smbios_defaults;
bool has_acpi_build;
bool has_pci_info;
+ /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
+ * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
+ * pages in the host.
+ */
+ bool gigabyte_align;
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 28/35] pc: Move has_reserved_memory to PCMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (26 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 27/35] pc: Move gigabyte_align " Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 29/35] pc: Move option_rom_has_mr/rom_file_has_mr to MachineClass Eduardo Habkost
` (6 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 8 +++-----
hw/i386/pc_q35.c | 6 ++----
include/hw/i386/pc.h | 1 +
4 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 3fe5764..571d47b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1667,6 +1667,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->smbios_defaults = true;
pcmc->has_acpi_build = true;
pcmc->gigabyte_align = true;
+ pcmc->has_reserved_memory = true;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1d58798..a9fb9dd 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -59,8 +59,6 @@ static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
-static bool has_reserved_memory = true;
-
/* PC hardware initialisation */
static void pc_init1(MachineState *machine)
{
@@ -157,7 +155,7 @@ static void pc_init1(MachineState *machine)
guest_info->has_pci_info = pcmc->has_pci_info;
guest_info->isapc_ram_fw = !pci_enabled;
- guest_info->has_reserved_memory = has_reserved_memory;
+ guest_info->has_reserved_memory = pcmc->has_reserved_memory;
if (pcmc->smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
@@ -288,7 +286,6 @@ static void pc_init_pci(MachineState *machine)
static void pc_compat_2_0(MachineState *machine)
{
- has_reserved_memory = false;
}
static void pc_compat_1_7(MachineState *machine)
@@ -387,7 +384,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)
static void pc_init_isa(MachineState *machine)
{
- has_reserved_memory = false;
option_rom_has_mr = true;
rom_file_has_mr = false;
if (!machine->cpu_model) {
@@ -459,6 +455,7 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
mc->name = "pc-i440fx-2.0";
machine_class_add_compat_props(mc, compat_props);
pcmc->smbios_legacy_mode = true;
+ pcmc->has_reserved_memory = false;
}
static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
@@ -965,6 +962,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
pcmc->has_acpi_build = false;
pcmc->has_pci_info = false;
pcmc->gigabyte_align = false;
+ pcmc->has_reserved_memory = false;
}
static const TypeInfo isapc_machine_type_info = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 9b67a67..3f5b0c3 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -49,8 +49,6 @@
/* ICH9 AHCI has 6 ports */
#define MAX_SATA_PORTS 6
-static bool has_reserved_memory = true;
-
/* PC hardware initialisation */
static void pc_q35_init(MachineState *machine)
{
@@ -145,7 +143,7 @@ static void pc_q35_init(MachineState *machine)
guest_info->has_pci_info = pcmc->has_pci_info;
guest_info->isapc_ram_fw = false;
guest_info->has_acpi_build = pcmc->has_acpi_build;
- guest_info->has_reserved_memory = has_reserved_memory;
+ guest_info->has_reserved_memory = pcmc->has_reserved_memory;
if (pcmc->smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
@@ -267,7 +265,6 @@ static void pc_q35_init(MachineState *machine)
static void pc_compat_2_0(MachineState *machine)
{
- has_reserved_memory = false;
}
static void pc_compat_1_7(MachineState *machine)
@@ -372,6 +369,7 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-2.0";
pcmc->smbios_legacy_mode = true;
+ pcmc->has_reserved_memory = false;
}
static TypeInfo pc_q35_machine_v2_0_type_info = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index c31c1bc..fd7ce10 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -64,6 +64,7 @@ struct PCMachineClass {
* pages in the host.
*/
bool gigabyte_align;
+ bool has_reserved_memory;
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 29/35] pc: Move option_rom_has_mr/rom_file_has_mr to MachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (27 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 28/35] pc: Move has_reserved_memory " Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 30/35] piix: Eliminate pc_init_pci() Eduardo Habkost
` (5 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
This 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/core/loader.c | 12 +++++++-----
hw/core/machine.c | 1 +
hw/i386/pc_piix.c | 8 ++++----
hw/i386/pc_q35.c | 4 ++--
include/hw/boards.h | 2 ++
5 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 2bf6b8f..d1d1e72 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -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;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index a4d928e..e3a6425 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -302,6 +302,7 @@ static void machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
QTAILQ_INIT(&mc->compat_props);
+ mc->rom_file_has_mr = true;
}
static const TypeInfo machine_info = {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a9fb9dd..18ac698 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -291,14 +291,12 @@ static void pc_compat_2_0(MachineState *machine)
static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
- option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
static void pc_compat_1_6(MachineState *machine)
{
pc_compat_1_7(machine);
- rom_file_has_mr = false;
}
static void pc_compat_1_5(MachineState *machine)
@@ -384,8 +382,6 @@ static void pc_init_pci_no_kvmclock(MachineState *machine)
static void pc_init_isa(MachineState *machine)
{
- option_rom_has_mr = true;
- rom_file_has_mr = false;
if (!machine->cpu_model) {
machine->cpu_model = "486";
}
@@ -476,6 +472,7 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
mc->default_machine_opts = NULL;
mc->init = pc_init_pci_1_7;
mc->name = "pc-i440fx-1.7";
+ mc->option_rom_has_mr = true;
machine_class_add_compat_props(mc, compat_props);
pcmc->smbios_defaults = false;
pcmc->gigabyte_align = false;
@@ -498,6 +495,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
pc_i440fx_machine_v1_7_class_init(oc, data);
mc->init = pc_init_pci_1_6;
mc->name = "pc-i440fx-1.6";
+ mc->rom_file_has_mr = false;
machine_class_add_compat_props(mc, compat_props);
pcmc->has_acpi_build = false;
}
@@ -957,6 +955,8 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
mc->max_cpus = 1;
mc->hot_add_cpu = NULL;
mc->name = "isapc";
+ mc->option_rom_has_mr = true;
+ mc->rom_file_has_mr = false;
machine_class_add_compat_props(mc, compat_props);
pcmc->smbios_defaults = false;
pcmc->has_acpi_build = false;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 3f5b0c3..33ea5dd 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -270,14 +270,12 @@ static void pc_compat_2_0(MachineState *machine)
static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
- option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
static void pc_compat_1_6(MachineState *machine)
{
pc_compat_1_7(machine);
- rom_file_has_mr = false;
}
static void pc_compat_1_5(MachineState *machine)
@@ -389,6 +387,7 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
pc_q35_machine_v2_0_class_init(oc, data);
mc->default_machine_opts = NULL;
mc->init = pc_q35_init_1_7;
+ mc->option_rom_has_mr = true;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.7";
pcmc->smbios_defaults = false;
@@ -411,6 +410,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
};
pc_q35_machine_v1_7_class_init(oc, data);
mc->init = pc_q35_init_1_6;
+ mc->rom_file_has_mr = false;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.6";
pcmc->has_acpi_build = false;
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 69b76a1..36eaba5 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -99,6 +99,8 @@ struct MachineClass {
const char *default_boot_order;
GlobalPropertyList compat_props;
const char *hw_version;
+ bool option_rom_has_mr;
+ bool rom_file_has_mr;
HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
DeviceState *dev);
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 30/35] piix: Eliminate pc_init_pci()
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (28 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 29/35] pc: Move option_rom_has_mr/rom_file_has_mr to MachineClass Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 31/35] piix: Introduce struct PCI440FXMachineClass Eduardo Habkost
` (4 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Now pc_init1() can be called directly.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 18ac698..5fca2c5 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -279,11 +279,6 @@ static void pc_init1(MachineState *machine)
}
}
-static void pc_init_pci(MachineState *machine)
-{
- pc_init1(machine);
-}
-
static void pc_compat_2_0(MachineState *machine)
{
}
@@ -333,51 +328,51 @@ static void pc_compat_0_13(MachineState *machine)
static void pc_init_pci_2_0(MachineState *machine)
{
pc_compat_2_0(machine);
- pc_init_pci(machine);
+ pc_init1(machine);
}
static void pc_init_pci_1_7(MachineState *machine)
{
pc_compat_1_7(machine);
- pc_init_pci(machine);
+ pc_init1(machine);
}
static void pc_init_pci_1_6(MachineState *machine)
{
pc_compat_1_6(machine);
- pc_init_pci(machine);
+ pc_init1(machine);
}
static void pc_init_pci_1_5(MachineState *machine)
{
pc_compat_1_5(machine);
- pc_init_pci(machine);
+ pc_init1(machine);
}
static void pc_init_pci_1_4(MachineState *machine)
{
pc_compat_1_4(machine);
- pc_init_pci(machine);
+ pc_init1(machine);
}
static void pc_init_pci_1_3(MachineState *machine)
{
pc_compat_1_3(machine);
- pc_init_pci(machine);
+ pc_init1(machine);
}
/* PC machine init function for pc-0.14 to pc-1.2 */
static void pc_init_pci_1_2(MachineState *machine)
{
pc_compat_1_2(machine);
- pc_init_pci(machine);
+ pc_init1(machine);
}
/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */
static void pc_init_pci_no_kvmclock(MachineState *machine)
{
pc_compat_0_13(machine);
- pc_init_pci(machine);
+ pc_init1(machine);
}
static void pc_init_isa(MachineState *machine)
@@ -395,7 +390,7 @@ static void pc_xen_hvm_init(MachineState *machine)
{
PCIBus *bus;
- pc_init_pci(machine);
+ pc_init1(machine);
bus = pci_find_primary_bus();
if (bus != NULL) {
@@ -425,7 +420,7 @@ static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)
MachineClass *mc = MACHINE_CLASS(oc);
mc->default_machine_opts = "firmware=bios-256k.bin";
mc->alias = "pc";
- mc->init = pc_init_pci;
+ mc->init = pc_init1;
mc->is_default = 1;
mc->name = "pc-i440fx-2.1";
}
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 31/35] piix: Introduce struct PCI440FXMachineClass
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (29 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 30/35] piix: Eliminate pc_init_pci() Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 32/35] pc: Create common machine init function Eduardo Habkost
` (3 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 5fca2c5..01730ea 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -399,6 +399,20 @@ static void pc_xen_hvm_init(MachineState *machine)
}
#endif
+/**
+ * PCI440FXMachineClass;
+ */
+typedef struct PCI440FXMachineClass {
+ /*< private >*/
+ PCMachineClass parent_class;
+} PCI440FXMachineClass;
+
+#define TYPE_PC_I440FX_MACHINE "pc-i440fx" TYPE_MACHINE_SUFFIX
+#define PC_I440FX_MACHINE_CLASS(klass) \
+ OBJECT_CLASS_CHECK(PCI440FXMachineClass, (klass), TYPE_PC_I440FX_MACHINE)
+#define PC_I440FX_MACHINE_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(PCI440FXMachineClass, (obj), TYPE_PC_I440FX_MACHINE)
+
static void pc_i440fx_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -406,12 +420,11 @@ static void pc_i440fx_machine_class_init(ObjectClass *oc, void *data)
mc->hot_add_cpu = pc_hot_add_cpu;
}
-#define TYPE_PC_I440FX_MACHINE "pc-i440fx" TYPE_MACHINE_SUFFIX
-
static TypeInfo pc_i440fx_machine_type_info = {
.name = TYPE_PC_I440FX_MACHINE,
.parent = TYPE_PC_MACHINE,
.class_init = pc_i440fx_machine_class_init,
+ .class_size = sizeof(PCI440FXMachineClass),
.abstract = true,
};
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 32/35] pc: Create common machine init function
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (30 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 31/35] piix: Introduce struct PCI440FXMachineClass Eduardo Habkost
@ 2014-07-05 0:09 ` Eduardo Habkost
2014-07-05 0:10 ` [Qemu-devel] [RFC v3 33/35] pc: Eliminate empty or trivial compat functions Eduardo Habkost
` (2 subsequent siblings)
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:09 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
This 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 12 ++++++++
hw/i386/pc_piix.c | 83 +++++++++++++---------------------------------------
hw/i386/pc_q35.c | 45 ++++++----------------------
include/hw/i386/pc.h | 4 +++
4 files changed, 45 insertions(+), 99 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 571d47b..b028669 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1655,6 +1655,17 @@ static void pc_machine_initfn(Object *obj)
NULL, NULL, NULL);
}
+static void pc_machine_init(MachineState *machine)
+{
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
+ if (pcmc->compat_func) {
+ pcmc->compat_func(machine);
+ }
+ if (pcmc->finish_init) {
+ pcmc->finish_init(machine);
+ }
+}
+
static void pc_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -1668,6 +1679,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->has_acpi_build = true;
pcmc->gigabyte_align = true;
pcmc->has_reserved_memory = true;
+ mc->init = pc_machine_init;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 01730ea..24bc59b 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -325,64 +325,13 @@ static void pc_compat_0_13(MachineState *machine)
pc_compat_1_2(machine);
}
-static void pc_init_pci_2_0(MachineState *machine)
-{
- pc_compat_2_0(machine);
- pc_init1(machine);
-}
-
-static void pc_init_pci_1_7(MachineState *machine)
-{
- pc_compat_1_7(machine);
- pc_init1(machine);
-}
-
-static void pc_init_pci_1_6(MachineState *machine)
-{
- pc_compat_1_6(machine);
- pc_init1(machine);
-}
-
-static void pc_init_pci_1_5(MachineState *machine)
-{
- pc_compat_1_5(machine);
- pc_init1(machine);
-}
-
-static void pc_init_pci_1_4(MachineState *machine)
-{
- pc_compat_1_4(machine);
- pc_init1(machine);
-}
-
-static void pc_init_pci_1_3(MachineState *machine)
-{
- pc_compat_1_3(machine);
- pc_init1(machine);
-}
-
-/* PC machine init function for pc-0.14 to pc-1.2 */
-static void pc_init_pci_1_2(MachineState *machine)
-{
- pc_compat_1_2(machine);
- pc_init1(machine);
-}
-
-/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */
-static void pc_init_pci_no_kvmclock(MachineState *machine)
-{
- pc_compat_0_13(machine);
- pc_init1(machine);
-}
-
-static void pc_init_isa(MachineState *machine)
+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();
- pc_init1(machine);
}
#ifdef CONFIG_XEN
@@ -416,8 +365,10 @@ typedef struct PCI440FXMachineClass {
static void pc_i440fx_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
mc->desc = "Standard PC (i440FX + PIIX, 1996)";
mc->hot_add_cpu = pc_hot_add_cpu;
+ pcmc->finish_init = pc_init1;
}
static TypeInfo pc_i440fx_machine_type_info = {
@@ -433,7 +384,6 @@ static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)
MachineClass *mc = MACHINE_CLASS(oc);
mc->default_machine_opts = "firmware=bios-256k.bin";
mc->alias = "pc";
- mc->init = pc_init1;
mc->is_default = 1;
mc->name = "pc-i440fx-2.1";
}
@@ -455,11 +405,11 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
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);
pcmc->smbios_legacy_mode = true;
pcmc->has_reserved_memory = false;
+ pcmc->compat_func = pc_compat_2_0;
}
static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
@@ -478,12 +428,12 @@ static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
};
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";
mc->option_rom_has_mr = true;
machine_class_add_compat_props(mc, compat_props);
pcmc->smbios_defaults = false;
pcmc->gigabyte_align = false;
+ pcmc->compat_func = pc_compat_1_7;
}
static const TypeInfo pc_i440fx_machine_v1_7_type_info = {
@@ -501,11 +451,11 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
{ /* end of list */ }
};
pc_i440fx_machine_v1_7_class_init(oc, data);
- mc->init = pc_init_pci_1_6;
mc->name = "pc-i440fx-1.6";
mc->rom_file_has_mr = false;
machine_class_add_compat_props(mc, compat_props);
pcmc->has_acpi_build = false;
+ pcmc->compat_func = pc_compat_1_6;
}
static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
@@ -517,14 +467,15 @@ static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_5,
{ /* end of list */ }
};
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);
+ pcmc->compat_func = pc_compat_1_5;
}
static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
@@ -536,15 +487,16 @@ static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_4,
{ /* end of list */ }
};
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);
+ pcmc->compat_func = pc_compat_1_4;
}
static const TypeInfo pc_i440fx_machine_v1_4_type_info = {
@@ -575,14 +527,15 @@ static const TypeInfo pc_i440fx_machine_v1_4_type_info = {
static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_3,
{ /* end of list */ }
};
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);
+ pcmc->compat_func = pc_compat_1_3;
}
static const TypeInfo pc_machine_v1_3_type_info = {
@@ -621,14 +574,15 @@ static const TypeInfo pc_machine_v1_3_type_info = {
static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_2,
{ /* end of list */ }
};
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);
+ pcmc->compat_func = pc_compat_1_2;
}
static const TypeInfo pc_machine_v1_2_type_info = {
@@ -817,10 +771,11 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
{ /* end of list */ }
};
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);
+ pcmc->compat_func = pc_compat_0_13;
pcmc->kvmclock_enabled = false;
}
@@ -959,13 +914,14 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data)
pcmc->pci_enabled = false;
pcmc->smbios_legacy_mode = true;
mc->desc = "ISA-only PC";
- mc->init = pc_init_isa;
mc->max_cpus = 1;
mc->hot_add_cpu = NULL;
mc->name = "isapc";
mc->option_rom_has_mr = true;
mc->rom_file_has_mr = false;
machine_class_add_compat_props(mc, compat_props);
+ pcmc->compat_func = pc_compat_isa;
+ pcmc->finish_init = pc_init1;
pcmc->smbios_defaults = false;
pcmc->has_acpi_build = false;
pcmc->has_pci_info = false;
@@ -983,6 +939,7 @@ static const TypeInfo isapc_machine_type_info = {
static void xenfv_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
/* xenfv has no fwcfg and so does not load acpi from QEMU.
* as such new acpi features don't work.
@@ -995,12 +952,12 @@ static void xenfv_machine_class_init(ObjectClass *oc, void *data)
{ /* end of list */ }
};
mc->desc = "Xen Fully-virtualized PC";
- mc->init = pc_xen_hvm_init;
mc->max_cpus = HVM_MAX_VCPUS;
mc->default_machine_opts = "accel=xen";
mc->hot_add_cpu = pc_hot_add_cpu;
mc->name = "xenfv";
machine_class_add_compat_props(mc, compat_props);
+ pcmc->finish_init = pc_xen_hvm_init;
}
static const TypeInfo xenfv_machine_type_info = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 33ea5dd..5ed9a16 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -290,36 +290,6 @@ static void pc_compat_1_4(MachineState *machine)
x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
}
-static void pc_q35_init_2_0(MachineState *machine)
-{
- pc_compat_2_0(machine);
- pc_q35_init(machine);
-}
-
-static void pc_q35_init_1_7(MachineState *machine)
-{
- pc_compat_1_7(machine);
- pc_q35_init(machine);
-}
-
-static void pc_q35_init_1_6(MachineState *machine)
-{
- pc_compat_1_6(machine);
- pc_q35_init(machine);
-}
-
-static void pc_q35_init_1_5(MachineState *machine)
-{
- pc_compat_1_5(machine);
- pc_q35_init(machine);
-}
-
-static void pc_q35_init_1_4(MachineState *machine)
-{
- pc_compat_1_4(machine);
- pc_q35_init(machine);
-}
-
static void pc_q35_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -341,10 +311,11 @@ static TypeInfo pc_q35_machine_type_info = {
static void pc_q35_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 = "q35";
- mc->init = pc_q35_init;
mc->name = "pc-q35-2.1";
+ pcmc->finish_init = pc_q35_init;
}
static TypeInfo pc_q35_machine_v2_1_type_info = {
@@ -363,11 +334,11 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
};
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";
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 = {
@@ -386,10 +357,10 @@ 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->compat_func = pc_compat_1_7;
pcmc->smbios_defaults = false;
pcmc->gigabyte_align = false;
}
@@ -409,10 +380,10 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
{ /* end of list */ }
};
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->compat_func = pc_compat_1_6;
pcmc->has_acpi_build = false;
}
@@ -425,14 +396,15 @@ static TypeInfo pc_q35_machine_v1_6_type_info = {
static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_5,
{ /* end of list */ }
};
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";
+ pcmc->compat_func = pc_compat_1_5;
}
static TypeInfo pc_q35_machine_v1_5_type_info = {
@@ -444,15 +416,16 @@ static TypeInfo pc_q35_machine_v1_5_type_info = {
static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_4,
{ /* end of list */ }
};
pc_q35_machine_v1_5_class_init(oc, data);
mc->hot_add_cpu = NULL;
- mc->init = pc_q35_init_1_4;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.4";
+ pcmc->compat_func = pc_compat_1_4;
}
static TypeInfo pc_q35_machine_v1_4_type_info = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index fd7ce10..38d571b 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -45,6 +45,8 @@ struct PCMachineState {
/**
* PCMachineClass:
* @get_hotplug_handler: pointer to parent class callback @get_hotplug_handler
+ * @finish_init: Subclass-specific function to finish initialization.
+ * @compat_func: Compatiblity function to be called before initialization.
*/
struct PCMachineClass {
/*< private >*/
@@ -65,6 +67,8 @@ struct PCMachineClass {
*/
bool gigabyte_align;
bool has_reserved_memory;
+ void (*finish_init)(MachineState *machine);
+ void (*compat_func)(MachineState *machine);
};
typedef struct PCMachineState PCMachineState;
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 33/35] pc: Eliminate empty or trivial compat functions
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (31 preceding siblings ...)
2014-07-05 0:09 ` [Qemu-devel] [RFC v3 32/35] pc: Create common machine init function Eduardo Habkost
@ 2014-07-05 0:10 ` Eduardo Habkost
2014-07-05 0:10 ` [Qemu-devel] [RFC v3 34/35] piix: Move compat/init functions closer to corresponding class_init Eduardo Habkost
2014-07-05 0:10 ` [Qemu-devel] [RFC v3 35/35] pc: Move {ram, pci, rom}_memory variables to PCMachineState Eduardo Habkost
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:10 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
When 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 29 +----------------------------
hw/i386/pc_q35.c | 21 +--------------------
2 files changed, 2 insertions(+), 48 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 24bc59b..94e9dfe 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -279,29 +279,14 @@ static void pc_init1(MachineState *machine)
}
}
-static void pc_compat_2_0(MachineState *machine)
-{
-}
-
static void pc_compat_1_7(MachineState *machine)
{
- pc_compat_2_0(machine);
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
-static void pc_compat_1_6(MachineState *machine)
-{
- pc_compat_1_7(machine);
-}
-
-static void pc_compat_1_5(MachineState *machine)
-{
- pc_compat_1_6(machine);
-}
-
static void pc_compat_1_4(MachineState *machine)
{
- pc_compat_1_5(machine);
+ pc_compat_1_7(machine);
x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
}
@@ -312,19 +297,12 @@ static void pc_compat_1_3(MachineState *machine)
enable_compat_apic_id_mode();
}
-/* PC compat function for pc-0.14 to pc-1.2 */
static void pc_compat_1_2(MachineState *machine)
{
pc_compat_1_3(machine);
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
}
-/* PC compat function for pc-0.10 to pc-0.13 */
-static void pc_compat_0_13(MachineState *machine)
-{
- pc_compat_1_2(machine);
-}
-
static void pc_compat_isa(MachineState *machine)
{
if (!machine->cpu_model) {
@@ -409,7 +387,6 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
machine_class_add_compat_props(mc, compat_props);
pcmc->smbios_legacy_mode = true;
pcmc->has_reserved_memory = false;
- pcmc->compat_func = pc_compat_2_0;
}
static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
@@ -455,7 +432,6 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
mc->rom_file_has_mr = false;
machine_class_add_compat_props(mc, compat_props);
pcmc->has_acpi_build = false;
- pcmc->compat_func = pc_compat_1_6;
}
static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
@@ -467,7 +443,6 @@ static const TypeInfo pc_i440fx_machine_v1_6_type_info = {
static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
- PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_5,
{ /* end of list */ }
@@ -475,7 +450,6 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
pc_i440fx_machine_v1_6_class_init(oc, data);
mc->name = "pc-i440fx-1.5";
machine_class_add_compat_props(mc, compat_props);
- pcmc->compat_func = pc_compat_1_5;
}
static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
@@ -775,7 +749,6 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
mc->hw_version = "0.13";
mc->name = "pc-0.13";
machine_class_add_compat_props(mc, compat_props);
- pcmc->compat_func = pc_compat_0_13;
pcmc->kvmclock_enabled = false;
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 5ed9a16..d978567 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -263,29 +263,14 @@ static void pc_q35_init(MachineState *machine)
}
}
-static void pc_compat_2_0(MachineState *machine)
-{
-}
-
static void pc_compat_1_7(MachineState *machine)
{
- pc_compat_2_0(machine);
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
-static void pc_compat_1_6(MachineState *machine)
-{
- pc_compat_1_7(machine);
-}
-
-static void pc_compat_1_5(MachineState *machine)
-{
- pc_compat_1_6(machine);
-}
-
static void pc_compat_1_4(MachineState *machine)
{
- pc_compat_1_5(machine);
+ pc_compat_1_7(machine);
x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
}
@@ -338,7 +323,6 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
mc->name = "pc-q35-2.0";
pcmc->smbios_legacy_mode = true;
pcmc->has_reserved_memory = false;
- pcmc->compat_func = pc_compat_2_0;
}
static TypeInfo pc_q35_machine_v2_0_type_info = {
@@ -383,7 +367,6 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
mc->rom_file_has_mr = false;
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.6";
- pcmc->compat_func = pc_compat_1_6;
pcmc->has_acpi_build = false;
}
@@ -396,7 +379,6 @@ static TypeInfo pc_q35_machine_v1_6_type_info = {
static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
- PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_5,
{ /* end of list */ }
@@ -404,7 +386,6 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
pc_q35_machine_v1_6_class_init(oc, data);
machine_class_add_compat_props(mc, compat_props);
mc->name = "pc-q35-1.5";
- pcmc->compat_func = pc_compat_1_5;
}
static TypeInfo pc_q35_machine_v1_5_type_info = {
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 34/35] piix: Move compat/init functions closer to corresponding class_init
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (32 preceding siblings ...)
2014-07-05 0:10 ` [Qemu-devel] [RFC v3 33/35] pc: Eliminate empty or trivial compat functions Eduardo Habkost
@ 2014-07-05 0:10 ` Eduardo Habkost
2014-07-05 0:10 ` [Qemu-devel] [RFC v3 35/35] pc: Move {ram, pci, rom}_memory variables to PCMachineState Eduardo Habkost
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:10 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 92 +++++++++++++++++++++++++++----------------------------
1 file changed, 45 insertions(+), 47 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 94e9dfe..3716f98 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -279,53 +279,6 @@ static void pc_init1(MachineState *machine)
}
}
-static void pc_compat_1_7(MachineState *machine)
-{
- x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
-}
-
-static void pc_compat_1_4(MachineState *machine)
-{
- pc_compat_1_7(machine);
- x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
- x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
-}
-
-static void pc_compat_1_3(MachineState *machine)
-{
- pc_compat_1_4(machine);
- enable_compat_apic_id_mode();
-}
-
-static void pc_compat_1_2(MachineState *machine)
-{
- pc_compat_1_3(machine);
- x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
-}
-
-static void pc_compat_isa(MachineState *machine)
-{
- if (!machine->cpu_model) {
- machine->cpu_model = "486";
- }
- x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
- enable_compat_apic_id_mode();
-}
-
-#ifdef CONFIG_XEN
-static void pc_xen_hvm_init(MachineState *machine)
-{
- PCIBus *bus;
-
- pc_init1(machine);
-
- bus = pci_find_primary_bus();
- if (bus != NULL) {
- pci_create_simple(bus, -1, "xen-platform");
- }
-}
-#endif
-
/**
* PCI440FXMachineClass;
*/
@@ -395,6 +348,11 @@ static const TypeInfo pc_i440fx_machine_v2_0_type_info = {
.class_init = pc_i440fx_machine_v2_0_class_init,
};
+static void pc_compat_1_7(MachineState *machine)
+{
+ x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
+}
+
static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -458,6 +416,13 @@ static const TypeInfo pc_i440fx_machine_v1_5_type_info = {
.class_init = pc_i440fx_machine_v1_5_class_init,
};
+static void pc_compat_1_4(MachineState *machine)
+{
+ pc_compat_1_7(machine);
+ x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
+ x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
+}
+
static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -498,6 +463,12 @@ static const TypeInfo pc_i440fx_machine_v1_4_type_info = {
.value = "off",\
}
+static void pc_compat_1_3(MachineState *machine)
+{
+ pc_compat_1_4(machine);
+ enable_compat_apic_id_mode();
+}
+
static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -545,6 +516,12 @@ static const TypeInfo pc_machine_v1_3_type_info = {
.value = "off",\
}
+static void pc_compat_1_2(MachineState *machine)
+{
+ pc_compat_1_3(machine);
+ x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
+}
+
static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -877,6 +854,15 @@ static const TypeInfo pc_machine_v0_10_type_info = {
.class_init = pc_machine_v0_10_class_init,
};
+static void pc_compat_isa(MachineState *machine)
+{
+ if (!machine->cpu_model) {
+ machine->cpu_model = "486";
+ }
+ x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
+ enable_compat_apic_id_mode();
+}
+
static void isapc_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -909,6 +895,18 @@ static const TypeInfo isapc_machine_type_info = {
};
#ifdef CONFIG_XEN
+static void pc_xen_hvm_init(MachineState *machine)
+{
+ PCIBus *bus;
+
+ pc_init1(machine);
+
+ bus = pci_find_primary_bus();
+ if (bus != NULL) {
+ pci_create_simple(bus, -1, "xen-platform");
+ }
+}
+
static void xenfv_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [Qemu-devel] [RFC v3 35/35] pc: Move {ram, pci, rom}_memory variables to PCMachineState
2014-07-05 0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
` (33 preceding siblings ...)
2014-07-05 0:10 ` [Qemu-devel] [RFC v3 34/35] piix: Move compat/init functions closer to corresponding class_init Eduardo Habkost
@ 2014-07-05 0:10 ` Eduardo Habkost
34 siblings, 0 replies; 36+ messages in thread
From: Eduardo Habkost @ 2014-07-05 0:10 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Alexander Graf, Don Slutz,
Igor Mammedov, Andreas Färber
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v2:
* Use PCMachineState fields inside pc_memory_init() too
---
hw/i386/pc.c | 8 +++-----
hw/i386/pc_piix.c | 19 ++++++++-----------
hw/i386/pc_q35.c | 22 +++++++++-------------
include/hw/i386/pc.h | 5 +++--
4 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index b028669..a89756e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1194,8 +1194,6 @@ FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
- MemoryRegion *rom_memory,
- MemoryRegion **ram_memory,
PcGuestInfo *guest_info)
{
int linux_boot, i;
@@ -1215,7 +1213,7 @@ FWCfgState *pc_memory_init(MachineState *machine,
ram = g_malloc(sizeof(*ram));
memory_region_allocate_system_memory(ram, NULL, "pc.ram",
machine->ram_size);
- *ram_memory = ram;
+ pcms->ram_memory = ram;
ram_below_4g = g_malloc(sizeof(*ram_below_4g));
memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram,
0, below_4g_mem_size);
@@ -1269,12 +1267,12 @@ FWCfgState *pc_memory_init(MachineState *machine,
}
/* Initialize PC system firmware */
- pc_system_firmware_init(rom_memory, guest_info->isapc_ram_fw);
+ pc_system_firmware_init(pcms->rom_memory, guest_info->isapc_ram_fw);
option_rom_mr = g_malloc(sizeof(*option_rom_mr));
memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE);
vmstate_register_ram_global(option_rom_mr);
- memory_region_add_subregion_overlap(rom_memory,
+ memory_region_add_subregion_overlap(pcms->rom_memory,
PC_ROM_MIN_VGA,
option_rom_mr,
1);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 3716f98..255bcbb 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -82,9 +82,6 @@ static void pc_init1(MachineState *machine)
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
ISADevice *floppy;
- MemoryRegion *ram_memory;
- MemoryRegion *pci_memory;
- MemoryRegion *rom_memory;
DeviceState *icc_bridge;
FWCfgState *fw_cfg = NULL;
PcGuestInfo *guest_info;
@@ -125,7 +122,7 @@ static void pc_init1(MachineState *machine)
}
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
- &ram_memory) != 0) {
+ &pcms->ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
@@ -141,12 +138,12 @@ static void pc_init1(MachineState *machine)
}
if (pci_enabled) {
- pci_memory = g_new(MemoryRegion, 1);
- memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
- rom_memory = pci_memory;
+ pcms->pci_memory = g_new(MemoryRegion, 1);
+ memory_region_init(pcms->pci_memory, NULL, "pci", UINT64_MAX);
+ pcms->rom_memory = pcms->pci_memory;
} else {
- pci_memory = NULL;
- rom_memory = system_memory;
+ pcms->pci_memory = NULL;
+ pcms->rom_memory = system_memory;
}
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
@@ -168,7 +165,7 @@ static void pc_init1(MachineState *machine)
if (!xen_enabled()) {
fw_cfg = pc_memory_init(machine, system_memory,
below_4g_mem_size, above_4g_mem_size,
- rom_memory, &ram_memory, guest_info);
+ guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
@@ -185,7 +182,7 @@ static void pc_init1(MachineState *machine)
system_memory, system_io, machine->ram_size,
below_4g_mem_size,
above_4g_mem_size,
- pci_memory, ram_memory);
+ pcms->pci_memory, pcms->ram_memory);
} else {
pci_bus = NULL;
i440fx_state = NULL;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index d978567..f8ea2b5 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -63,9 +63,6 @@ static void pc_q35_init(MachineState *machine)
BusState *idebus[MAX_SATA_PORTS];
ISADevice *rtc_state;
ISADevice *floppy;
- MemoryRegion *pci_memory;
- MemoryRegion *rom_memory;
- MemoryRegion *ram_memory;
GSIState *gsi_state;
ISABus *isa_bus;
qemu_irq *cpu_irq;
@@ -115,7 +112,7 @@ static void pc_q35_init(MachineState *machine)
}
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
- &ram_memory) != 0) {
+ &pcms->ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
@@ -131,12 +128,12 @@ static void pc_q35_init(MachineState *machine)
/* pci enabled */
if (pci_enabled) {
- pci_memory = g_new(MemoryRegion, 1);
- memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
- rom_memory = pci_memory;
+ pcms->pci_memory = g_new(MemoryRegion, 1);
+ memory_region_init(pcms->pci_memory, NULL, "pci", UINT64_MAX);
+ pcms->rom_memory = pcms->pci_memory;
} else {
- pci_memory = NULL;
- rom_memory = get_system_memory();
+ pcms->pci_memory = NULL;
+ pcms->rom_memory = get_system_memory();
}
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
@@ -155,8 +152,7 @@ static void pc_q35_init(MachineState *machine)
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
pc_memory_init(machine, get_system_memory(),
- below_4g_mem_size, above_4g_mem_size,
- rom_memory, &ram_memory, guest_info);
+ below_4g_mem_size, above_4g_mem_size, guest_info);
}
/* irq lines */
@@ -173,8 +169,8 @@ static void pc_q35_init(MachineState *machine)
q35_host = Q35_HOST_DEVICE(qdev_create(NULL, TYPE_Q35_HOST_DEVICE));
object_property_add_child(qdev_get_machine(), "q35", OBJECT(q35_host), NULL);
- q35_host->mch.ram_memory = ram_memory;
- q35_host->mch.pci_address_space = pci_memory;
+ q35_host->mch.ram_memory = pcms->ram_memory;
+ q35_host->mch.pci_address_space = pcms->pci_memory;
q35_host->mch.system_memory = get_system_memory();
q35_host->mch.address_space_io = get_system_io();
q35_host->mch.below_4g_mem_size = below_4g_mem_size;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 38d571b..3b0f886 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -32,6 +32,9 @@ struct PCMachineState {
/* <public> */
ram_addr_t hotplug_memory_base;
MemoryRegion hotplug_memory;
+ MemoryRegion *ram_memory;
+ MemoryRegion *pci_memory;
+ MemoryRegion *rom_memory;
HotplugHandler *acpi_dev;
@@ -208,8 +211,6 @@ FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
- MemoryRegion *rom_memory,
- MemoryRegion **ram_memory,
PcGuestInfo *guest_info);
qemu_irq *pc_allocate_cpu_irq(void);
DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
--
1.9.3
^ permalink raw reply related [flat|nested] 36+ messages in thread