diff mbox series

[1/2] migration: provide an error message to migration_cancel()

Message ID 20210929144311.1168561-2-lvivier@redhat.com (mailing list archive)
State New, archived
Headers show
Series failover: don't allow to migrate a paused VM that needs PCI unplug | expand

Commit Message

Laurent Vivier Sept. 29, 2021, 2:43 p.m. UTC
This avoids to call migrate_get_current() in the caller function
whereas migration_cancel() already needs the pointer to the current
migration state.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 migration/migration.h | 2 +-
 migration/migration.c | 9 ++++++---
 migration/ram.c       | 3 +--
 3 files changed, 8 insertions(+), 6 deletions(-)

Comments

Juan Quintela Nov. 2, 2021, 9:04 a.m. UTC | #1
Laurent Vivier <lvivier@redhat.com> wrote:
> This avoids to call migrate_get_current() in the caller function
> whereas migration_cancel() already needs the pointer to the current
> migration state.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

queued.


>          error_setg(&err, "RAM block '%s' resized during precopy.", rb->idstr);
> -        migrate_set_error(migrate_get_current(), err);
> +        migration_cancel(err);
>          error_free(err);
> -        migration_cancel();

This was already there, but it is ugly, isn't it?

Later, Juan.
diff mbox series

Patch

diff --git a/migration/migration.h b/migration/migration.h
index 7a5aa8c2fdde..8130b703eb95 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -388,7 +388,7 @@  int foreach_not_ignored_block(RAMBlockIterFunc func, void *opaque);
 void migration_make_urgent_request(void);
 void migration_consume_urgent_request(void);
 bool migration_rate_limit(void);
-void migration_cancel(void);
+void migration_cancel(const Error *error);
 
 void populate_vfio_info(MigrationInfo *info);
 
diff --git a/migration/migration.c b/migration/migration.c
index bb909781b7f5..565cbc859744 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -215,8 +215,11 @@  void migration_object_init(void)
     dirty_bitmap_mig_init();
 }
 
-void migration_cancel(void)
+void migration_cancel(const Error *error)
 {
+    if (error) {
+        migrate_set_error(current_migration, error);
+    }
     migrate_fd_cancel(current_migration);
 }
 
@@ -226,7 +229,7 @@  void migration_shutdown(void)
      * Cancel the current migration - that will (eventually)
      * stop the migration using this structure
      */
-    migration_cancel();
+    migration_cancel(NULL);
     object_unref(OBJECT(current_migration));
 
     /*
@@ -2316,7 +2319,7 @@  void qmp_migrate(const char *uri, bool has_blk, bool blk,
 
 void qmp_migrate_cancel(Error **errp)
 {
-    migration_cancel();
+    migration_cancel(NULL);
 }
 
 void qmp_migrate_continue(MigrationStatus state, Error **errp)
diff --git a/migration/ram.c b/migration/ram.c
index 7a43bfd7afcb..50809b59ee70 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -4178,9 +4178,8 @@  static void ram_mig_ram_block_resized(RAMBlockNotifier *n, void *host,
          * Abort and indicate a proper reason.
          */
         error_setg(&err, "RAM block '%s' resized during precopy.", rb->idstr);
-        migrate_set_error(migrate_get_current(), err);
+        migration_cancel(err);
         error_free(err);
-        migration_cancel();
     }
 
     switch (ps) {