]> git.proxmox.com Git - mirror_qemu.git/commitdiff
migration: Take reference to migration state around bg_migration_vm_start_bh
authorFabiano Rosas <farosas@suse.de>
Fri, 19 Jan 2024 23:39:19 +0000 (20:39 -0300)
committerPeter Xu <peterx@redhat.com>
Mon, 29 Jan 2024 03:02:12 +0000 (11:02 +0800)
We need to hold a reference to the current_migration object around
async calls to avoid it been freed while still in use.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240119233922.32588-3-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
migration/migration.c

index cf17b68e57679bbd5d4a43a6e53543fb8a5e2df3..b1213b59ce70c6e2cbbe33bfed8cf6ecb06af678 100644 (file)
@@ -3382,6 +3382,7 @@ static void bg_migration_vm_start_bh(void *opaque)
 
     vm_resume(s->vm_old_state);
     migration_downtime_end(s);
+    object_unref(OBJECT(s));
 }
 
 /**
@@ -3486,6 +3487,7 @@ static void *bg_migration_thread(void *opaque)
      * writes to virtio VQs memory which is in write-protected region.
      */
     s->vm_start_bh = qemu_bh_new(bg_migration_vm_start_bh, s);
+    object_ref(OBJECT(s));
     qemu_bh_schedule(s->vm_start_bh);
 
     bql_unlock();