summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2016-03-01 14:18:18 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2016-03-07 13:18:28 +0100
commit528f46af6ecd1e300db18684969104d4067b867b (patch)
tree8b2d1ff05b51f7246084ea848ed1d420a285d0b7 /memory.c
parentbb8f32c0318cb6c6e13e09ec0f35e21eff246413 (diff)
exec: Return RAMBlock pointer from allocating functions
Previously we return RAMBlock.offset; now return the pointer to the whole structure. ram_block_add returns void now, error is completely passed with errp. Reviewed-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <1456813104-25902-2-git-send-email-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/memory.c b/memory.c
index 013c2ed531..d630b01856 100644
--- a/memory.c
+++ b/memory.c
@@ -1270,11 +1270,14 @@ void memory_region_init_ram(MemoryRegion *mr,
uint64_t size,
Error **errp)
{
+ RAMBlock *ram_block;
+
memory_region_init(mr, owner, name, size);
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
- mr->ram_addr = qemu_ram_alloc(size, mr, errp);
+ ram_block = qemu_ram_alloc(size, mr, errp);
+ mr->ram_addr = ram_block->offset;
mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
@@ -1288,11 +1291,14 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
void *host),
Error **errp)
{
+ RAMBlock *ram_block;
+
memory_region_init(mr, owner, name, size);
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
- mr->ram_addr = qemu_ram_alloc_resizeable(size, max_size, resized, mr, errp);
+ ram_block = qemu_ram_alloc_resizeable(size, max_size, resized, mr, errp);
+ mr->ram_addr = ram_block->offset;
mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
@@ -1305,11 +1311,14 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
const char *path,
Error **errp)
{
+ RAMBlock *ram_block;
+
memory_region_init(mr, owner, name, size);
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
- mr->ram_addr = qemu_ram_alloc_from_file(size, mr, share, path, errp);
+ ram_block = qemu_ram_alloc_from_file(size, mr, share, path, errp);
+ mr->ram_addr = ram_block->offset;
mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
#endif
@@ -1320,6 +1329,8 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
uint64_t size,
void *ptr)
{
+ RAMBlock *ram_block;
+
memory_region_init(mr, owner, name, size);
mr->ram = true;
mr->terminates = true;
@@ -1328,7 +1339,8 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
/* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */
assert(ptr != NULL);
- mr->ram_addr = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_fatal);
+ ram_block = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_fatal);
+ mr->ram_addr = ram_block->offset;
}
void memory_region_set_skip_dump(MemoryRegion *mr)
@@ -1356,13 +1368,16 @@ void memory_region_init_rom_device(MemoryRegion *mr,
uint64_t size,
Error **errp)
{
+ RAMBlock *ram_block;
+
memory_region_init(mr, owner, name, size);
mr->ops = ops;
mr->opaque = opaque;
mr->terminates = true;
mr->rom_device = true;
mr->destructor = memory_region_destructor_rom_device;
- mr->ram_addr = qemu_ram_alloc(size, mr, errp);
+ ram_block = qemu_ram_alloc(size, mr, errp);
+ mr->ram_addr = ram_block->offset;
}
void memory_region_init_iommu(MemoryRegion *mr,