There is no need to update the dirty log from inside ram_save_block, since this happens through cpu_physical_sync_dirty_bitmap. In stage 3, where the VM is stopped, cpu_physical_sync_dirty_bitmap guarantees dirty log is synchronized before migration finishes. Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx> Index: qemu-kvm-cleanups/vl.c =================================================================== --- qemu-kvm-cleanups.orig/vl.c +++ qemu-kvm-cleanups/vl.c @@ -2782,15 +2782,6 @@ static int ram_save_block(QEMUFile *f) int found = 0; while (addr < last_ram_offset) { - if (kvm_enabled() && current_addr == 0) { - int r; - r = kvm_update_dirty_pages_log(); - if (r) { - fprintf(stderr, "%s: update dirty pages log failed %d\n", __FUNCTION__, r); - qemu_file_set_error(f); - return 0; - } - } if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) { uint8_t *p; Index: qemu-kvm-cleanups/qemu-kvm.c =================================================================== --- qemu-kvm-cleanups.orig/qemu-kvm.c +++ qemu-kvm-cleanups/qemu-kvm.c @@ -2338,20 +2338,6 @@ static int kvm_get_dirty_bitmap_cb(unsig return kvm_get_dirty_pages_log_range(start, bitmap, start, len); } -/* - * get kvm's dirty pages bitmap and update qemu's - * we only care about physical ram, which resides in slots 0 and 3 - */ -int kvm_update_dirty_pages_log(void) -{ - int r = 0; - - - r = kvm_get_dirty_pages_range(kvm_context, 0, -1UL, NULL, - kvm_get_dirty_bitmap_cb); - return r; -} - void kvm_qemu_log_memory(target_phys_addr_t start, target_phys_addr_t size, int log) { Index: qemu-kvm-cleanups/qemu-kvm.h =================================================================== --- qemu-kvm-cleanups.orig/qemu-kvm.h +++ qemu-kvm-cleanups/qemu-kvm.h @@ -836,7 +836,6 @@ void kvm_hpet_disable_kpit(void); int kvm_set_irq(int irq, int level, int *status); int kvm_physical_memory_set_dirty_tracking(int enable); -int kvm_update_dirty_pages_log(void); void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *env); void qemu_kvm_cpuid_on_env(CPUState *env); -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html