* [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup
@ 2015-08-07 19:55 Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 01/18] pc: Use PC_COMPAT_* for CPUID feature compatibility Eduardo Habkost
` (17 more replies)
0 siblings, 18 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
This implements some extras code cleanups in the PC code:
* Use PC_COMPAT_* instead of a special compat function
for X86 CPUID compatibility
* Use error_abort where appropriate
* Rename PCMachineState variables consistently
* Move some local variables from pc_init1() and pc_q35_init() to
PCMachineState, so initialization functions can get that info from a
PCMachineState* argument directly
* Move some compat global variables to PCMachineClass,
and move compatibility code from pc_compat_*() functions
to the corresponding *_machine_options() function
Eduardo Habkost (18):
pc: Use PC_COMPAT_* for CPUID feature compatibility
target-i386: Remove x86_cpu_compat_set_features()
pc: Use error_abort when registering properties
pc: Rename pc_machine variables to pcms
pc: Move PCMachineClass, PCMachineState to qemu/typedefs.h
pc: Eliminate pc_common_machine_options()
pc: Eliminate pc_default_machine_options()
pc: Use PCMachineState for pc_cmos_init() argument
pc: Use PCMachineState for pc_memory_init() argument
pc: Move {above,below}_4g_mem_size variables to PCMachineState
pc: Use PCMachineState as pc_guest_info_init() argument
pc: Remove redundant arguments from *load_linux()
pc: Remove redundant arguments from pc_cmos_init()
pc: Remove redundant arguments from pc_memory_init()
pc: Remove redundant arguments from xen_hvm_init()
pc: Move compat boolean globals to PCMachineClass
pc: Move legacy_acpi_table_size global to PCMachineClass
pc: Move acpi_data_size global to PCMachineClass
hw/i386/pc.c | 121 +++++++++++++++--------------
hw/i386/pc_piix.c | 201 +++++++++++++++++++-----------------------------
hw/i386/pc_q35.c | 123 +++++++++++------------------
include/hw/i386/pc.h | 167 ++++++++++++++++++++++++++++++++--------
include/hw/xen/xen.h | 4 +-
include/qemu/typedefs.h | 2 +
target-i386/cpu.c | 26 -------
target-i386/cpu.h | 3 -
xen-hvm.c | 25 +++---
9 files changed, 339 insertions(+), 333 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 01/18] pc: Use PC_COMPAT_* for CPUID feature compatibility
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 02/18] target-i386: Remove x86_cpu_compat_set_features() Eduardo Habkost
` (16 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Now we can use compat_props to keep CPUID feature compatibility, using
the boolean QOM properties for CPUID feature flags.
This simplifies the compatibility code, and reduces duplication between
pc_piix.c and pc_q35.c.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 22 ----------
hw/i386/pc_q35.c | 22 ----------
include/hw/i386/pc.h | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 112 insertions(+), 46 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a896624..482555f 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -319,24 +319,6 @@ static void pc_compat_2_2(MachineState *machine)
{
pc_compat_2_3(machine);
rsdp_in_ram = false;
- x86_cpu_compat_set_features("kvm64", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("kvm32", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Conroe", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Penryn", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Nehalem", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Westmere", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("SandyBridge", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Haswell", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Broadwell", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G1", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G2", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G3", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G4", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G5", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
- x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
- x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
- x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
machine->suppress_vmdesc = true;
}
@@ -346,8 +328,6 @@ static void pc_compat_2_1(MachineState *machine)
pc_compat_2_2(machine);
smbios_uuid_encoded = false;
- x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
- x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
pcms->enforce_aligned_dimm = false;
}
@@ -402,8 +382,6 @@ static void pc_compat_1_5(MachineState *machine)
static void pc_compat_1_4(MachineState *machine)
{
pc_compat_1_5(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)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 974aead..1da9b3a 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -302,24 +302,6 @@ static void pc_compat_2_2(MachineState *machine)
{
pc_compat_2_3(machine);
rsdp_in_ram = false;
- x86_cpu_compat_set_features("kvm64", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("kvm32", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Conroe", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Penryn", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Nehalem", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Westmere", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("SandyBridge", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Haswell", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Broadwell", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G1", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G2", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G3", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G4", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Opteron_G5", FEAT_1_EDX, 0, CPUID_VME);
- x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
- x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
- x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
- x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
machine->suppress_vmdesc = true;
}
@@ -330,8 +312,6 @@ static void pc_compat_2_1(MachineState *machine)
pc_compat_2_2(machine);
pcms->enforce_aligned_dimm = false;
smbios_uuid_encoded = false;
- x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
- x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
}
@@ -367,8 +347,6 @@ static void pc_compat_1_5(MachineState *machine)
static void pc_compat_1_4(MachineState *machine)
{
pc_compat_1_5(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);
}
#define DEFINE_Q35_MACHINE(suffix, name, compatfn, optionfn) \
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 954203d..1dca7e7 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -374,11 +374,111 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
#define PC_COMPAT_2_2 \
PC_COMPAT_2_3 \
- HW_COMPAT_2_2
+ HW_COMPAT_2_2 \
+ {\
+ .driver = "kvm64" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "kvm32" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Conroe" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Penryn" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Nehalem" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Westmere" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "SandyBridge" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Haswell" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Broadwell" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Opteron_G1" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Opteron_G2" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Opteron_G3" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Opteron_G4" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Opteron_G5" "-" TYPE_X86_CPU,\
+ .property = "vme",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Haswell" "-" TYPE_X86_CPU,\
+ .property = "f16c",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Haswell" "-" TYPE_X86_CPU,\
+ .property = "rdrand",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Broadwell" "-" TYPE_X86_CPU,\
+ .property = "f16c",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Broadwell" "-" TYPE_X86_CPU,\
+ .property = "rdrand",\
+ .value = "off",\
+ },
#define PC_COMPAT_2_1 \
PC_COMPAT_2_2 \
- HW_COMPAT_2_1
+ HW_COMPAT_2_1 \
+ {\
+ .driver = "coreduo" "-" TYPE_X86_CPU,\
+ .property = "vmx",\
+ .value = "on",\
+ },\
+ {\
+ .driver = "core2duo" "-" TYPE_X86_CPU,\
+ .property = "vmx",\
+ .value = "on",\
+ },
#define PC_COMPAT_2_0 \
PC_COMPAT_2_1 \
@@ -589,6 +689,16 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.driver = "486-" TYPE_X86_CPU,\
.property = "model",\
.value = stringify(0),\
+ },\
+ {\
+ .driver = "n270" "-" TYPE_X86_CPU,\
+ .property = "movbe",\
+ .value = "off",\
+ },\
+ {\
+ .driver = "Westmere" "-" TYPE_X86_CPU,\
+ .property = "pclmulqdq",\
+ .value = "off",\
},
static inline void pc_common_machine_options(MachineClass *m)
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 02/18] target-i386: Remove x86_cpu_compat_set_features()
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 01/18] pc: Use PC_COMPAT_* for CPUID feature compatibility Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 03/18] pc: Use error_abort when registering properties Eduardo Habkost
` (15 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
The function is not used by PC code anymore and can be removed.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 26 --------------------------
target-i386/cpu.h | 3 ---
2 files changed, 29 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 7a779b1..cfb8aa7 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1392,32 +1392,6 @@ static X86CPUDefinition builtin_x86_defs[] = {
},
};
-/**
- * x86_cpu_compat_set_features:
- * @cpu_model: CPU model name to be changed. If NULL, all CPU models are changed
- * @w: Identifies the feature word to be changed.
- * @feat_add: Feature bits to be added to feature word
- * @feat_remove: Feature bits to be removed from feature word
- *
- * Change CPU model feature bits for compatibility.
- *
- * This function may be used by machine-type compatibility functions
- * to enable or disable feature bits on specific CPU models.
- */
-void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w,
- uint32_t feat_add, uint32_t feat_remove)
-{
- X86CPUDefinition *def;
- int i;
- for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
- def = &builtin_x86_defs[i];
- if (!cpu_model || !strcmp(cpu_model, def->name)) {
- def->features[w] |= feat_add;
- def->features[w] &= ~feat_remove;
- }
- }
-}
-
static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
bool migratable_only);
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index ead2832..74b674d 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -1332,9 +1332,6 @@ void cpu_smm_update(X86CPU *cpu);
void cpu_report_tpr_access(CPUX86State *env, TPRAccess access);
-void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w,
- uint32_t feat_add, uint32_t feat_remove);
-
void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features);
void x86_cpu_compat_kvm_no_autodisable(FeatureWord w, uint32_t features);
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 03/18] pc: Use error_abort when registering properties
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 01/18] pc: Use PC_COMPAT_* for CPUID feature compatibility Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 02/18] target-i386: Remove x86_cpu_compat_set_features() Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 04/18] pc: Rename pc_machine variables to pcms Eduardo Habkost
` (14 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
No errors should happen when registering the properties, but we
shouldn't silently ignore them if they happen.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 7661ea9..7c811cd 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1886,39 +1886,39 @@ static void pc_machine_initfn(Object *obj)
object_property_add(obj, PC_MACHINE_MEMHP_REGION_SIZE, "int",
pc_machine_get_hotplug_memory_region_size,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, &error_abort);
pcms->max_ram_below_4g = 1ULL << 32; /* 4G */
object_property_add(obj, PC_MACHINE_MAX_RAM_BELOW_4G, "size",
pc_machine_get_max_ram_below_4g,
pc_machine_set_max_ram_below_4g,
- NULL, NULL, NULL);
+ NULL, NULL, &error_abort);
object_property_set_description(obj, PC_MACHINE_MAX_RAM_BELOW_4G,
"Maximum ram below the 4G boundary (32bit boundary)",
- NULL);
+ &error_abort);
pcms->smm = ON_OFF_AUTO_AUTO;
object_property_add(obj, PC_MACHINE_SMM, "OnOffAuto",
pc_machine_get_smm,
pc_machine_set_smm,
- NULL, NULL, NULL);
+ NULL, NULL, &error_abort);
object_property_set_description(obj, PC_MACHINE_SMM,
"Enable SMM (pc & q35)",
- NULL);
+ &error_abort);
pcms->vmport = ON_OFF_AUTO_AUTO;
object_property_add(obj, PC_MACHINE_VMPORT, "OnOffAuto",
pc_machine_get_vmport,
pc_machine_set_vmport,
- NULL, NULL, NULL);
+ NULL, NULL, &error_abort);
object_property_set_description(obj, PC_MACHINE_VMPORT,
"Enable vmport (pc & q35)",
- NULL);
+ &error_abort);
pcms->enforce_aligned_dimm = true;
object_property_add_bool(obj, PC_MACHINE_ENFORCE_ALIGNED_DIMM,
pc_machine_get_aligned_dimm,
- NULL, NULL);
+ NULL, &error_abort);
}
static unsigned pc_cpu_index_to_socket_id(unsigned cpu_index)
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 04/18] pc: Rename pc_machine variables to pcms
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (2 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 03/18] pc: Use error_abort when registering properties Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 05/18] pc: Move PCMachineClass, PCMachineState to qemu/typedefs.h Eduardo Habkost
` (13 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Make the code use the same variable name everywhere. "pcms" is already
being used in existing code and it's shorter.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 4 ++--
hw/i386/pc_piix.c | 20 ++++++++++----------
hw/i386/pc_q35.c | 20 ++++++++++----------
3 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 7c811cd..ad1a861 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -435,7 +435,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
{
int val;
static pc_cmos_init_late_arg arg;
- PCMachineState *pc_machine = PC_MACHINE(machine);
+ PCMachineState *pcms = PC_MACHINE(machine);
Error *local_err = NULL;
/* various important CMOS locations needed by PC/Bochs bios */
@@ -478,7 +478,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
object_property_add_link(OBJECT(machine), "rtc_state",
TYPE_ISA_DEVICE,
- (Object **)&pc_machine->rtc,
+ (Object **)&pcms->rtc,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(s),
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 482555f..c88ed0d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -78,7 +78,7 @@ static bool kvmclock_enabled = true;
/* PC hardware initialisation */
static void pc_init1(MachineState *machine)
{
- 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 basically 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);
}
}
@@ -234,14 +234,14 @@ static void pc_init1(MachineState *machine)
pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
- assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
- if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
- pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
+ assert(pcms->vmport != ON_OFF_AUTO_MAX);
+ if (pcms->vmport == ON_OFF_AUTO_AUTO) {
+ pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
}
/* init basic PC hardware */
pc_basic_device_init(isa_bus, gsi, &rtc_state, true,
- (pc_machine->vmport != ON_OFF_AUTO_ON), 0x4);
+ (pcms->vmport != ON_OFF_AUTO_ON), 0x4);
pc_nic_init(isa_bus, pci_bus);
@@ -286,13 +286,13 @@ static void pc_init1(MachineState *machine)
/* TODO: Populate SPD eeprom data. */
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
gsi[9], smi_irq,
- pc_machine_is_smm_enabled(pc_machine),
+ pc_machine_is_smm_enabled(pcms),
&piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
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 1da9b3a..d0e4350 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -65,7 +65,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;
@@ -108,13 +108,13 @@ static void pc_q35_init(MachineState *machine)
/* Handle the machine opt max-ram-below-4g. It is basically 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);
}
}
@@ -207,7 +207,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),
@@ -242,17 +242,17 @@ static void pc_q35_init(MachineState *machine)
pc_register_ferr_irq(gsi[13]);
- assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
- if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
- pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
+ assert(pcms->vmport != ON_OFF_AUTO_MAX);
+ if (pcms->vmport == ON_OFF_AUTO_AUTO) {
+ pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
}
/* init basic PC hardware */
pc_basic_device_init(isa_bus, gsi, &rtc_state, !mc->no_floppy,
- (pc_machine->vmport != ON_OFF_AUTO_ON), 0xff0104);
+ (pcms->vmport != ON_OFF_AUTO_ON), 0xff0104);
/* connect pm stuff to lpc */
- ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pc_machine), !mc->no_tco);
+ ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms), !mc->no_tco);
/* ahci and SATA device, for q35 1 ahci controller is built-in */
ahci = pci_create_simple_multifunction(host_bus,
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 05/18] pc: Move PCMachineClass, PCMachineState to qemu/typedefs.h
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (3 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 04/18] pc: Rename pc_machine variables to pcms Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 06/18] pc: Eliminate pc_common_machine_options() Eduardo Habkost
` (12 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
They will be used inside hw/xen/xen.h, which doesn't include
hw/i386/pc.h.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/hw/i386/pc.h | 4 +---
include/qemu/typedefs.h | 2 ++
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 1dca7e7..6746097 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -2,6 +2,7 @@
#define HW_PC_H
#include "qemu-common.h"
+#include "qemu/typedefs.h"
#include "exec/memory.h"
#include "hw/boards.h"
#include "hw/isa/isa.h"
@@ -61,9 +62,6 @@ struct PCMachineClass {
DeviceState *dev);
};
-typedef struct PCMachineState PCMachineState;
-typedef struct PCMachineClass PCMachineClass;
-
#define TYPE_PC_MACHINE "generic-pc-machine"
#define PC_MACHINE(obj) \
OBJECT_CHECK(PCMachineState, (obj), TYPE_PC_MACHINE)
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 6fdcbcd..f8a9dd6 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -58,6 +58,8 @@ typedef struct PCIESlot PCIESlot;
typedef struct PCIExpressDevice PCIExpressDevice;
typedef struct PCIExpressHost PCIExpressHost;
typedef struct PCIHostState PCIHostState;
+typedef struct PCMachineState PCMachineState;
+typedef struct PCMachineClass PCMachineClass;
typedef struct PCMCIACardState PCMCIACardState;
typedef struct PixelFormat PixelFormat;
typedef struct PropertyInfo PropertyInfo;
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 06/18] pc: Eliminate pc_common_machine_options()
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (4 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 05/18] pc: Move PCMachineClass, PCMachineState to qemu/typedefs.h Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 07/18] pc: Eliminate pc_default_machine_options() Eduardo Habkost
` (11 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
All TYPE_PC_MACHINE subclasses call pc_common_machine_options().
TYPE_PC_MACHINE can simply initialize the common options on class_init
directly.
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 ad1a861..583c47a 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1938,6 +1938,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->cpu_index_to_socket_id = pc_cpu_index_to_socket_id;
+ mc->default_boot_order = "cad";
hc->plug = pc_machine_device_plug_cb;
hc->unplug_request = pc_machine_device_unplug_request_cb;
hc->unplug = pc_machine_device_unplug_cb;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index c88ed0d..d722518 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -887,7 +887,6 @@ DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13,
static void isapc_machine_options(MachineClass *m)
{
- pc_common_machine_options(m);
m->desc = "ISA-only PC";
m->max_cpus = 1;
}
@@ -899,7 +898,6 @@ DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
#ifdef CONFIG_XEN
static void xenfv_machine_options(MachineClass *m)
{
- pc_common_machine_options(m);
m->desc = "Xen Fully-virtualized PC";
m->max_cpus = HVM_MAX_VCPUS;
m->default_machine_opts = "accel=xen";
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 6746097..1d21ab2 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -699,14 +699,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.value = "off",\
},
-static inline void pc_common_machine_options(MachineClass *m)
-{
- m->default_boot_order = "cad";
-}
-
static inline void pc_default_machine_options(MachineClass *m)
{
- pc_common_machine_options(m);
m->hot_add_cpu = pc_hot_add_cpu;
m->max_cpus = 255;
}
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 07/18] pc: Eliminate pc_default_machine_options()
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (5 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 06/18] pc: Eliminate pc_common_machine_options() Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 08/18] pc: Use PCMachineState for pc_cmos_init() argument Eduardo Habkost
` (10 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
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 | 1 -
hw/i386/pc_q35.c | 1 -
include/hw/i386/pc.h | 6 ------
4 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 583c47a..29f2b90 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1939,6 +1939,8 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->cpu_index_to_socket_id = pc_cpu_index_to_socket_id;
mc->default_boot_order = "cad";
+ mc->hot_add_cpu = pc_hot_add_cpu;
+ mc->max_cpus = 255;
hc->plug = pc_machine_device_plug_cb;
hc->unplug_request = pc_machine_device_unplug_request_cb;
hc->unplug = pc_machine_device_unplug_cb;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index d722518..48d56c0 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -449,7 +449,6 @@ static void pc_xen_hvm_init(MachineState *machine)
static void pc_i440fx_machine_options(MachineClass *m)
{
- pc_default_machine_options(m);
m->family = "pc_piix";
m->desc = "Standard PC (i440FX + PIIX, 1996)";
m->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index d0e4350..0706934 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -363,7 +363,6 @@ static void pc_compat_1_4(MachineState *machine)
static void pc_q35_machine_options(MachineClass *m)
{
- pc_default_machine_options(m);
m->family = "pc_q35";
m->desc = "Standard PC (Q35 + ICH9, 2009)";
m->hot_add_cpu = pc_hot_add_cpu;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 1d21ab2..0273bec 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -699,12 +699,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.value = "off",\
},
-static inline void pc_default_machine_options(MachineClass *m)
-{
- m->hot_add_cpu = pc_hot_add_cpu;
- m->max_cpus = 255;
-}
-
#define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
{ \
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 08/18] pc: Use PCMachineState for pc_cmos_init() argument
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (6 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 07/18] pc: Eliminate pc_default_machine_options() Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 09/18] pc: Use PCMachineState for pc_memory_init() argument Eduardo Habkost
` (9 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
pc_cmos_init() already expects a PCMachineState object, there's no point
in upcasting it to MachineState before calling the function.
While doing it, reorder the arguments so PCMachineState is the first
function argument.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 10 +++++-----
hw/i386/pc_piix.c | 5 +++--
hw/i386/pc_q35.c | 5 +++--
include/hw/i386/pc.h | 5 +++--
4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 29f2b90..255476b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -428,14 +428,14 @@ static void pc_cmos_init_late(void *opaque)
qemu_unregister_reset(pc_cmos_init_late, opaque);
}
-void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
- const char *boot_device, MachineState *machine,
+void pc_cmos_init(PCMachineState *pcms,
+ ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
+ const char *boot_device,
BusState *idebus0, BusState *idebus1,
ISADevice *s)
{
int val;
static pc_cmos_init_late_arg arg;
- PCMachineState *pcms = PC_MACHINE(machine);
Error *local_err = NULL;
/* various important CMOS locations needed by PC/Bochs bios */
@@ -476,12 +476,12 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
/* set the number of CPU */
rtc_set_memory(s, 0x5f, smp_cpus - 1);
- object_property_add_link(OBJECT(machine), "rtc_state",
+ object_property_add_link(OBJECT(pcms), "rtc_state",
TYPE_ISA_DEVICE,
(Object **)&pcms->rtc,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
- object_property_set_link(OBJECT(machine), OBJECT(s),
+ object_property_set_link(OBJECT(pcms), OBJECT(s),
"rtc_state", &error_abort);
set_boot_dev(s, boot_device, &local_err);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 48d56c0..b975c21 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -271,8 +271,9 @@ static void pc_init1(MachineState *machine)
}
}
- pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
- machine, idebus[0], idebus[1], rtc_state);
+ pc_cmos_init(pcms,
+ below_4g_mem_size, above_4g_mem_size, machine->boot_order,
+ idebus[0], idebus[1], rtc_state);
if (pci_enabled && usb_enabled()) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 0706934..441e9d9 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -276,8 +276,9 @@ static void pc_q35_init(MachineState *machine)
0xb100),
8, NULL, 0);
- pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
- machine, idebus[0], idebus[1], rtc_state);
+ pc_cmos_init(pcms,
+ below_4g_mem_size, above_4g_mem_size, machine->boot_order,
+ idebus[0], idebus[1], rtc_state);
/* the rest devices to which pci devfn is automatically assigned */
pc_vga_init(isa_bus, host_bus);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 0273bec..d8184cd 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -200,8 +200,9 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
bool no_vmport,
uint32 hpet_irqs);
void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
-void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
- const char *boot_device, MachineState *machine,
+void pc_cmos_init(PCMachineState *pcms,
+ ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
+ const char *boot_device,
BusState *ide0, BusState *ide1,
ISADevice *s);
void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus);
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 09/18] pc: Use PCMachineState for pc_memory_init() argument
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (7 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 08/18] pc: Use PCMachineState for pc_cmos_init() argument Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 10/18] pc: Move {above, below}_4g_mem_size variables to PCMachineState Eduardo Habkost
` (8 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
pc_memory_init() already expects a PCMachineState object, there's no
point in upcasting it to MachineState before calling the function.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 4 ++--
hw/i386/pc_piix.c | 2 +-
hw/i386/pc_q35.c | 2 +-
include/hw/i386/pc.h | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 255476b..a9a9cf4 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1289,7 +1289,7 @@ FWCfgState *xen_load_linux(const char *kernel_filename,
return fw_cfg;
}
-FWCfgState *pc_memory_init(MachineState *machine,
+FWCfgState *pc_memory_init(PCMachineState *pcms,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
@@ -1301,7 +1301,7 @@ FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *ram, *option_rom_mr;
MemoryRegion *ram_below_4g, *ram_above_4g;
FWCfgState *fw_cfg;
- PCMachineState *pcms = PC_MACHINE(machine);
+ MachineState *machine = MACHINE(pcms);
assert(machine->ram_size == below_4g_mem_size + above_4g_mem_size);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index b975c21..18e9aa5 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -178,7 +178,7 @@ static void pc_init1(MachineState *machine)
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
- pc_memory_init(machine, system_memory,
+ pc_memory_init(pcms, system_memory,
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
} else if (machine->kernel_filename != NULL) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 441e9d9..6763f0d 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -170,7 +170,7 @@ static void pc_q35_init(MachineState *machine)
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
- pc_memory_init(machine, get_system_memory(),
+ pc_memory_init(pcms, get_system_memory(),
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
}
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index d8184cd..4fa2b3f 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -185,7 +185,7 @@ FWCfgState *xen_load_linux(const char *kernel_filename,
const char *initrd_filename,
ram_addr_t below_4g_mem_size,
PcGuestInfo *guest_info);
-FWCfgState *pc_memory_init(MachineState *machine,
+FWCfgState *pc_memory_init(PCMachineState *pcms,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 10/18] pc: Move {above, below}_4g_mem_size variables to PCMachineState
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (8 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 09/18] pc: Use PCMachineState for pc_memory_init() argument Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 11/18] pc: Use PCMachineState as pc_guest_info_init() argument Eduardo Habkost
` (7 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
This will make the info readily available for the other initialization
functions, and will allow us to simplify their argument list.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 26 ++++++++++++++------------
hw/i386/pc_q35.c | 24 +++++++++++++-----------
include/hw/i386/pc.h | 1 +
3 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 18e9aa5..559f4e5 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -82,7 +82,6 @@ static void pc_init1(MachineState *machine)
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
- ram_addr_t below_4g_mem_size, above_4g_mem_size;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
@@ -128,14 +127,15 @@ static void pc_init1(MachineState *machine)
}
if (machine->ram_size >= lowmem) {
- above_4g_mem_size = machine->ram_size - lowmem;
- below_4g_mem_size = lowmem;
+ pcms->above_4g_mem_size = machine->ram_size - lowmem;
+ pcms->below_4g_mem_size = lowmem;
} else {
- above_4g_mem_size = 0;
- below_4g_mem_size = machine->ram_size;
+ pcms->above_4g_mem_size = 0;
+ pcms->below_4g_mem_size = machine->ram_size;
}
- if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
+ if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
+ &pcms->above_4g_mem_size,
&ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
@@ -160,7 +160,8 @@ static void pc_init1(MachineState *machine)
rom_memory = system_memory;
}
- guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
+ guest_info = pc_guest_info_init(pcms->below_4g_mem_size,
+ pcms->above_4g_mem_size);
guest_info->has_acpi_build = has_acpi_build;
guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
@@ -179,14 +180,14 @@ static void pc_init1(MachineState *machine)
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
pc_memory_init(pcms, system_memory,
- below_4g_mem_size, above_4g_mem_size,
+ pcms->below_4g_mem_size, pcms->above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
} else if (machine->kernel_filename != NULL) {
/* For xen HVM direct kernel boot, load linux here */
xen_load_linux(machine->kernel_filename,
machine->kernel_cmdline,
machine->initrd_filename,
- below_4g_mem_size,
+ pcms->below_4g_mem_size,
guest_info);
}
@@ -202,8 +203,8 @@ static void pc_init1(MachineState *machine)
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
system_memory, system_io, machine->ram_size,
- below_4g_mem_size,
- above_4g_mem_size,
+ pcms->below_4g_mem_size,
+ pcms->above_4g_mem_size,
pci_memory, ram_memory);
} else {
pci_bus = NULL;
@@ -272,7 +273,8 @@ static void pc_init1(MachineState *machine)
}
pc_cmos_init(pcms,
- below_4g_mem_size, above_4g_mem_size, machine->boot_order,
+ pcms->below_4g_mem_size, pcms->above_4g_mem_size,
+ machine->boot_order,
idebus[0], idebus[1], rtc_state);
if (pci_enabled && usb_enabled()) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 6763f0d..489dfcb 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -66,7 +66,6 @@ static bool has_reserved_memory = true;
static void pc_q35_init(MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
- ram_addr_t below_4g_mem_size, above_4g_mem_size;
Q35PCIHost *q35_host;
PCIHostState *phb;
PCIBus *host_bus;
@@ -119,14 +118,15 @@ static void pc_q35_init(MachineState *machine)
}
if (machine->ram_size >= lowmem) {
- above_4g_mem_size = machine->ram_size - lowmem;
- below_4g_mem_size = lowmem;
+ pcms->above_4g_mem_size = machine->ram_size - lowmem;
+ pcms->below_4g_mem_size = lowmem;
} else {
- above_4g_mem_size = 0;
- below_4g_mem_size = machine->ram_size;
+ pcms->above_4g_mem_size = 0;
+ pcms->below_4g_mem_size = machine->ram_size;
}
- if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
+ if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
+ &pcms->above_4g_mem_size,
&ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
@@ -151,7 +151,8 @@ static void pc_q35_init(MachineState *machine)
rom_memory = get_system_memory();
}
- guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
+ guest_info = pc_guest_info_init(pcms->below_4g_mem_size,
+ pcms->above_4g_mem_size);
guest_info->isapc_ram_fw = false;
guest_info->has_acpi_build = has_acpi_build;
guest_info->has_reserved_memory = has_reserved_memory;
@@ -171,7 +172,7 @@ static void pc_q35_init(MachineState *machine)
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
pc_memory_init(pcms, get_system_memory(),
- below_4g_mem_size, above_4g_mem_size,
+ pcms->below_4g_mem_size, pcms->above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
}
@@ -193,8 +194,8 @@ static void pc_q35_init(MachineState *machine)
q35_host->mch.pci_address_space = 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;
- q35_host->mch.above_4g_mem_size = above_4g_mem_size;
+ q35_host->mch.below_4g_mem_size = pcms->below_4g_mem_size;
+ q35_host->mch.above_4g_mem_size = pcms->above_4g_mem_size;
q35_host->mch.guest_info = guest_info;
/* pci */
qdev_init_nofail(DEVICE(q35_host));
@@ -277,7 +278,8 @@ static void pc_q35_init(MachineState *machine)
8, NULL, 0);
pc_cmos_init(pcms,
- below_4g_mem_size, above_4g_mem_size, machine->boot_order,
+ pcms->below_4g_mem_size, pcms->above_4g_mem_size,
+ machine->boot_order,
idebus[0], idebus[1], rtc_state);
/* the rest devices to which pci devfn is automatically assigned */
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 4fa2b3f..e1d20ad 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -40,6 +40,7 @@ struct PCMachineState {
OnOffAuto vmport;
OnOffAuto smm;
bool enforce_aligned_dimm;
+ ram_addr_t below_4g_mem_size, above_4g_mem_size;
};
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 11/18] pc: Use PCMachineState as pc_guest_info_init() argument
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (9 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 10/18] pc: Move {above, below}_4g_mem_size variables to PCMachineState Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 12/18] pc: Remove redundant arguments from *load_linux() Eduardo Habkost
` (6 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 7 +++----
hw/i386/pc_piix.c | 3 +--
hw/i386/pc_q35.c | 3 +--
include/hw/i386/pc.h | 3 +--
4 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index a9a9cf4..081ef83 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1189,15 +1189,14 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)
acpi_setup(&guest_info_state->info);
}
-PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
- ram_addr_t above_4g_mem_size)
+PcGuestInfo *pc_guest_info_init(PCMachineState *pcms)
{
PcGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state);
PcGuestInfo *guest_info = &guest_info_state->info;
int i, j;
- guest_info->ram_size_below_4g = below_4g_mem_size;
- guest_info->ram_size = below_4g_mem_size + above_4g_mem_size;
+ guest_info->ram_size_below_4g = pcms->below_4g_mem_size;
+ guest_info->ram_size = pcms->below_4g_mem_size + pcms->above_4g_mem_size;
guest_info->apic_id_limit = pc_apic_id_limit(max_cpus);
guest_info->apic_xrupt_override = kvm_allows_irq0_override();
guest_info->numa_nodes = nb_numa_nodes;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 559f4e5..9364c47 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -160,8 +160,7 @@ static void pc_init1(MachineState *machine)
rom_memory = system_memory;
}
- guest_info = pc_guest_info_init(pcms->below_4g_mem_size,
- pcms->above_4g_mem_size);
+ guest_info = pc_guest_info_init(pcms);
guest_info->has_acpi_build = has_acpi_build;
guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 489dfcb..af5fd9f 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -151,8 +151,7 @@ static void pc_q35_init(MachineState *machine)
rom_memory = get_system_memory();
}
- guest_info = pc_guest_info_init(pcms->below_4g_mem_size,
- pcms->above_4g_mem_size);
+ guest_info = pc_guest_info_init(pcms);
guest_info->isapc_ram_fw = false;
guest_info->has_acpi_build = has_acpi_build;
guest_info->has_reserved_memory = has_reserved_memory;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index e1d20ad..94d7afb 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -165,8 +165,7 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge);
void pc_hot_add_cpu(const int64_t id, Error **errp);
void pc_acpi_init(const char *default_dsdt);
-PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
- ram_addr_t above_4g_mem_size);
+PcGuestInfo *pc_guest_info_init(PCMachineState *pcms);
void pc_set_legacy_acpi_data_size(void);
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 12/18] pc: Remove redundant arguments from *load_linux()
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (10 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 11/18] pc: Use PCMachineState as pc_guest_info_init() argument Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 13/18] pc: Remove redundant arguments from pc_cmos_init() Eduardo Habkost
` (5 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Remove arguments that can be found in PCMachineState.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 28 ++++++++++++----------------
hw/i386/pc_piix.c | 6 +-----
include/hw/i386/pc.h | 5 +----
3 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 081ef83..54b28a3 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -809,11 +809,8 @@ static long get_file_size(FILE *f)
return size;
}
-static void load_linux(FWCfgState *fw_cfg,
- const char *kernel_filename,
- const char *initrd_filename,
- const char *kernel_cmdline,
- hwaddr max_ram_size)
+static void load_linux(PCMachineState *pcms,
+ FWCfgState *fw_cfg)
{
uint16_t protocol;
int setup_size, kernel_size, initrd_size = 0, cmdline_size;
@@ -822,6 +819,10 @@ static void load_linux(FWCfgState *fw_cfg,
hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
FILE *f;
char *vmode;
+ MachineState *machine = MACHINE(pcms);
+ const char *kernel_filename = machine->kernel_filename;
+ const char *initrd_filename = machine->initrd_filename;
+ const char *kernel_cmdline = machine->kernel_cmdline;
/* Align to 16 bytes as a paranoia measure */
cmdline_size = (strlen(kernel_cmdline)+16) & ~15;
@@ -886,8 +887,8 @@ static void load_linux(FWCfgState *fw_cfg,
initrd_max = 0x37ffffff;
}
- if (initrd_max >= max_ram_size - acpi_data_size) {
- initrd_max = max_ram_size - acpi_data_size - 1;
+ if (initrd_max >= pcms->below_4g_mem_size - acpi_data_size) {
+ initrd_max = pcms->below_4g_mem_size - acpi_data_size - 1;
}
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr);
@@ -1263,22 +1264,18 @@ void pc_acpi_init(const char *default_dsdt)
}
}
-FWCfgState *xen_load_linux(const char *kernel_filename,
- const char *kernel_cmdline,
- const char *initrd_filename,
- ram_addr_t below_4g_mem_size,
+FWCfgState *xen_load_linux(PCMachineState *pcms,
PcGuestInfo *guest_info)
{
int i;
FWCfgState *fw_cfg;
- assert(kernel_filename != NULL);
+ assert(MACHINE(pcms)->kernel_filename != NULL);
fw_cfg = fw_cfg_init_io(BIOS_CFG_IOPORT);
rom_set_fw(fw_cfg);
- load_linux(fw_cfg, kernel_filename, initrd_filename,
- kernel_cmdline, below_4g_mem_size);
+ load_linux(pcms, fw_cfg);
for (i = 0; i < nb_option_roms; i++) {
assert(!strcmp(option_rom[i].name, "linuxboot.bin") ||
!strcmp(option_rom[i].name, "multiboot.bin"));
@@ -1400,8 +1397,7 @@ FWCfgState *pc_memory_init(PCMachineState *pcms,
}
if (linux_boot) {
- load_linux(fw_cfg, machine->kernel_filename, machine->initrd_filename,
- machine->kernel_cmdline, below_4g_mem_size);
+ load_linux(pcms, fw_cfg);
}
for (i = 0; i < nb_option_roms; i++) {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 9364c47..f64f029 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -183,11 +183,7 @@ static void pc_init1(MachineState *machine)
rom_memory, &ram_memory, guest_info);
} else if (machine->kernel_filename != NULL) {
/* For xen HVM direct kernel boot, load linux here */
- xen_load_linux(machine->kernel_filename,
- machine->kernel_cmdline,
- machine->initrd_filename,
- pcms->below_4g_mem_size,
- guest_info);
+ xen_load_linux(pcms, guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 94d7afb..c433602 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -180,10 +180,7 @@ void pc_set_legacy_acpi_data_size(void);
void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory,
MemoryRegion *pci_address_space);
-FWCfgState *xen_load_linux(const char *kernel_filename,
- const char *kernel_cmdline,
- const char *initrd_filename,
- ram_addr_t below_4g_mem_size,
+FWCfgState *xen_load_linux(PCMachineState *pcms,
PcGuestInfo *guest_info);
FWCfgState *pc_memory_init(PCMachineState *pcms,
MemoryRegion *system_memory,
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 13/18] pc: Remove redundant arguments from pc_cmos_init()
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (11 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 12/18] pc: Remove redundant arguments from *load_linux() Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 14/18] pc: Remove redundant arguments from pc_memory_init() Eduardo Habkost
` (4 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Remove arguments that can be found in PCMachineState.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 16 +++++++---------
hw/i386/pc_piix.c | 5 +----
hw/i386/pc_q35.c | 5 +----
include/hw/i386/pc.h | 2 --
4 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 54b28a3..681ea85 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -429,8 +429,6 @@ static void pc_cmos_init_late(void *opaque)
}
void pc_cmos_init(PCMachineState *pcms,
- ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
- const char *boot_device,
BusState *idebus0, BusState *idebus1,
ISADevice *s)
{
@@ -442,12 +440,12 @@ void pc_cmos_init(PCMachineState *pcms,
/* memory size */
/* base memory (first MiB) */
- val = MIN(ram_size / 1024, 640);
+ val = MIN(pcms->below_4g_mem_size / 1024, 640);
rtc_set_memory(s, 0x15, val);
rtc_set_memory(s, 0x16, val >> 8);
/* extended memory (next 64MiB) */
- if (ram_size > 1024 * 1024) {
- val = (ram_size - 1024 * 1024) / 1024;
+ if (pcms->below_4g_mem_size > 1024 * 1024) {
+ val = (pcms->below_4g_mem_size - 1024 * 1024) / 1024;
} else {
val = 0;
}
@@ -458,8 +456,8 @@ void pc_cmos_init(PCMachineState *pcms,
rtc_set_memory(s, 0x30, val);
rtc_set_memory(s, 0x31, val >> 8);
/* memory between 16MiB and 4GiB */
- if (ram_size > 16 * 1024 * 1024) {
- val = (ram_size - 16 * 1024 * 1024) / 65536;
+ if (pcms->below_4g_mem_size > 16 * 1024 * 1024) {
+ val = (pcms->below_4g_mem_size - 16 * 1024 * 1024) / 65536;
} else {
val = 0;
}
@@ -468,7 +466,7 @@ void pc_cmos_init(PCMachineState *pcms,
rtc_set_memory(s, 0x34, val);
rtc_set_memory(s, 0x35, val >> 8);
/* memory above 4GiB */
- val = above_4g_mem_size / 65536;
+ val = pcms->above_4g_mem_size / 65536;
rtc_set_memory(s, 0x5b, val);
rtc_set_memory(s, 0x5c, val >> 8);
rtc_set_memory(s, 0x5d, val >> 16);
@@ -484,7 +482,7 @@ void pc_cmos_init(PCMachineState *pcms,
object_property_set_link(OBJECT(pcms), OBJECT(s),
"rtc_state", &error_abort);
- set_boot_dev(s, boot_device, &local_err);
+ set_boot_dev(s, MACHINE(pcms)->boot_order, &local_err);
if (local_err) {
error_report_err(local_err);
exit(1);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index f64f029..c98635f 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -267,10 +267,7 @@ static void pc_init1(MachineState *machine)
}
}
- pc_cmos_init(pcms,
- pcms->below_4g_mem_size, pcms->above_4g_mem_size,
- machine->boot_order,
- idebus[0], idebus[1], rtc_state);
+ pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
if (pci_enabled && usb_enabled()) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index af5fd9f..79e3f9b 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -276,10 +276,7 @@ static void pc_q35_init(MachineState *machine)
0xb100),
8, NULL, 0);
- pc_cmos_init(pcms,
- pcms->below_4g_mem_size, pcms->above_4g_mem_size,
- machine->boot_order,
- idebus[0], idebus[1], rtc_state);
+ pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
/* the rest devices to which pci devfn is automatically assigned */
pc_vga_init(isa_bus, host_bus);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index c433602..a56f70c 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -198,8 +198,6 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
uint32 hpet_irqs);
void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
void pc_cmos_init(PCMachineState *pcms,
- ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
- const char *boot_device,
BusState *ide0, BusState *ide1,
ISADevice *s);
void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus);
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 14/18] pc: Remove redundant arguments from pc_memory_init()
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (12 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 13/18] pc: Remove redundant arguments from pc_cmos_init() Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 15/18] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
` (3 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Remove arguments that can be found in PCMachineState.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 18 +++++++++---------
hw/i386/pc_piix.c | 1 -
hw/i386/pc_q35.c | 1 -
include/hw/i386/pc.h | 2 --
4 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 681ea85..0c828e4 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1285,8 +1285,6 @@ FWCfgState *xen_load_linux(PCMachineState *pcms,
FWCfgState *pc_memory_init(PCMachineState *pcms,
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)
@@ -1297,7 +1295,8 @@ FWCfgState *pc_memory_init(PCMachineState *pcms,
FWCfgState *fw_cfg;
MachineState *machine = MACHINE(pcms);
- assert(machine->ram_size == below_4g_mem_size + above_4g_mem_size);
+ assert(machine->ram_size == pcms->below_4g_mem_size +
+ pcms->above_4g_mem_size);
linux_boot = (machine->kernel_filename != NULL);
@@ -1311,16 +1310,17 @@ FWCfgState *pc_memory_init(PCMachineState *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);
+ 0, pcms->below_4g_mem_size);
memory_region_add_subregion(system_memory, 0, ram_below_4g);
- e820_add_entry(0, below_4g_mem_size, E820_RAM);
- if (above_4g_mem_size > 0) {
+ e820_add_entry(0, pcms->below_4g_mem_size, E820_RAM);
+ if (pcms->above_4g_mem_size > 0) {
ram_above_4g = g_malloc(sizeof(*ram_above_4g));
memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram,
- below_4g_mem_size, above_4g_mem_size);
+ pcms->below_4g_mem_size,
+ pcms->above_4g_mem_size);
memory_region_add_subregion(system_memory, 0x100000000ULL,
ram_above_4g);
- e820_add_entry(0x100000000ULL, above_4g_mem_size, E820_RAM);
+ e820_add_entry(0x100000000ULL, pcms->above_4g_mem_size, E820_RAM);
}
if (!guest_info->has_reserved_memory &&
@@ -1353,7 +1353,7 @@ FWCfgState *pc_memory_init(PCMachineState *pcms,
}
pcms->hotplug_memory.base =
- ROUND_UP(0x100000000ULL + above_4g_mem_size, 1ULL << 30);
+ ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30);
if (pcms->enforce_aligned_dimm) {
/* size hotplug region assuming 1G page max alignment per slot */
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index c98635f..ce51cd1 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -179,7 +179,6 @@ static void pc_init1(MachineState *machine)
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
pc_memory_init(pcms, system_memory,
- pcms->below_4g_mem_size, pcms->above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
} else if (machine->kernel_filename != NULL) {
/* For xen HVM direct kernel boot, load linux here */
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 79e3f9b..cd4ecc3 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -171,7 +171,6 @@ static void pc_q35_init(MachineState *machine)
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
pc_memory_init(pcms, get_system_memory(),
- pcms->below_4g_mem_size, pcms->above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
}
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index a56f70c..d0cad87 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -184,8 +184,6 @@ FWCfgState *xen_load_linux(PCMachineState *pcms,
PcGuestInfo *guest_info);
FWCfgState *pc_memory_init(PCMachineState *pcms,
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);
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 15/18] pc: Remove redundant arguments from xen_hvm_init()
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (13 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 14/18] pc: Remove redundant arguments from pc_memory_init() Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-13 11:06 ` Michael S. Tsirkin
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 16/18] pc: Move compat boolean globals to PCMachineClass Eduardo Habkost
` (2 subsequent siblings)
17 siblings, 1 reply; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Remove arguments that can be found in PCMachineState.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 4 +---
hw/i386/pc_q35.c | 4 +---
include/hw/xen/xen.h | 4 ++--
xen-hvm.c | 25 ++++++++++++-------------
4 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index ce51cd1..d964f8d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -134,9 +134,7 @@ static void pc_init1(MachineState *machine)
pcms->below_4g_mem_size = machine->ram_size;
}
- if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
- &pcms->above_4g_mem_size,
- &ram_memory) != 0) {
+ if (xen_enabled() && xen_hvm_init(pcms, &ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index cd4ecc3..b7b8709 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -125,9 +125,7 @@ static void pc_q35_init(MachineState *machine)
pcms->below_4g_mem_size = machine->ram_size;
}
- if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
- &pcms->above_4g_mem_size,
- &ram_memory) != 0) {
+ if (xen_enabled() && xen_hvm_init(pcms, &ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 4356af4..e90931a 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -10,6 +10,7 @@
#include "hw/irq.h"
#include "qemu-common.h"
+#include "qemu/typedefs.h"
/* xen-machine.c */
enum xen_mode {
@@ -38,8 +39,7 @@ qemu_irq *xen_interrupt_controller_init(void);
void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
#if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
-int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
- MemoryRegion **ram_memory);
+int xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory);
void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
struct MemoryRegion *mr);
void xen_modified_memory(ram_addr_t start, ram_addr_t length);
diff --git a/xen-hvm.c b/xen-hvm.c
index 0408462..55bce3a 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -180,8 +180,7 @@ qemu_irq *xen_interrupt_controller_init(void)
/* Memory Ops */
-static void xen_ram_init(ram_addr_t *below_4g_mem_size,
- ram_addr_t *above_4g_mem_size,
+static void xen_ram_init(PCMachineState *pcms,
ram_addr_t ram_size, MemoryRegion **ram_memory_p)
{
MemoryRegion *sysmem = get_system_memory();
@@ -198,20 +197,20 @@ static void xen_ram_init(ram_addr_t *below_4g_mem_size,
}
if (ram_size >= user_lowmem) {
- *above_4g_mem_size = ram_size - user_lowmem;
- *below_4g_mem_size = user_lowmem;
+ pcms->above_4g_mem_size = ram_size - user_lowmem;
+ pcms->below_4g_mem_size = user_lowmem;
} else {
- *above_4g_mem_size = 0;
- *below_4g_mem_size = ram_size;
+ pcms->above_4g_mem_size = 0;
+ pcms->below_4g_mem_size = ram_size;
}
- if (!*above_4g_mem_size) {
+ if (!pcms->above_4g_mem_size) {
block_len = ram_size;
} else {
/*
* Xen does not allocate the memory continuously, it keeps a
* hole of the size computed above or passed in.
*/
- block_len = (1ULL << 32) + *above_4g_mem_size;
+ block_len = (1ULL << 32) + pcms->above_4g_mem_size;
}
memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len,
&error_abort);
@@ -229,12 +228,12 @@ static void xen_ram_init(ram_addr_t *below_4g_mem_size,
*/
memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo",
&ram_memory, 0xc0000,
- *below_4g_mem_size - 0xc0000);
+ pcms->below_4g_mem_size - 0xc0000);
memory_region_add_subregion(sysmem, 0xc0000, &ram_lo);
- if (*above_4g_mem_size > 0) {
+ if (pcms->above_4g_mem_size > 0) {
memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi",
&ram_memory, 0x100000000ULL,
- *above_4g_mem_size);
+ pcms->above_4g_mem_size);
memory_region_add_subregion(sysmem, 0x100000000ULL, &ram_hi);
}
}
@@ -1159,7 +1158,7 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
}
/* return 0 means OK, or -1 means critical issue -- will exit(1) */
-int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
+int xen_hvm_init(PCMachineState *pcms,
MemoryRegion **ram_memory)
{
int i, rc;
@@ -1270,7 +1269,7 @@ int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
/* Init RAM management */
xen_map_cache_init(xen_phys_offset_to_gaddr, state);
- xen_ram_init(below_4g_mem_size, above_4g_mem_size, ram_size, ram_memory);
+ xen_ram_init(pcms, ram_size, ram_memory);
qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 16/18] pc: Move compat boolean globals to PCMachineClass
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (14 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 15/18] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 17/18] pc: Move legacy_acpi_table_size global " Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 18/18] pc: Move acpi_data_size " Eduardo Habkost
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
This way the compat flags can be initialized in the machine_options()
function. This will help us to eventually eliminate the pc_compat_*()
functions.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 8 +++++
hw/i386/pc_piix.c | 84 +++++++++++++++++++++++++---------------------------
hw/i386/pc_q35.c | 54 +++++++++++++++------------------
include/hw/i386/pc.h | 14 +++++++++
4 files changed, 86 insertions(+), 74 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 0c828e4..20db409 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1929,6 +1929,14 @@ 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;
+ pcmc->has_acpi_build = true;
+ pcmc->rsdp_in_ram = true;
+ pcmc->smbios_defaults = true;
+ pcmc->smbios_uuid_encoded = true;
+ pcmc->gigabyte_align = true;
+ pcmc->has_reserved_memory = true;
+ pcmc->kvmclock_enabled = true;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->cpu_index_to_socket_id = pc_cpu_index_to_socket_id;
mc->default_boot_order = "cad";
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index d964f8d..81cf681 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -60,25 +60,13 @@ static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
-static bool pci_enabled = true;
-static bool has_acpi_build = true;
-static bool rsdp_in_ram = true;
static int legacy_acpi_table_size;
-static bool smbios_defaults = true;
-static bool smbios_legacy_mode;
-static bool smbios_uuid_encoded = 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.
- */
-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)
{
PCMachineState *pcms = PC_MACHINE(machine);
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
@@ -108,7 +96,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;
}
@@ -145,11 +133,11 @@ 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();
}
- if (pci_enabled) {
+ if (pcmc->pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
@@ -160,18 +148,19 @@ static void pc_init1(MachineState *machine)
guest_info = pc_guest_info_init(pcms);
- guest_info->has_acpi_build = has_acpi_build;
+ guest_info->has_acpi_build = pcmc->has_acpi_build;
guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
- guest_info->isapc_ram_fw = !pci_enabled;
- guest_info->has_reserved_memory = has_reserved_memory;
- guest_info->rsdp_in_ram = rsdp_in_ram;
+ guest_info->isapc_ram_fw = !pcmc->pci_enabled;
+ guest_info->has_reserved_memory = pcmc->has_reserved_memory;
+ guest_info->rsdp_in_ram = pcmc->rsdp_in_ram;
- if (smbios_defaults) {
+ if (pcmc->smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
/* These values are guest ABI, do not change */
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
- mc->name, smbios_legacy_mode, smbios_uuid_encoded);
+ mc->name, pcmc->smbios_legacy_mode,
+ pcmc->smbios_uuid_encoded);
}
/* allocate ram and load rom/bios */
@@ -185,14 +174,14 @@ static void pc_init1(MachineState *machine)
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_irqchip_in_kernel()) {
- kvm_pc_setup_irq_routing(pci_enabled);
+ kvm_pc_setup_irq_routing(pcmc->pci_enabled);
gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
- if (pci_enabled) {
+ if (pcmc->pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
system_memory, system_io, machine->ram_size,
pcms->below_4g_mem_size,
@@ -218,14 +207,14 @@ static void pc_init1(MachineState *machine)
gsi_state->i8259_irq[i] = i8259[i];
}
g_free(i8259);
- if (pci_enabled) {
+ if (pcmc->pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
qdev_init_nofail(icc_bridge);
pc_register_ferr_irq(gsi[13]);
- pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
+ pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
assert(pcms->vmport != ON_OFF_AUTO_MAX);
if (pcms->vmport == ON_OFF_AUTO_AUTO) {
@@ -239,7 +228,7 @@ static void pc_init1(MachineState *machine)
pc_nic_init(isa_bus, pci_bus);
ide_drive_get(hd, ARRAY_SIZE(hd));
- if (pci_enabled) {
+ if (pcmc->pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
@@ -266,11 +255,11 @@ static void pc_init1(MachineState *machine)
pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
- if (pci_enabled && usb_enabled()) {
+ if (pcmc->pci_enabled && usb_enabled()) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
}
- if (pci_enabled && acpi_enabled) {
+ if (pcmc->pci_enabled && acpi_enabled) {
DeviceState *piix4_pm;
I2CBus *smbus;
@@ -291,7 +280,7 @@ static void pc_init1(MachineState *machine)
PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
}
- if (pci_enabled) {
+ if (pcmc->pci_enabled) {
pc_pci_device_init(pci_bus);
}
}
@@ -310,7 +299,6 @@ static void pc_compat_2_3(MachineState *machine)
static void pc_compat_2_2(MachineState *machine)
{
pc_compat_2_3(machine);
- rsdp_in_ram = false;
machine->suppress_vmdesc = true;
}
@@ -319,7 +307,6 @@ static void pc_compat_2_1(MachineState *machine)
PCMachineState *pcms = PC_MACHINE(machine);
pc_compat_2_2(machine);
- smbios_uuid_encoded = false;
x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
pcms->enforce_aligned_dimm = false;
}
@@ -344,16 +331,12 @@ static void pc_compat_2_0(MachineState *machine)
* QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
*/
legacy_acpi_table_size = 6652;
- smbios_legacy_mode = true;
- has_reserved_memory = false;
pc_set_legacy_acpi_data_size();
}
static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
- smbios_defaults = false;
- gigabyte_align = false;
option_rom_has_mr = true;
legacy_acpi_table_size = 6414;
x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
@@ -363,7 +346,6 @@ static void pc_compat_1_6(MachineState *machine)
{
pc_compat_1_7(machine);
rom_file_has_mr = false;
- has_acpi_build = false;
}
static void pc_compat_1_5(MachineState *machine)
@@ -393,17 +375,10 @@ 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_isa(MachineState *machine)
{
- pci_enabled = false;
- 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;
if (!machine->cpu_model) {
@@ -473,8 +448,10 @@ DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
static void pc_i440fx_2_2_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_2_3_machine_options(m);
SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
+ pcmc->rsdp_in_ram = false;
}
DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
@@ -483,9 +460,11 @@ DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
static void pc_i440fx_2_1_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_2_2_machine_options(m);
m->default_display = NULL;
SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
+ pcmc->smbios_uuid_encoded = false;
}
DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
@@ -495,8 +474,11 @@ DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
static void pc_i440fx_2_0_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_2_1_machine_options(m);
SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
+ pcmc->smbios_legacy_mode = true;
+ pcmc->has_reserved_memory = false;
}
DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
@@ -505,9 +487,12 @@ DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
static void pc_i440fx_1_7_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_2_0_machine_options(m);
m->default_machine_opts = NULL;
SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
+ pcmc->smbios_defaults = false;
+ pcmc->gigabyte_align = false;
}
DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
@@ -516,8 +501,10 @@ DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
static void pc_i440fx_1_6_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_1_7_machine_options(m);
SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
+ pcmc->has_acpi_build = false;
}
DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6,
@@ -766,9 +753,11 @@ DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
static void pc_i440fx_0_13_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_0_14_machine_options(m);
m->hw_version = "0.13";
SET_MACHINE_COMPAT(m, PC_COMPAT_0_13);
+ pcmc->kvmclock_enabled = false;
}
DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
@@ -878,8 +867,15 @@ DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13,
static void isapc_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
m->desc = "ISA-only PC";
m->max_cpus = 1;
+ pcmc->pci_enabled = false;
+ pcmc->has_acpi_build = false;
+ pcmc->smbios_defaults = false;
+ pcmc->gigabyte_align = false;
+ pcmc->smbios_legacy_mode = true;
+ pcmc->has_reserved_memory = false;
}
DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index b7b8709..6e1b9cd 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -50,22 +50,11 @@
/* ICH9 AHCI has 6 ports */
#define MAX_SATA_PORTS 6
-static bool has_acpi_build = true;
-static bool rsdp_in_ram = true;
-static bool smbios_defaults = true;
-static bool smbios_legacy_mode;
-static bool smbios_uuid_encoded = 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.
- */
-static bool gigabyte_align = true;
-static bool has_reserved_memory = true;
-
/* PC hardware initialisation */
static void pc_q35_init(MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
Q35PCIHost *q35_host;
PCIHostState *phb;
PCIBus *host_bus;
@@ -77,7 +66,6 @@ static void pc_q35_init(MachineState *machine)
MemoryRegion *ram_memory;
GSIState *gsi_state;
ISABus *isa_bus;
- int pci_enabled = 1;
qemu_irq *gsi;
qemu_irq *i8259;
int i;
@@ -99,7 +87,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;
}
@@ -140,7 +128,7 @@ static void pc_q35_init(MachineState *machine)
kvmclock_create();
/* pci enabled */
- if (pci_enabled) {
+ if (pcmc->pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
@@ -151,19 +139,20 @@ static void pc_q35_init(MachineState *machine)
guest_info = pc_guest_info_init(pcms);
guest_info->isapc_ram_fw = false;
- guest_info->has_acpi_build = has_acpi_build;
- guest_info->has_reserved_memory = has_reserved_memory;
- guest_info->rsdp_in_ram = rsdp_in_ram;
+ guest_info->has_acpi_build = pcmc->has_acpi_build;
+ guest_info->has_reserved_memory = pcmc->has_reserved_memory;
+ guest_info->rsdp_in_ram = pcmc->rsdp_in_ram;
/* Migration was not supported in 2.0 for Q35, so do not bother
* with this hack (see hw/i386/acpi-build.c).
*/
guest_info->legacy_acpi_table_size = 0;
- if (smbios_defaults) {
+ if (pcmc->smbios_defaults) {
/* These values are guest ABI, do not change */
smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)",
- mc->name, smbios_legacy_mode, smbios_uuid_encoded);
+ mc->name, pcmc->smbios_legacy_mode,
+ pcmc->smbios_uuid_encoded);
}
/* allocate ram and load rom/bios */
@@ -175,7 +164,7 @@ static void pc_q35_init(MachineState *machine)
/* irq lines */
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_irqchip_in_kernel()) {
- kvm_pc_setup_irq_routing(pci_enabled);
+ kvm_pc_setup_irq_routing(pcmc->pci_enabled);
gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
@@ -232,7 +221,7 @@ static void pc_q35_init(MachineState *machine)
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
- if (pci_enabled) {
+ if (pcmc->pci_enabled) {
ioapic_init_gsi(gsi_state, "q35");
}
qdev_init_nofail(icc_bridge);
@@ -278,7 +267,7 @@ static void pc_q35_init(MachineState *machine)
/* the rest devices to which pci devfn is automatically assigned */
pc_vga_init(isa_bus, host_bus);
pc_nic_init(isa_bus, host_bus);
- if (pci_enabled) {
+ if (pcmc->pci_enabled) {
pc_pci_device_init(host_bus);
}
}
@@ -297,7 +286,6 @@ static void pc_compat_2_3(MachineState *machine)
static void pc_compat_2_2(MachineState *machine)
{
pc_compat_2_3(machine);
- rsdp_in_ram = false;
machine->suppress_vmdesc = true;
}
@@ -307,23 +295,18 @@ static void pc_compat_2_1(MachineState *machine)
pc_compat_2_2(machine);
pcms->enforce_aligned_dimm = false;
- smbios_uuid_encoded = false;
x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
}
static void pc_compat_2_0(MachineState *machine)
{
pc_compat_2_1(machine);
- smbios_legacy_mode = true;
- has_reserved_memory = false;
pc_set_legacy_acpi_data_size();
}
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_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
@@ -332,7 +315,6 @@ static void pc_compat_1_6(MachineState *machine)
{
pc_compat_1_7(machine);
rom_file_has_mr = false;
- has_acpi_build = false;
}
static void pc_compat_1_5(MachineState *machine)
@@ -394,8 +376,10 @@ DEFINE_Q35_MACHINE(v2_3, "pc-q35-2.3", pc_compat_2_3,
static void pc_q35_2_2_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_q35_2_3_machine_options(m);
SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
+ pcmc->rsdp_in_ram = false;
}
DEFINE_Q35_MACHINE(v2_2, "pc-q35-2.2", pc_compat_2_2,
@@ -404,9 +388,11 @@ DEFINE_Q35_MACHINE(v2_2, "pc-q35-2.2", pc_compat_2_2,
static void pc_q35_2_1_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_q35_2_2_machine_options(m);
m->default_display = NULL;
SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
+ pcmc->smbios_uuid_encoded = false;
}
DEFINE_Q35_MACHINE(v2_1, "pc-q35-2.1", pc_compat_2_1,
@@ -415,8 +401,11 @@ DEFINE_Q35_MACHINE(v2_1, "pc-q35-2.1", pc_compat_2_1,
static void pc_q35_2_0_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_q35_2_1_machine_options(m);
SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
+ pcmc->has_reserved_memory = false;
+ pcmc->smbios_legacy_mode = true;
}
DEFINE_Q35_MACHINE(v2_0, "pc-q35-2.0", pc_compat_2_0,
@@ -425,9 +414,12 @@ DEFINE_Q35_MACHINE(v2_0, "pc-q35-2.0", pc_compat_2_0,
static void pc_q35_1_7_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_q35_2_0_machine_options(m);
m->default_machine_opts = NULL;
SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
+ pcmc->smbios_defaults = false;
+ pcmc->gigabyte_align = false;
}
DEFINE_Q35_MACHINE(v1_7, "pc-q35-1.7", pc_compat_1_7,
@@ -436,8 +428,10 @@ DEFINE_Q35_MACHINE(v1_7, "pc-q35-1.7", pc_compat_1_7,
static void pc_q35_1_6_machine_options(MachineClass *m)
{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_q35_machine_options(m);
SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
+ pcmc->has_acpi_build = false;
}
DEFINE_Q35_MACHINE(v1_6, "pc-q35-1.6", pc_compat_1_6,
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index d0cad87..b09c652 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -61,6 +61,20 @@ struct PCMachineClass {
/*< public >*/
HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
DeviceState *dev);
+
+ bool pci_enabled;
+ bool has_acpi_build;
+ bool rsdp_in_ram;
+ bool smbios_defaults;
+ bool smbios_legacy_mode;
+ bool smbios_uuid_encoded;
+ /* 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;
+ bool has_reserved_memory;
+ bool kvmclock_enabled;
};
#define TYPE_PC_MACHINE "generic-pc-machine"
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 17/18] pc: Move legacy_acpi_table_size global to PCMachineClass
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (15 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 16/18] pc: Move compat boolean globals to PCMachineClass Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 18/18] pc: Move acpi_data_size " Eduardo Habkost
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
This way we can set legacy_acpi_table_size on the machine_options()
functions, instead of requirng code in pc_compat_*() functions.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 40 +++++++++++++++++++---------------------
include/hw/i386/pc.h | 1 +
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 81cf681..69ca014 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -60,8 +60,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 int legacy_acpi_table_size;
-
/* PC hardware initialisation */
static void pc_init1(MachineState *machine)
{
@@ -149,7 +147,7 @@ static void pc_init1(MachineState *machine)
guest_info = pc_guest_info_init(pcms);
guest_info->has_acpi_build = pcmc->has_acpi_build;
- guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
+ guest_info->legacy_acpi_table_size = pcmc->legacy_acpi_table_size;
guest_info->isapc_ram_fw = !pcmc->pci_enabled;
guest_info->has_reserved_memory = pcmc->has_reserved_memory;
@@ -314,23 +312,6 @@ static void pc_compat_2_1(MachineState *machine)
static void pc_compat_2_0(MachineState *machine)
{
pc_compat_2_1(machine);
- /* This value depends on the actual DSDT and SSDT compiled into
- * the source QEMU; unfortunately it depends on the binary and
- * not on the machine type, so we cannot make pc-i440fx-1.7 work on
- * both QEMU 1.7 and QEMU 2.0.
- *
- * Large variations cause migration to fail for more than one
- * consecutive value of the "-smp" maxcpus option.
- *
- * For small variations of the kind caused by different iasl versions,
- * the 4k rounding usually leaves slack. However, there could be still
- * one or two values that break. For QEMU 1.7 and QEMU 2.0 the
- * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
- *
- * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
- * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
- */
- legacy_acpi_table_size = 6652;
pc_set_legacy_acpi_data_size();
}
@@ -338,7 +319,6 @@ static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
option_rom_has_mr = true;
- legacy_acpi_table_size = 6414;
x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
@@ -479,6 +459,23 @@ static void pc_i440fx_2_0_machine_options(MachineClass *m)
SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
pcmc->smbios_legacy_mode = true;
pcmc->has_reserved_memory = false;
+ /* This value depends on the actual DSDT and SSDT compiled into
+ * the source QEMU; unfortunately it depends on the binary and
+ * not on the machine type, so we cannot make pc-i440fx-1.7 work on
+ * both QEMU 1.7 and QEMU 2.0.
+ *
+ * Large variations cause migration to fail for more than one
+ * consecutive value of the "-smp" maxcpus option.
+ *
+ * For small variations of the kind caused by different iasl versions,
+ * the 4k rounding usually leaves slack. However, there could be still
+ * one or two values that break. For QEMU 1.7 and QEMU 2.0 the
+ * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
+ *
+ * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
+ * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
+ */
+ pcmc->legacy_acpi_table_size = 6652;
}
DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
@@ -493,6 +490,7 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m)
SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
pcmc->smbios_defaults = false;
pcmc->gigabyte_align = false;
+ pcmc->legacy_acpi_table_size = 6414;
}
DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index b09c652..b812968 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -75,6 +75,7 @@ struct PCMachineClass {
bool gigabyte_align;
bool has_reserved_memory;
bool kvmclock_enabled;
+ int legacy_acpi_table_size;
};
#define TYPE_PC_MACHINE "generic-pc-machine"
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH for-2.5 18/18] pc: Move acpi_data_size global to PCMachineClass
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
` (16 preceding siblings ...)
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 17/18] pc: Move legacy_acpi_table_size global " Eduardo Habkost
@ 2015-08-07 19:55 ` Eduardo Habkost
17 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-07 19:55 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
This way we don't need code in pc_compat_*() functions to set the legacy
acpi_data_size value.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc.c | 17 ++++++-----------
hw/i386/pc_piix.c | 2 +-
hw/i386/pc_q35.c | 2 +-
include/hw/i386/pc.h | 6 ++++--
4 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 20db409..4f7c532 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -77,15 +77,6 @@
#define DPRINTF(fmt, ...)
#endif
-/* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables
- * (128K) and other BIOS datastructures (less than 4K reported to be used at
- * the moment, 32K should be enough for a while). */
-static unsigned acpi_data_size = 0x20000 + 0x8000;
-void pc_set_legacy_acpi_data_size(void)
-{
- acpi_data_size = 0x10000;
-}
-
#define BIOS_CFG_IOPORT 0x510
#define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0)
#define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1)
@@ -818,6 +809,7 @@ static void load_linux(PCMachineState *pcms,
FILE *f;
char *vmode;
MachineState *machine = MACHINE(pcms);
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
const char *kernel_filename = machine->kernel_filename;
const char *initrd_filename = machine->initrd_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
@@ -885,8 +877,8 @@ static void load_linux(PCMachineState *pcms,
initrd_max = 0x37ffffff;
}
- if (initrd_max >= pcms->below_4g_mem_size - acpi_data_size) {
- initrd_max = pcms->below_4g_mem_size - acpi_data_size - 1;
+ if (initrd_max >= pcms->below_4g_mem_size - pcmc->acpi_data_size) {
+ initrd_max = pcms->below_4g_mem_size - pcmc->acpi_data_size - 1;
}
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr);
@@ -1937,6 +1929,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->gigabyte_align = true;
pcmc->has_reserved_memory = true;
pcmc->kvmclock_enabled = true;
+ /* BIOS ACPI tables: 128K. Other BIOS datastructures: less than 4K reported
+ * to be used at the moment, 32K should be enough for a while. */
+ pcmc->acpi_data_size = 0x20000 + 0x8000;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->cpu_index_to_socket_id = pc_cpu_index_to_socket_id;
mc->default_boot_order = "cad";
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 69ca014..d3d53e5 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -312,7 +312,6 @@ static void pc_compat_2_1(MachineState *machine)
static void pc_compat_2_0(MachineState *machine)
{
pc_compat_2_1(machine);
- pc_set_legacy_acpi_data_size();
}
static void pc_compat_1_7(MachineState *machine)
@@ -476,6 +475,7 @@ static void pc_i440fx_2_0_machine_options(MachineClass *m)
* QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
*/
pcmc->legacy_acpi_table_size = 6652;
+ pcmc->acpi_data_size = 0x10000;
}
DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 6e1b9cd..b006d3c 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -301,7 +301,6 @@ static void pc_compat_2_1(MachineState *machine)
static void pc_compat_2_0(MachineState *machine)
{
pc_compat_2_1(machine);
- pc_set_legacy_acpi_data_size();
}
static void pc_compat_1_7(MachineState *machine)
@@ -406,6 +405,7 @@ static void pc_q35_2_0_machine_options(MachineClass *m)
SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
pcmc->has_reserved_memory = false;
pcmc->smbios_legacy_mode = true;
+ pcmc->acpi_data_size = 0x10000;
}
DEFINE_Q35_MACHINE(v2_0, "pc-q35-2.0", pc_compat_2_0,
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index b812968..e3ecc21 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -76,6 +76,10 @@ struct PCMachineClass {
bool has_reserved_memory;
bool kvmclock_enabled;
int legacy_acpi_table_size;
+ /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables
+ * and other BIOS datastructures.
+ */
+ unsigned acpi_data_size;
};
#define TYPE_PC_MACHINE "generic-pc-machine"
@@ -182,8 +186,6 @@ void pc_acpi_init(const char *default_dsdt);
PcGuestInfo *pc_guest_info_init(PCMachineState *pcms);
-void pc_set_legacy_acpi_data_size(void);
-
#define PCI_HOST_PROP_PCI_HOLE_START "pci-hole-start"
#define PCI_HOST_PROP_PCI_HOLE_END "pci-hole-end"
#define PCI_HOST_PROP_PCI_HOLE64_START "pci-hole64-start"
--
2.1.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.5 15/18] pc: Remove redundant arguments from xen_hvm_init()
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 15/18] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
@ 2015-08-13 11:06 ` Michael S. Tsirkin
2015-08-17 18:37 ` Eduardo Habkost
0 siblings, 1 reply; 21+ messages in thread
From: Michael S. Tsirkin @ 2015-08-13 11:06 UTC (permalink / raw)
To: Eduardo Habkost; +Cc: qemu-devel
On Fri, Aug 07, 2015 at 04:55:56PM -0300, Eduardo Habkost wrote:
> Remove arguments that can be found in PCMachineState.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> hw/i386/pc_piix.c | 4 +---
> hw/i386/pc_q35.c | 4 +---
> include/hw/xen/xen.h | 4 ++--
> xen-hvm.c | 25 ++++++++++++-------------
> 4 files changed, 16 insertions(+), 21 deletions(-)
>
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index ce51cd1..d964f8d 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -134,9 +134,7 @@ static void pc_init1(MachineState *machine)
> pcms->below_4g_mem_size = machine->ram_size;
> }
>
> - if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
> - &pcms->above_4g_mem_size,
> - &ram_memory) != 0) {
> + if (xen_enabled() && xen_hvm_init(pcms, &ram_memory) != 0) {
> fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
> exit(1);
> }
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index cd4ecc3..b7b8709 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -125,9 +125,7 @@ static void pc_q35_init(MachineState *machine)
> pcms->below_4g_mem_size = machine->ram_size;
> }
>
> - if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
> - &pcms->above_4g_mem_size,
> - &ram_memory) != 0) {
> + if (xen_enabled() && xen_hvm_init(pcms, &ram_memory) != 0) {
> fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
> exit(1);
> }
> diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
> index 4356af4..e90931a 100644
> --- a/include/hw/xen/xen.h
> +++ b/include/hw/xen/xen.h
> @@ -10,6 +10,7 @@
>
> #include "hw/irq.h"
> #include "qemu-common.h"
> +#include "qemu/typedefs.h"
>
> /* xen-machine.c */
> enum xen_mode {
> @@ -38,8 +39,7 @@ qemu_irq *xen_interrupt_controller_init(void);
> void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
>
> #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
> -int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
> - MemoryRegion **ram_memory);
> +int xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory);
> void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
> struct MemoryRegion *mr);
> void xen_modified_memory(ram_addr_t start, ram_addr_t length);
> diff --git a/xen-hvm.c b/xen-hvm.c
> index 0408462..55bce3a 100644
> --- a/xen-hvm.c
> +++ b/xen-hvm.c
> @@ -180,8 +180,7 @@ qemu_irq *xen_interrupt_controller_init(void)
>
> /* Memory Ops */
>
> -static void xen_ram_init(ram_addr_t *below_4g_mem_size,
> - ram_addr_t *above_4g_mem_size,
> +static void xen_ram_init(PCMachineState *pcms,
> ram_addr_t ram_size, MemoryRegion **ram_memory_p)
> {
> MemoryRegion *sysmem = get_system_memory();
> @@ -198,20 +197,20 @@ static void xen_ram_init(ram_addr_t *below_4g_mem_size,
> }
>
> if (ram_size >= user_lowmem) {
> - *above_4g_mem_size = ram_size - user_lowmem;
> - *below_4g_mem_size = user_lowmem;
> + pcms->above_4g_mem_size = ram_size - user_lowmem;
> + pcms->below_4g_mem_size = user_lowmem;
> } else {
> - *above_4g_mem_size = 0;
> - *below_4g_mem_size = ram_size;
> + pcms->above_4g_mem_size = 0;
> + pcms->below_4g_mem_size = ram_size;
> }
> - if (!*above_4g_mem_size) {
> + if (!pcms->above_4g_mem_size) {
> block_len = ram_size;
> } else {
> /*
> * Xen does not allocate the memory continuously, it keeps a
> * hole of the size computed above or passed in.
> */
> - block_len = (1ULL << 32) + *above_4g_mem_size;
> + block_len = (1ULL << 32) + pcms->above_4g_mem_size;
> }
> memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len,
> &error_abort);
> @@ -229,12 +228,12 @@ static void xen_ram_init(ram_addr_t *below_4g_mem_size,
> */
> memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo",
> &ram_memory, 0xc0000,
> - *below_4g_mem_size - 0xc0000);
> + pcms->below_4g_mem_size - 0xc0000);
> memory_region_add_subregion(sysmem, 0xc0000, &ram_lo);
> - if (*above_4g_mem_size > 0) {
> + if (pcms->above_4g_mem_size > 0) {
> memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi",
> &ram_memory, 0x100000000ULL,
> - *above_4g_mem_size);
> + pcms->above_4g_mem_size);
> memory_region_add_subregion(sysmem, 0x100000000ULL, &ram_hi);
> }
> }
> @@ -1159,7 +1158,7 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
> }
>
> /* return 0 means OK, or -1 means critical issue -- will exit(1) */
> -int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
> +int xen_hvm_init(PCMachineState *pcms,
> MemoryRegion **ram_memory)
> {
> int i, rc;
This breaks the build: you didn't update the version in xen-hvm-stub.c
Please test on config with all options enabled.
> @@ -1270,7 +1269,7 @@ int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
>
> /* Init RAM management */
> xen_map_cache_init(xen_phys_offset_to_gaddr, state);
> - xen_ram_init(below_4g_mem_size, above_4g_mem_size, ram_size, ram_memory);
> + xen_ram_init(pcms, ram_size, ram_memory);
>
> qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
>
> --
> 2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.5 15/18] pc: Remove redundant arguments from xen_hvm_init()
2015-08-13 11:06 ` Michael S. Tsirkin
@ 2015-08-17 18:37 ` Eduardo Habkost
0 siblings, 0 replies; 21+ messages in thread
From: Eduardo Habkost @ 2015-08-17 18:37 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
On Thu, Aug 13, 2015 at 02:06:04PM +0300, Michael S. Tsirkin wrote:
> On Fri, Aug 07, 2015 at 04:55:56PM -0300, Eduardo Habkost wrote:
[...]
> > @@ -1159,7 +1158,7 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
> > }
> >
> > /* return 0 means OK, or -1 means critical issue -- will exit(1) */
> > -int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
> > +int xen_hvm_init(PCMachineState *pcms,
> > MemoryRegion **ram_memory)
> > {
> > int i, rc;
>
> This breaks the build: you didn't update the version in xen-hvm-stub.c
Oops, sorry.
>
> Please test on config with all options enabled.
I incorrectly assumed the changes wouldn't affect anything except PC, so
I was building it with --target-list=x86_64-softmmu --enable-xen. I
should remember to build it at least once with all targets enabled, next
time.
--
Eduardo
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2015-08-17 18:44 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-07 19:55 [Qemu-devel] [PATCH for-2.5 00/18] pc: Initialization and compat function cleanup Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 01/18] pc: Use PC_COMPAT_* for CPUID feature compatibility Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 02/18] target-i386: Remove x86_cpu_compat_set_features() Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 03/18] pc: Use error_abort when registering properties Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 04/18] pc: Rename pc_machine variables to pcms Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 05/18] pc: Move PCMachineClass, PCMachineState to qemu/typedefs.h Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 06/18] pc: Eliminate pc_common_machine_options() Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 07/18] pc: Eliminate pc_default_machine_options() Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 08/18] pc: Use PCMachineState for pc_cmos_init() argument Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 09/18] pc: Use PCMachineState for pc_memory_init() argument Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 10/18] pc: Move {above, below}_4g_mem_size variables to PCMachineState Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 11/18] pc: Use PCMachineState as pc_guest_info_init() argument Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 12/18] pc: Remove redundant arguments from *load_linux() Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 13/18] pc: Remove redundant arguments from pc_cmos_init() Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 14/18] pc: Remove redundant arguments from pc_memory_init() Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 15/18] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
2015-08-13 11:06 ` Michael S. Tsirkin
2015-08-17 18:37 ` Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 16/18] pc: Move compat boolean globals to PCMachineClass Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 17/18] pc: Move legacy_acpi_table_size global " Eduardo Habkost
2015-08-07 19:55 ` [Qemu-devel] [PATCH for-2.5 18/18] pc: Move acpi_data_size " Eduardo Habkost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).