From: Fabiano Rosas Date: Fri, 23 Jan 2026 14:16:38 +0000 (-0300) Subject: migration: Move error reporting out of migration_cleanup X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7be51a6909edca49afff3a8b501122069190466;p=thirdparty%2Fqemu.git migration: Move error reporting out of migration_cleanup In the next patches migration_cleanup() will be used in qmp_migrate(), which currently does not show an error message. Move the error reporting out of migration_cleanup() to avoid duplicate messages. Reviewed-by: Peter Xu Reviewed-by: Prasad Pandit Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-9-farosas@suse.de Signed-off-by: Fabiano Rosas --- diff --git a/migration/migration.c b/migration/migration.c index 93013608ef..000f113307 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1527,10 +1527,6 @@ static void migration_cleanup(MigrationState *s) MIGRATION_STATUS_CANCELLED); } - if (s->error) { - /* It is used on info migrate. We can't free it */ - error_report_err(error_copy(s->error)); - } type = migration_has_failed(s) ? MIG_EVENT_PRECOPY_FAILED : MIG_EVENT_PRECOPY_DONE; migration_call_notifiers(type, NULL); @@ -1539,7 +1535,12 @@ static void migration_cleanup(MigrationState *s) static void migration_cleanup_bh(void *opaque) { - migration_cleanup(opaque); + MigrationState *s = opaque; + + migration_cleanup(s); + if (s->error) { + error_report_err(error_copy(s->error)); + } } /* @@ -4017,18 +4018,12 @@ void migration_connect(MigrationState *s, Error *error_in) s->expected_downtime = migrate_downtime_limit(); if (error_in) { migration_connect_error_propagate(s, error_in); - if (resume) { - /* - * Don't do cleanup for resume if channel is invalid, but only dump - * the error. We wait for another channel connect from the user. - * The error_report still gives HMP user a hint on what failed. - * It's normally done in migration_cleanup(), but call it here - * explicitly. - */ - error_report_err(error_copy(s->error)); - } else { + if (!resume) { migration_cleanup(s); } + if (s->error) { + error_report_err(error_copy(s->error)); + } return; } @@ -4107,8 +4102,10 @@ fail: if (s->state != MIGRATION_STATUS_CANCELLING) { migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); } - error_report_err(local_err); migration_cleanup(s); + if (s->error) { + error_report_err(error_copy(s->error)); + } } static void migration_class_init(ObjectClass *klass, const void *data)