1. Most of callers want to free the error after call. Let's help them.
2. Some callers log the error, some not. We also have places where we
log the stored error. Let's instead simply log every migration
error.
3. Some callers have to retrieve current migration state only to pass
it to migrate_set_error(). In the new helper let's get the state
automatically.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
migration/migration.c | 48 ++++++++++++----------------------------
migration/migration.h | 2 +-
migration/multifd.c | 18 ++++++---------
migration/postcopy-ram.c | 3 +--
migration/savevm.c | 16 +++++---------
5 files changed, 28 insertions(+), 59 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 696762bc64..806b7b080b 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -285,7 +285,7 @@ void migration_bh_schedule(QEMUBHFunc *cb, void *opaque)
void migration_cancel(const Error *error)
{
if (error) {
- migrate_set_error(current_migration, error);
+ migrate_report_err(error_copy(error));
}
if (migrate_dirty_limit()) {
qmp_cancel_vcpu_dirty_limit(false, -1, NULL);
@@ -779,13 +779,6 @@ process_incoming_migration_co(void *opaque)
}
if (ret < 0) {
- MigrationState *s = migrate_get_current();
-
- if (migrate_has_error(s)) {
- WITH_QEMU_LOCK_GUARD(&s->error_mutex) {
- error_report_err(s->error);
- }
- }
error_report("load of migration failed: %s", strerror(-ret));
goto fail;
}
@@ -1402,10 +1395,6 @@ static void migrate_fd_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(s, type, NULL);
@@ -1418,12 +1407,14 @@ static void migrate_fd_cleanup_bh(void *opaque)
migrate_fd_cleanup(opaque);
}
-void migrate_set_error(MigrationState *s, const Error *error)
+void migrate_report_err(Error *error)
{
+ MigrationState *s = migrate_get_current();