Skip to content

Commit

Permalink
migration: Introduce migrate_has_error()
Browse files Browse the repository at this point in the history
Introduce a helper to detect whether MigrationState.error is set for
whatever reason.

This is preparation work for any thread (e.g. source return path thread) to
setup errors in an unified way to MigrationState, rather than relying on
its own way to set errors (mark_source_rp_bad()).

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231004220240.167175-3-peterx@redhat.com>
  • Loading branch information
xzpeter authored and Juan Quintela committed Oct 11, 2023
1 parent c94143e commit 2b2f6f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,13 @@ void migrate_set_error(MigrationState *s, const Error *error)
}
}

bool migrate_has_error(MigrationState *s)
{
/* The lock is not helpful here, but still follow the rule */
QEMU_LOCK_GUARD(&s->error_mutex);
return qatomic_read(&s->error);
}

static void migrate_error_free(MigrationState *s)
{
QEMU_LOCK_GUARD(&s->error_mutex);
Expand Down
1 change: 1 addition & 0 deletions migration/migration.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ bool migration_has_all_channels(void);
uint64_t migrate_max_downtime(void);

void migrate_set_error(MigrationState *s, const Error *error);
bool migrate_has_error(MigrationState *s);

void migrate_fd_connect(MigrationState *s, Error *error_in);

Expand Down

0 comments on commit 2b2f6f4

Please sign in to comment.