Commit 64df66fe8c for qemu.org

commit 64df66fe8caf09517a2c8168653def1020e6a95d
Author: Lukas Straub <lukasstraub2@web.de>
Date:   Mon Mar 2 12:43:39 2026 +0100

    Call colo_release_ram_cache() after multifd threads terminate

    The multifd threads still may access the colo cache, so release it
    only after they terminate.

    Reviewed-by: Fabiano Rosas <farosas@suse.de>
    Reviewed-by: Peter Xu <peterx@redhat.com>
    Signed-off-by: Lukas Straub <lukasstraub2@web.de>
    Link: https://lore.kernel.org/qemu-devel/20260302-colo_unit_test_multifd-v11-9-d653fb3b1d80@web.de
    Signed-off-by: Fabiano Rosas <farosas@suse.de>

diff --git a/migration/colo.c b/migration/colo.c
index 97a224c39c..96102c9d0f 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -949,7 +949,4 @@ void coroutine_fn colo_incoming_co(void)
     /* Wait checkpoint incoming thread exit before free resource */
     qemu_thread_join(&th);
     bql_lock();
-
-    /* We hold the global BQL, so it is safe here */
-    colo_release_ram_cache();
 }
diff --git a/migration/migration.c b/migration/migration.c
index f10abf91e2..53bf87c3fc 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -454,6 +454,9 @@ void migration_incoming_state_destroy(void)
      * BQL and retake unconditionally.
      */
     assert(bql_locked());
+    if (migrate_colo()) {
+        colo_release_ram_cache();
+    }
     qemu_loadvm_state_cleanup(mis);

     if (mis->to_src_file) {