[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V9 45/46] migration: notifier error reporting
From: |
Steve Sistare |
Subject: |
[PATCH V9 45/46] migration: notifier error reporting |
Date: |
Tue, 26 Jul 2022 09:10:42 -0700 |
Provide migration_notifier_set_error(), which allows migration notifiers
to return an error message indicating they have failed, which halts the
migration. The error message is visible in the 'info migrate' command.
No functional change until calls to migration_notifier_set_error are
added.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/migration/misc.h | 3 ++-
migration/migration.c | 31 +++++++++++++++++++++++++++----
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/include/migration/misc.h b/include/migration/misc.h
index d4c2d7d..e5d8c81 100644
--- a/include/migration/misc.h
+++ b/include/migration/misc.h
@@ -63,7 +63,8 @@ bool migration_is_active(MigrationState *);
void migration_add_notifier(Notifier *notify,
void (*func)(Notifier *notifier, void *data));
void migration_remove_notifier(Notifier *notify);
-void migration_call_notifiers(MigrationState *s);
+int migration_call_notifiers(MigrationState *s);
+void migration_notifier_set_error(MigrationState *s, Error *err);
bool migration_in_setup(MigrationState *);
bool migration_has_finished(MigrationState *);
bool migration_has_failed(MigrationState *);
diff --git a/migration/migration.c b/migration/migration.c
index 45eebea..d477b58 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1924,6 +1924,8 @@ static void block_cleanup_parameters(MigrationState *s)
static void migrate_fd_cleanup(MigrationState *s)
{
+ bool already_failed;
+
qemu_bh_delete(s->cleanup_bh);
s->cleanup_bh = NULL;
@@ -1973,7 +1975,15 @@ static void migrate_fd_cleanup(MigrationState *s)
/* It is used on info migrate. We can't free it */
error_report_err(error_copy(s->error));
}
- migration_call_notifiers(s);
+
+ already_failed = migration_has_failed(s);
+ if (migration_call_notifiers(s)) {
+ if (!already_failed) {
+ migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED);
+ /* Notify again to recover from this late failure. */
+ migration_call_notifiers(s);
+ }
+ }
block_cleanup_parameters(s);
cpr_exec();
yank_unregister_instance(MIGRATION_YANK_INSTANCE);
@@ -2084,9 +2094,16 @@ void migration_remove_notifier(Notifier *notify)
}
}
-void migration_call_notifiers(MigrationState *s)
+int migration_call_notifiers(MigrationState *s)
{
notifier_list_notify(&migration_state_notifiers, s);
+ return (s->error != NULL);
+}
+
+void migration_notifier_set_error(MigrationState *s, Error *err)
+{
+ migrate_set_error(s, err);
+ error_report_err(err);
}
bool migration_in_setup(MigrationState *s)
@@ -3381,7 +3398,9 @@ static int postcopy_start(MigrationState *ms)
* spice needs to trigger a transition now
*/
ms->postcopy_after_devices = true;
- migration_call_notifiers(ms);
+ if (migration_call_notifiers(ms)) {
+ goto fail;
+ }
ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop;
@@ -4412,7 +4431,11 @@ void migrate_fd_connect(MigrationState *s, Error
*error_in)
rate_limit = s->parameters.max_bandwidth / XFER_LIMIT_RATIO;
/* Notify before starting migration thread */
- migration_call_notifiers(s);
+ if (migration_call_notifiers(s)) {
+ migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED);
+ migrate_fd_cleanup(s);
+ return;
+ }
}
qemu_file_set_rate_limit(s->to_dst_file, rate_limit);
--
1.8.3.1
- [PATCH V9 22/46] cpr: exec mode, (continued)
- [PATCH V9 22/46] cpr: exec mode, Steve Sistare, 2022/07/26
- [PATCH V9 16/46] migration: simplify notifiers, Steve Sistare, 2022/07/26
- [PATCH V9 26/46] cpr: Mismatched GPAs fix, Steve Sistare, 2022/07/26
- [PATCH V9 37/46] chardev: cpr for simple devices, Steve Sistare, 2022/07/26
- [PATCH V9 38/46] chardev: cpr for pty, Steve Sistare, 2022/07/26
- [PATCH V9 32/46] vfio-pci: cpr part 2 (msi), Steve Sistare, 2022/07/26
- [PATCH V9 34/46] vfio-pci: recover from unmap-all-vaddr failure, Steve Sistare, 2022/07/26
- [PATCH V9 40/46] python/machine: QEMUMachine full_args, Steve Sistare, 2022/07/26
- [PATCH V9 17/46] migration: check mode in notifiers, Steve Sistare, 2022/07/26
- [PATCH V9 45/46] migration: notifier error reporting,
Steve Sistare <=
- [PATCH V9 36/46] chardev: cpr framework, Steve Sistare, 2022/07/26
- [PATCH V9 41/46] python/machine: QEMUMachine reopen_qmp_connection, Steve Sistare, 2022/07/26
- [PATCH V9 43/46] vl: start on wakeup request, Steve Sistare, 2022/07/26
- [PATCH V9 44/46] migration: fix suspended runstate, Steve Sistare, 2022/07/26
- [PATCH V9 42/46] tests/avocado: add cpr regression test, Steve Sistare, 2022/07/26
- [PATCH V9 46/46] vfio: allow cpr-reboot migration if suspended, Steve Sistare, 2022/07/26
- [PATCH V9 23/46] cpr: add exec-mode blockers, Steve Sistare, 2022/07/26
- [PATCH V9 09/46] cpr: reboot mode, Steve Sistare, 2022/07/26