diff options
author | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2014-03-27 15:01:48 +0000 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2014-05-05 22:15:03 +0200 |
commit | e30d1d8c7195848abb28a8c734a82b845b8b456a (patch) | |
tree | 004856d6bbeb5e699d3572c676cd3adbe6d6b867 /arch_init.c | |
parent | 548f52ea06951c20f0b91cae6cde0512ec073c83 (diff) | |
download | qemu-e30d1d8c7195848abb28a8c734a82b845b8b456a.zip qemu-e30d1d8c7195848abb28a8c734a82b845b8b456a.tar.gz qemu-e30d1d8c7195848abb28a8c734a82b845b8b456a.tar.bz2 |
Count used RAMBlock pages for migration_dirty_pages
This is a fix for a bug* triggered by a migration after hot unplugging
a few virtio-net NICs, that caused migration never to converge, because
'migration_dirty_pages' is incorrectly initialised.
'migration_dirty_pages' is used as a tally of the number of outstanding
dirty pages, to give the migration code an idea of how much more data
will need to be transferred, and thus whether it can end the iterative
phase.
It was initialised to the total size of the RAMBlock address space,
however hotunplug can leave this space sparse, and hence
migration_dirty_pages ended up too large.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
(* https://bugzilla.redhat.com/show_bug.cgi?id=1074913 )
Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'arch_init.c')
-rw-r--r-- | arch_init.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/arch_init.c b/arch_init.c index 60c975d..0c8c07d 100644 --- a/arch_init.c +++ b/arch_init.c @@ -726,11 +726,8 @@ static void reset_ram_globals(void) static int ram_save_setup(QEMUFile *f, void *opaque) { RAMBlock *block; - int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS; + int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ - migration_bitmap = bitmap_new(ram_pages); - bitmap_set(migration_bitmap, 0, ram_pages); - migration_dirty_pages = ram_pages; mig_throttle_on = false; dirty_rate_high_cnt = 0; @@ -770,6 +767,22 @@ static int ram_save_setup(QEMUFile *f, void *opaque) bytes_transferred = 0; reset_ram_globals(); + ram_bitmap_pages = last_ram_offset() >> TARGET_PAGE_BITS; + migration_bitmap = bitmap_new(ram_bitmap_pages); + bitmap_set(migration_bitmap, 0, ram_bitmap_pages); + + /* + * Count the total number of pages used by ram blocks not including any + * gaps due to alignment or unplugs. + */ + migration_dirty_pages = 0; + QTAILQ_FOREACH(block, &ram_list.blocks, next) { + uint64_t block_pages; + + block_pages = block->length >> TARGET_PAGE_BITS; + migration_dirty_pages += block_pages; + } + memory_global_dirty_log_start(); migration_bitmap_sync(); qemu_mutex_unlock_iothread(); |