]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
migration: Introduce migrate_has_error()
authorPeter Xu <peterx@redhat.com>
Wed, 4 Oct 2023 22:02:32 +0000 (18:02 -0400)
committerJuan Quintela <quintela@redhat.com>
Wed, 11 Oct 2023 09:17:05 +0000 (11:17 +0200)
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>

migration/migration.c
migration/migration.h

index 57f9e9ed0c3924b6687c7b8d41b7454ea9b4c591..409eb3e916d7c6422628ea7afa1eb97fd87c22d8 100644 (file)
@@ -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);
index 972597f4decdee1b7b6f3a8094fdb447cb2645e8..4106a1dc54b3eef8d4965e0ab581a5577319b77c 100644 (file)
@@ -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);