diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-12-15 22:55:32 +0200 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-01-08 13:17:54 +0200 |
commit | 9b8424d5735278ca382f11adc7c63072b632ab83 (patch) | |
tree | a7320e19b3418258eebda8d2b2164e9a9b830d3a /arch_init.c | |
parent | c8d6f66ae7d0ce5f3622c19e29a2333d28dc1e9a (diff) | |
download | qemu-9b8424d5735278ca382f11adc7c63072b632ab83.zip qemu-9b8424d5735278ca382f11adc7c63072b632ab83.tar.gz qemu-9b8424d5735278ca382f11adc7c63072b632ab83.tar.bz2 |
exec: split length -> used_length/max_length
This patch allows us to distinguish between two
length values for each block:
max_length - length of memory block that was allocated
used_length - length of block used by QEMU/guest
Currently, we set used_length - max_length, unconditionally.
Follow-up patches allow used_length <= max_length.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch_init.c')
-rw-r--r-- | arch_init.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/arch_init.c b/arch_init.c index 7680d28..106f46e 100644 --- a/arch_init.c +++ b/arch_init.c @@ -522,7 +522,7 @@ static void migration_bitmap_sync(void) address_space_sync_dirty_bitmap(&address_space_memory); QTAILQ_FOREACH(block, &ram_list.blocks, next) { - migration_bitmap_sync_range(block->mr->ram_addr, block->length); + migration_bitmap_sync_range(block->mr->ram_addr, block->used_length); } trace_migration_bitmap_sync_end(migration_dirty_pages - num_dirty_pages_init); @@ -668,7 +668,7 @@ static int ram_find_and_save_block(QEMUFile *f, bool last_stage) offset >= last_offset) { break; } - if (offset >= block->length) { + if (offset >= block->used_length) { offset = 0; block = QTAILQ_NEXT(block, next); if (!block) { @@ -727,7 +727,7 @@ uint64_t ram_bytes_total(void) uint64_t total = 0; QTAILQ_FOREACH(block, &ram_list.blocks, next) - total += block->length; + total += block->used_length; return total; } @@ -831,7 +831,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) QTAILQ_FOREACH(block, &ram_list.blocks, next) { uint64_t block_pages; - block_pages = block->length >> TARGET_PAGE_BITS; + block_pages = block->used_length >> TARGET_PAGE_BITS; migration_dirty_pages += block_pages; } @@ -844,7 +844,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) QTAILQ_FOREACH(block, &ram_list.blocks, next) { qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr)); - qemu_put_be64(f, block->length); + qemu_put_be64(f, block->used_length); } qemu_mutex_unlock_ramlist(); @@ -1015,7 +1015,7 @@ static inline void *host_from_stream_offset(QEMUFile *f, uint8_t len; if (flags & RAM_SAVE_FLAG_CONTINUE) { - if (!block || block->length <= offset) { + if (!block || block->max_length <= offset) { error_report("Ack, bad migration stream!"); return NULL; } @@ -1028,7 +1028,8 @@ static inline void *host_from_stream_offset(QEMUFile *f, id[len] = 0; QTAILQ_FOREACH(block, &ram_list.blocks, next) { - if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) { + if (!strncmp(id, block->idstr, sizeof(id)) && + block->max_length > offset) { return memory_region_get_ram_ptr(block->mr) + offset; } } @@ -1085,10 +1086,10 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (!strncmp(id, block->idstr, sizeof(id))) { - if (block->length != length) { + if (block->used_length != length) { error_report("Length mismatch: %s: 0x" RAM_ADDR_FMT " in != 0x" RAM_ADDR_FMT, id, length, - block->length); + block->used_length); ret = -EINVAL; } break; |