summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2016-03-01 14:18:19 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2016-03-07 13:18:28 +0100
commit0a75601853c00f3729fa62c49ec0d4bb1e3d9bc1 (patch)
tree9bbc82f3283b969e716970d1403f212fe832bb97 /memory.c
parent528f46af6ecd1e300db18684969104d4067b867b (diff)
downloadqemu-0a75601853c00f3729fa62c49ec0d4bb1e3d9bc1.zip
memory: Move assignment to ram_block to memory_region_init_*
We don't force "const" qualifiers with pointers in QEMU, but it's still good to keep a clean function interface. Assigning to mr->ram_block is in this sense ugly - one initializer mutating its owning object's state. Move it to memory_region_init_*, where mr->ram_addr is assigned. Reviewed-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <1456813104-25902-3-git-send-email-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/memory.c b/memory.c
index d630b01856..1aa777da7f 100644
--- a/memory.c
+++ b/memory.c
@@ -1277,6 +1277,7 @@ void memory_region_init_ram(MemoryRegion *mr,
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
ram_block = qemu_ram_alloc(size, mr, errp);
+ mr->ram_block = ram_block;
mr->ram_addr = ram_block->offset;
mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
@@ -1298,6 +1299,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
ram_block = qemu_ram_alloc_resizeable(size, max_size, resized, mr, errp);
+ mr->ram_block = ram_block;
mr->ram_addr = ram_block->offset;
mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
@@ -1318,6 +1320,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
ram_block = qemu_ram_alloc_from_file(size, mr, share, path, errp);
+ mr->ram_block = ram_block;
mr->ram_addr = ram_block->offset;
mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
@@ -1340,6 +1343,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
/* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */
assert(ptr != NULL);
ram_block = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_fatal);
+ mr->ram_block = ram_block;
mr->ram_addr = ram_block->offset;
}
@@ -1377,6 +1381,7 @@ void memory_region_init_rom_device(MemoryRegion *mr,
mr->rom_device = true;
mr->destructor = memory_region_destructor_rom_device;
ram_block = qemu_ram_alloc(size, mr, errp);
+ mr->ram_block = ram_block;
mr->ram_addr = ram_block->offset;
}