Skip to content

Commit

Permalink
migration: Reference migration state around loadvm_postcopy_handle_ru…
Browse files Browse the repository at this point in the history
…n_bh

We need to hold a reference to the current_migration object around
async calls to avoid it been freed while still in use. Even on this
load-side function, we might still use the MigrationState, e.g to
check for capabilities.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240119233922.32588-4-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
  • Loading branch information
Fabiano Rosas authored and xzpeter committed Jan 26, 2024
1 parent 66acde5 commit b561ebb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions migration/savevm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaque)
qemu_bh_delete(mis->bh);

trace_vmstate_downtime_checkpoint("dst-postcopy-bh-vm-started");
object_unref(OBJECT(migration_get_current()));
}

/* After all discards we can start running and asking for pages */
Expand All @@ -2189,6 +2190,7 @@ static int loadvm_postcopy_handle_run(MigrationIncomingState *mis)

postcopy_state_set(POSTCOPY_INCOMING_RUNNING);
mis->bh = qemu_bh_new(loadvm_postcopy_handle_run_bh, mis);
object_ref(OBJECT(migration_get_current()));
qemu_bh_schedule(mis->bh);

/* We need to finish reading the stream from the package
Expand Down

0 comments on commit b561ebb

Please sign in to comment.