* [Qemu-devel] [PATCH v2 0/4] pc: Initialization and compat function cleanup
@ 2015-08-17 18:42 Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 1/4] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Eduardo Habkost @ 2015-08-17 18:42 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
Changes v1 -> v2:
* Fix build error on patch 1/4
This implements some extras code cleanups in the PC code:
* 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 (4):
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 | 25 +++++-----
hw/i386/pc_piix.c | 130 ++++++++++++++++++++++++---------------------------
hw/i386/pc_q35.c | 60 +++++++++++-------------
include/hw/i386/pc.h | 21 ++++++++-
include/hw/xen/xen.h | 4 +-
xen-hvm-stub.c | 3 +-
xen-hvm.c | 25 +++++-----
7 files changed, 135 insertions(+), 133 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v2 1/4] pc: Remove redundant arguments from xen_hvm_init()
2015-08-17 18:42 [Qemu-devel] [PATCH v2 0/4] pc: Initialization and compat function cleanup Eduardo Habkost
@ 2015-08-17 18:42 ` Eduardo Habkost
2015-08-25 9:13 ` Marcel Apfelbaum
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 2/4] pc: Move compat boolean globals to PCMachineClass Eduardo Habkost
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Eduardo Habkost @ 2015-08-17 18:42 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>
---
Changes v1 -> v2:
* Change prototype on xen-hvm-stub.c too
---
hw/i386/pc_piix.c | 4 +---
hw/i386/pc_q35.c | 4 +---
include/hw/xen/xen.h | 4 ++--
xen-hvm-stub.c | 3 +--
xen-hvm.c | 25 ++++++++++++-------------
5 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 9558467..2b7afc8 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 c07d65b..36dd6a4 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-stub.c b/xen-hvm-stub.c
index 46867d8..6a39425 100644
--- a/xen-hvm-stub.c
+++ b/xen-hvm-stub.c
@@ -47,8 +47,7 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length)
{
}
-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)
{
return 0;
}
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] 6+ messages in thread
* [Qemu-devel] [PATCH v2 2/4] pc: Move compat boolean globals to PCMachineClass
2015-08-17 18:42 [Qemu-devel] [PATCH v2 0/4] pc: Initialization and compat function cleanup Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 1/4] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
@ 2015-08-17 18:42 ` Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 3/4] pc: Move legacy_acpi_table_size global " Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 4/4] pc: Move acpi_data_size " Eduardo Habkost
3 siblings, 0 replies; 6+ messages in thread
From: Eduardo Habkost @ 2015-08-17 18:42 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 9f2924e..430cd5c 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1951,6 +1951,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 2b7afc8..3b80ade 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 36dd6a4..b9e931c 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] 6+ messages in thread
* [Qemu-devel] [PATCH v2 3/4] pc: Move legacy_acpi_table_size global to PCMachineClass
2015-08-17 18:42 [Qemu-devel] [PATCH v2 0/4] pc: Initialization and compat function cleanup Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 1/4] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 2/4] pc: Move compat boolean globals to PCMachineClass Eduardo Habkost
@ 2015-08-17 18:42 ` Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 4/4] pc: Move acpi_data_size " Eduardo Habkost
3 siblings, 0 replies; 6+ messages in thread
From: Eduardo Habkost @ 2015-08-17 18:42 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 3b80ade..ea544fa 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] 6+ messages in thread
* [Qemu-devel] [PATCH v2 4/4] pc: Move acpi_data_size global to PCMachineClass
2015-08-17 18:42 [Qemu-devel] [PATCH v2 0/4] pc: Initialization and compat function cleanup Eduardo Habkost
` (2 preceding siblings ...)
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 3/4] pc: Move legacy_acpi_table_size global " Eduardo Habkost
@ 2015-08-17 18:42 ` Eduardo Habkost
3 siblings, 0 replies; 6+ messages in thread
From: Eduardo Habkost @ 2015-08-17 18:42 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 430cd5c..dea41e7 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)
@@ -840,6 +831,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;
@@ -907,8 +899,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);
@@ -1959,6 +1951,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 ea544fa..bfa0e45 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 b9e931c..4ee653e 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] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/4] pc: Remove redundant arguments from xen_hvm_init()
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 1/4] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
@ 2015-08-25 9:13 ` Marcel Apfelbaum
0 siblings, 0 replies; 6+ messages in thread
From: Marcel Apfelbaum @ 2015-08-25 9:13 UTC (permalink / raw)
To: Eduardo Habkost, Michael S. Tsirkin; +Cc: qemu-devel
On 08/17/2015 09:42 PM, Eduardo Habkost wrote:
> Remove arguments that can be found in PCMachineState.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2:
> * Change prototype on xen-hvm-stub.c too
> ---
> hw/i386/pc_piix.c | 4 +---
> hw/i386/pc_q35.c | 4 +---
> include/hw/xen/xen.h | 4 ++--
> xen-hvm-stub.c | 3 +--
> xen-hvm.c | 25 ++++++++++++-------------
> 5 files changed, 17 insertions(+), 23 deletions(-)
>
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 9558467..2b7afc8 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 c07d65b..36dd6a4 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-stub.c b/xen-hvm-stub.c
> index 46867d8..6a39425 100644
> --- a/xen-hvm-stub.c
> +++ b/xen-hvm-stub.c
> @@ -47,8 +47,7 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length)
> {
> }
>
> -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)
> {
> return 0;
> }
> 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);
>
>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Thanks,
Marcel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-08-25 9:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17 18:42 [Qemu-devel] [PATCH v2 0/4] pc: Initialization and compat function cleanup Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 1/4] pc: Remove redundant arguments from xen_hvm_init() Eduardo Habkost
2015-08-25 9:13 ` Marcel Apfelbaum
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 2/4] pc: Move compat boolean globals to PCMachineClass Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 3/4] pc: Move legacy_acpi_table_size global " Eduardo Habkost
2015-08-17 18:42 ` [Qemu-devel] [PATCH v2 4/4] 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).