thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-migration-Allow-migrate-recover-to-run-multiple-time.patch

0727d3
From f5be3d8a5944679c1239b974e0f910f1afe4f532 Mon Sep 17 00:00:00 2001
0727d3
From: Peter Xu <peterx@redhat.com>
0727d3
Date: Thu, 31 Mar 2022 11:08:45 -0400
0727d3
Subject: [PATCH 28/37] migration: Allow migrate-recover to run multiple times
0727d3
MIME-Version: 1.0
0727d3
Content-Type: text/plain; charset=UTF-8
0727d3
Content-Transfer-Encoding: 8bit
0727d3
0727d3
RH-Author: Peter Xu <peterx@redhat.com>
0727d3
RH-MergeRequest: 195: migration: Allow migrate-recover to run multiple times
0727d3
RH-Commit: [2/2] a2e6b02007a06c9c7f5237289095811c7d7ca1f1
0727d3
RH-Bugzilla: 2097652
0727d3
RH-Acked-by: Leonardo Brás <leobras@redhat.com>
0727d3
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
0727d3
0727d3
Previously migration didn't have an easy way to cleanup the listening
0727d3
transport, migrate recovery only allows to execute once.  That's done with a
0727d3
trick flag in postcopy_recover_triggered.
0727d3
0727d3
Now the facility is already there.
0727d3
0727d3
Drop postcopy_recover_triggered and instead allows a new migrate-recover to
0727d3
release the previous listener transport.
0727d3
0727d3
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
Signed-off-by: Peter Xu <peterx@redhat.com>
0727d3
Message-Id: <20220331150857.74406-8-peterx@redhat.com>
0727d3
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
0727d3
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
(cherry picked from commit 08401c0426bc1a5ce4609afd1cda5dd39abbf9fa)
0727d3
Signed-off-by: Peter Xu <peterx@redhat.com>
0727d3
---
0727d3
 migration/migration.c | 13 ++-----------
0727d3
 migration/migration.h |  1 -
0727d3
 migration/savevm.c    |  3 ---
0727d3
 3 files changed, 2 insertions(+), 15 deletions(-)
0727d3
0727d3
diff --git a/migration/migration.c b/migration/migration.c
0727d3
index b787a36789..616c3ff32e 100644
0727d3
--- a/migration/migration.c
0727d3
+++ b/migration/migration.c
0727d3
@@ -2158,11 +2158,8 @@ void qmp_migrate_recover(const char *uri, Error **errp)
0727d3
         return;
0727d3
     }
0727d3
 
0727d3
-    if (qatomic_cmpxchg(&mis->postcopy_recover_triggered,
0727d3
-                       false, true) == true) {
0727d3
-        error_setg(errp, "Migrate recovery is triggered already");
0727d3
-        return;
0727d3
-    }
0727d3
+    /* If there's an existing transport, release it */
0727d3
+    migration_incoming_transport_cleanup(mis);
0727d3
 
0727d3
     /*
0727d3
      * Note that this call will never start a real migration; it will
0727d3
@@ -2170,12 +2167,6 @@ void qmp_migrate_recover(const char *uri, Error **errp)
0727d3
      * to continue using that newly established channel.
0727d3
      */
0727d3
     qemu_start_incoming_migration(uri, errp);
0727d3
-
0727d3
-    /* Safe to dereference with the assert above */
0727d3
-    if (*errp) {
0727d3
-        /* Reset the flag so user could still retry */
0727d3
-        qatomic_set(&mis->postcopy_recover_triggered, false);
0727d3
-    }
0727d3
 }
0727d3
 
0727d3
 void qmp_migrate_pause(Error **errp)
0727d3
diff --git a/migration/migration.h b/migration/migration.h
0727d3
index 243898e3be..0ae2133326 100644
0727d3
--- a/migration/migration.h
0727d3
+++ b/migration/migration.h
0727d3
@@ -103,7 +103,6 @@ struct MigrationIncomingState {
0727d3
     struct PostcopyBlocktimeContext *blocktime_ctx;
0727d3
 
0727d3
     /* notify PAUSED postcopy incoming migrations to try to continue */
0727d3
-    bool postcopy_recover_triggered;
0727d3
     QemuSemaphore postcopy_pause_sem_dst;
0727d3
     QemuSemaphore postcopy_pause_sem_fault;
0727d3
 
0727d3
diff --git a/migration/savevm.c b/migration/savevm.c
0727d3
index 0bef031acb..b8382aaa64 100644
0727d3
--- a/migration/savevm.c
0727d3
+++ b/migration/savevm.c
0727d3
@@ -2568,9 +2568,6 @@ static bool postcopy_pause_incoming(MigrationIncomingState *mis)
0727d3
 
0727d3
     assert(migrate_postcopy_ram());
0727d3
 
0727d3
-    /* Clear the triggered bit to allow one recovery */
0727d3
-    mis->postcopy_recover_triggered = false;
0727d3
-
0727d3
     /*
0727d3
      * Unregister yank with either from/to src would work, since ioc behind it
0727d3
      * is the same
0727d3
-- 
0727d3
2.35.3
0727d3