@samitouri / QOSamiQemu / commits / ce0b9fa9e7

migration/ram: Use migration_bitmap_sync_precopy() for postcopy discard

ram_postcopy_send_discard_bitmap() performs the final RAM dirty bitmap sync at postcopy switchover, before sending discard bitmap to the destination. Unlike the precopy switchover path, it currently calls the raw migration_bitmap_sync() helper and passes last_stage=false. Postcopy switchover is also a stopped-VM final sync point, so use migration_bitmap_sync_precopy(true). This keeps RAM final bitmap sync handling consistent across precopy and postcopy switchover, including the precopy bitmap-sync notifier wrapper. Current notifier users are safe in postcopy: virtio-balloon free-page hinting already opts out when postcopy-ram is enabled [1]. This prepares for moving the final sync out of RAM completion/discard paths and into migration_switchover_start(), where the migration core can run a final save_query_pending pass for all modules uniformly. [1] fd51e54fa102 ("virtio-balloon: don't start free page hinting if postcopy is possible") Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Avihai Horon <avihaih@nvidia.com> Link: https://lore.kernel.org/qemu-devel/20260706085211.13905-3-avihaih@nvidia.com Signed-off-by: Cédric Le Goater <clg@redhat.com>

Avihai Horon committed Jul 6, 2026 at 11:51 UTC ce0b9fa9e75223e73241dbfaeeca39e9c3be4113
1 file changed +1 -1
migration/ram.c
+1 -1
@@ -2687,7 +2687,7 @@ void ram_postcopy_send_discard_bitmap(MigrationState *ms)
2687 RCU_READ_LOCK_GUARD();
2688
2689 /* This should be our last sync, the src is now paused */
2690 - migration_bitmap_sync(rs, false);
2690 + migration_bitmap_sync_precopy(true);
2691
2692 /* Easiest way to make sure we don't resume in the middle of a host-page */
2693 rs->pss[RAM_CHANNEL_PRECOPY].last_sent_block = NULL;