[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 079/106] pc: pass MachineState to pc_memory_init
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 079/106] pc: pass MachineState to pc_memory_init |
Date: |
Wed, 18 Jun 2014 19:20:48 +0300 |
From: Paolo Bonzini <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
Reviewed-By: Igor Mammedov <address@hidden>
Acked-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/hw/i386/pc.h | 7 +++----
hw/i386/pc.c | 24 ++++++++++++------------
hw/i386/pc_piix.c | 8 +++-----
hw/i386/pc_q35.c | 4 +---
4 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index a9529f4..76d4c6e 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -3,6 +3,7 @@
#include "qemu-common.h"
#include "exec/memory.h"
+#include "hw/boards.h"
#include "hw/isa/isa.h"
#include "hw/block/fdc.h"
#include "net/net.h"
@@ -183,10 +184,8 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t
below_4g_mem_size,
void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory,
MemoryRegion *pci_address_space);
-FWCfgState *pc_memory_init(MemoryRegion *system_memory,
- const char *kernel_filename,
- const char *kernel_cmdline,
- const char *initrd_filename,
+FWCfgState *pc_memory_init(MachineState *machine,
+ MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
MemoryRegion *rom_memory,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index c674c1c..67eb450 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1190,10 +1190,8 @@ void pc_acpi_init(const char *default_dsdt)
}
}
-FWCfgState *pc_memory_init(MemoryRegion *system_memory,
- const char *kernel_filename,
- const char *kernel_cmdline,
- const char *initrd_filename,
+FWCfgState *pc_memory_init(MachineState *machine,
+ MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
MemoryRegion *rom_memory,
@@ -1204,18 +1202,19 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
MemoryRegion *ram, *option_rom_mr;
MemoryRegion *ram_below_4g, *ram_above_4g;
FWCfgState *fw_cfg;
- ram_addr_t ram_size = below_4g_mem_size + above_4g_mem_size;
- MachineState *machine = MACHINE(qdev_get_machine());
PCMachineState *pcms = PC_MACHINE(machine);
- linux_boot = (kernel_filename != NULL);
+ assert(machine->ram_size == below_4g_mem_size + above_4g_mem_size);
+
+ linux_boot = (machine->kernel_filename != NULL);
/* Allocate RAM. We allocate it as a single memory region and use
* aliases to address portions of it, mostly for backwards compatibility
* with older qemus that used qemu_ram_alloc().
*/
ram = g_malloc(sizeof(*ram));
- memory_region_allocate_system_memory(ram, NULL, "pc.ram", ram_size);
+ memory_region_allocate_system_memory(ram, NULL, "pc.ram",
+ machine->ram_size);
*ram_memory = ram;
ram_below_4g = g_malloc(sizeof(*ram_below_4g));
memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram,
@@ -1233,7 +1232,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
if (!guest_info->has_reserved_memory &&
(machine->ram_slots ||
- (machine->maxram_size > ram_size))) {
+ (machine->maxram_size > machine->ram_size))) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
error_report("\"-memory 'slots|maxmem'\" is not supported by: %s",
@@ -1243,9 +1242,9 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
/* initialize hotplug memory address space */
if (guest_info->has_reserved_memory &&
- (ram_size < machine->maxram_size)) {
+ (machine->ram_size < machine->maxram_size)) {
ram_addr_t hotplug_mem_size =
- machine->maxram_size - ram_size;
+ machine->maxram_size - machine->ram_size;
if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) {
error_report("unsupported amount of memory slots: %"PRIu64,
@@ -1290,7 +1289,8 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
}
if (linux_boot) {
- load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline,
below_4g_mem_size);
+ load_linux(fw_cfg, machine->kernel_filename, machine->initrd_filename,
+ machine->kernel_cmdline, below_4g_mem_size);
}
for (i = 0; i < nb_option_roms; i++) {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a13e8d6..3e7524b 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -156,11 +156,9 @@ static void pc_init1(MachineState *machine,
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
- fw_cfg = pc_memory_init(system_memory,
- machine->kernel_filename, machine->kernel_cmdline,
- machine->initrd_filename,
- below_4g_mem_size, above_4g_mem_size,
- rom_memory, &ram_memory, guest_info);
+ fw_cfg = pc_memory_init(machine, system_memory,
+ below_4g_mem_size, above_4g_mem_size,
+ rom_memory, &ram_memory, guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 629eb2d..aa71332 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -143,9 +143,7 @@ static void pc_q35_init(MachineState *machine)
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
- pc_memory_init(get_system_memory(),
- machine->kernel_filename, machine->kernel_cmdline,
- machine->initrd_filename,
+ pc_memory_init(machine, get_system_memory(),
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
}
--
MST
- [Qemu-devel] [PULL v2 064/106] NUMA: convert -numa option to use OptsVisitor, (continued)
- [Qemu-devel] [PULL v2 064/106] NUMA: convert -numa option to use OptsVisitor, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 065/106] NUMA: expand MAX_NODES from 64 to 128, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 066/106] man: improve -numa doc, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 067/106] qmp: improve error reporting for -object and object-add, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 068/106] numa: introduce memory_region_allocate_system_memory, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 069/106] memory: reorganize file-based allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 070/106] memory: move preallocation code out of exec.c, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 071/106] memory: move RAM_PREALLOC_MASK to exec.c, rename, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 073/106] Introduce signed range., Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 075/106] numa: add -numa node, memdev= option, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 079/106] pc: pass MachineState to pc_memory_init,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 080/106] backend:hostmem: replace hostmemory with host_memory, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 081/106] hostmem: separate allocation from UserCreatable complete method, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 082/106] hostmem: add file-based HostMemoryBackend, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 083/106] hostmem: add merge and dump properties, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 084/106] hostmem: allow preallocation of any memory region, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 085/106] hostmem: add property to map memory with MAP_SHARED, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 086/106] hostmem: add properties for NUMA memory policy, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 087/106] qmp: add query-memdev, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 089/106] tests: fix memory leak in test of string input visitor, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 088/106] hmp: add info memdev, Michael S. Tsirkin, 2014/06/18