From 4f719179546e9327cba3b74e86d2a403e36c5d71 Mon Sep 17 00:00:00 2001 From: Steve Sistare Date: Tue, 20 Aug 2024 05:36:15 -0700 Subject: [PATCH 1/2] migration: cpr setup notifier Add a cpr-setup notification point which is called before general setup. It is needed for resetting vhost devices, as explained in the next patch. Signed-off-by: Steve Sistare --- include/migration/misc.h | 7 ++++--- migration/migration.c | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index bcb6f35..bd05fe2 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,6 +60,7 @@ bool migration_thread_is_self(void); bool migration_is_setup_or_active(void); typedef enum MigrationEventType { + MIG_EVENT_PRECOPY_CPR_SETUP, MIG_EVENT_PRECOPY_SETUP, MIG_EVENT_PRECOPY_DONE, MIG_EVENT_PRECOPY_FAILED, @@ -71,9 +72,9 @@ typedef struct MigrationEvent { } MigrationEvent; /* - * A MigrationNotifyFunc may return an error code and an Error object, - * but only when @e->type is MIG_EVENT_PRECOPY_SETUP. The code is an int - * to allow for different failure modes and recovery actions. + * A MigrationNotifyFunc may return an error code and an Error object, but + * only when @e->type is MIG_EVENT_PRECOPY_SETUP or MIG_EVENT_PRECOPY_CPR_SETUP. + * The code is an int to allow for different failure modes and recovery actions. */ typedef int (*MigrationNotifyFunc)(NotifierWithReturn *notify, MigrationEvent *e, Error **errp); diff --git a/migration/migration.c b/migration/migration.c index 15ac8f5..8bc1975 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2201,7 +2201,12 @@ void qmp_migrate(const char *uri, bool has_channels, stopped = true; } + if (migration_call_notifiers(s, MIG_EVENT_PRECOPY_CPR_SETUP, &local_err)) { + goto out; + } + if (cpr_state_save(&local_err)) { + migration_call_notifiers(s, MIG_EVENT_PRECOPY_FAILED, NULL); goto out; } -- 1.8.3.1