aboutsummaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2013-10-08 13:52:02 +0200
committerJuan Quintela <quintela@redhat.com>2014-01-13 14:04:54 +0100
commit2152f5ca782e51a4d05a1f7d9bfa83286323cbc9 (patch)
tree7b55bc1cebe4b8703865020081b1e6582d896209 /exec.c
parent7a5b558c9d061814f34d9b95d70d17ef75037937 (diff)
downloadqemu-arm-2152f5ca782e51a4d05a1f7d9bfa83286323cbc9.tar.gz
memory: only resize dirty bitmap when memory size increases
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/exec.c b/exec.c
index 82aca4ad37..db369dc42f 100644
--- a/exec.c
+++ b/exec.c
@@ -1211,6 +1211,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
MemoryRegion *mr)
{
RAMBlock *block, *new_block;
+ ram_addr_t old_ram_size, new_ram_size;
+
+ old_ram_size = last_ram_offset() >> TARGET_PAGE_BITS;
size = TARGET_PAGE_ALIGN(size);
new_block = g_malloc0(sizeof(*new_block));
@@ -1271,10 +1274,13 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
ram_list.version++;
qemu_mutex_unlock_ramlist();
- ram_list.phys_dirty = g_realloc(ram_list.phys_dirty,
- last_ram_offset() >> TARGET_PAGE_BITS);
- memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
+ new_ram_size = last_ram_offset() >> TARGET_PAGE_BITS;
+
+ if (new_ram_size > old_ram_size) {
+ ram_list.phys_dirty = g_realloc(ram_list.phys_dirty, new_ram_size);
+ memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
0, size >> TARGET_PAGE_BITS);
+ }
cpu_physical_memory_set_dirty_range(new_block->offset, size);
qemu_ram_setup_dump(new_block->host, size);