If only bitmaps postcopy migration enabled and not ram, this assertion will fire, as we don't have to_src_file for bitmaps postcopy migration.
migrate_postcopy_ram() accesses migrations state, which may be freed in main thread, so, we should ref/unref it in postcopy incoming thread. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> --- migration/savevm.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index adfdca26ac..143755389e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1832,6 +1832,9 @@ static void *postcopy_ram_listen_thread(void *opaque) MigrationIncomingState *mis = migration_incoming_get_current(); QEMUFile *f = mis->from_src_file; int load_res; + MigrationState *migr = migrate_get_current(); + + object_ref(OBJECT(migr)); migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_POSTCOPY_ACTIVE); @@ -1898,6 +1901,8 @@ static void *postcopy_ram_listen_thread(void *opaque) mis->have_listen_thread = false; postcopy_state_set(POSTCOPY_INCOMING_END); + object_unref(OBJECT(migr)); + return NULL; } @@ -2457,12 +2462,14 @@ static bool postcopy_pause_incoming(MigrationIncomingState *mis) qemu_fclose(mis->from_src_file); mis->from_src_file = NULL; - assert(mis->to_src_file); - qemu_file_shutdown(mis->to_src_file); - qemu_mutex_lock(&mis->rp_mutex); - qemu_fclose(mis->to_src_file); - mis->to_src_file = NULL; - qemu_mutex_unlock(&mis->rp_mutex); + if (migrate_postcopy_ram()) { + assert(mis->to_src_file); + qemu_file_shutdown(mis->to_src_file); + qemu_mutex_lock(&mis->rp_mutex); + qemu_fclose(mis->to_src_file); + mis->to_src_file = NULL; + qemu_mutex_unlock(&mis->rp_mutex); + } migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, MIGRATION_STATUS_POSTCOPY_PAUSED); -- 2.21.0