diff mbox series

[v2,5/9] migration: Reject qmp_migrate_cancel after postcopy

Message ID 20250211150136.6781-6-farosas@suse.de (mailing list archive)
State New
Headers show
Series migration: Fix issues during qmp_migrate_cancel | expand

Commit Message

Fabiano Rosas Feb. 11, 2025, 3:01 p.m. UTC
After postcopy has started, it's not possible to recover the source
machine in case a migration error occurs because the destination has
already been changing the state of the machine. For that same reason,
it doesn't make sense to try to cancel the migration after postcopy
has started. Reject the cancel command during postcopy.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/migration.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Peter Xu Feb. 11, 2025, 5:34 p.m. UTC | #1
On Tue, Feb 11, 2025 at 12:01:32PM -0300, Fabiano Rosas wrote:
> After postcopy has started, it's not possible to recover the source
> machine in case a migration error occurs because the destination has
> already been changing the state of the machine. For that same reason,
> it doesn't make sense to try to cancel the migration after postcopy
> has started. Reject the cancel command during postcopy.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>

Reviewed-by: Peter Xu <peterx@redhat.com>
diff mbox series

Patch

diff --git a/migration/migration.c b/migration/migration.c
index db8d6e8ea7..375de6d460 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2251,7 +2251,18 @@  static void qmp_migrate_finish(MigrationAddress *addr, bool resume_requested,
 
 void qmp_migrate_cancel(Error **errp)
 {
-    migration_cancel(NULL);
+    /*
+     * After postcopy migration has started, the source machine is not
+     * recoverable in case of a migration error. This also means the
+     * cancel command cannot be used as cancel should allow the
+     * machine to continue operation.
+     */
+    if (migration_in_postcopy()) {
+        error_setg(errp, "Postcopy migration in progress, cannot cancel.");
+        return;
+    }
+
+    migration_cancel();
 }
 
 void qmp_migrate_continue(MigrationStatus state, Error **errp)