yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-migration-Move-yank-outside-qemu_start_incoming_migr.patch

a83cc2
From 4c11e06222ca5a88f48f2d47adc3a7da306bb345 Mon Sep 17 00:00:00 2001
a83cc2
From: Peter Xu <peterx@redhat.com>
a83cc2
Date: Tue, 29 Jun 2021 14:13:55 -0400
a83cc2
Subject: [PATCH 01/39] migration: Move yank outside
a83cc2
 qemu_start_incoming_migration()
a83cc2
MIME-Version: 1.0
a83cc2
Content-Type: text/plain; charset=UTF-8
a83cc2
Content-Transfer-Encoding: 8bit
a83cc2
a83cc2
RH-Author: Leonardo BrĂ¡s <leobras@redhat.com>
a83cc2
RH-MergeRequest: 25: migration: Move yank outside qemu_start_incoming_migration()
a83cc2
RH-Commit: [1/2] e5694b0ae9a55f6b147c336e86fce6f4f2163db6 (LeoBras/centos-qemu-kvm)
a83cc2
RH-Bugzilla: 1974683
a83cc2
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
RH-Acked-by: Peter Xu <Peter Xu <peterx@redhat.com>>
a83cc2
a83cc2
Starting from commit b5eea99ec2f5c, qmp_migrate_recover() calls unregister
a83cc2
before calling qemu_start_incoming_migration(). I believe it wanted to mitigate
a83cc2
the next call to yank_register_instance(), but I think that's wrong.
a83cc2
a83cc2
Firstly, if during recover, we should keep the yank instance there, not
a83cc2
"quickly removing and adding it back".
a83cc2
a83cc2
Meanwhile, calling qmp_migrate_recover() twice with b5eea99ec2f5c will directly
a83cc2
crash the dest qemu (right now it can't; but it'll start to work right after
a83cc2
the next patch) because the 1st call of qmp_migrate_recover() will unregister
a83cc2
permanently when the channel failed to establish, then the 2nd call of
a83cc2
qmp_migrate_recover() crashes at yank_unregister_instance().
a83cc2
a83cc2
This patch fixes it by moving yank ops out of qemu_start_incoming_migration()
a83cc2
into qmp_migrate_incoming.  For qmp_migrate_recover(), drop the unregister of
a83cc2
yank instance too since we keep it there during the recovery phase.
a83cc2
a83cc2
Signed-off-by: Peter Xu <peterx@redhat.com>
a83cc2
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
a83cc2
Message-Id: <20210629181356.217312-2-peterx@redhat.com>
a83cc2
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
a83cc2
(cherry picked from commit cc48c587d25ff5dd7dddb4e5072de9ca8464c832)
a83cc2
Fixes: b5eea99e ("migration: Add yank feature", 2021-01-13)
a83cc2
Signed-off-by: Leonardo Bras <leobras@redhat.com>
a83cc2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
---
a83cc2
 migration/migration.c | 11 +++++------
a83cc2
 1 file changed, 5 insertions(+), 6 deletions(-)
a83cc2
a83cc2
diff --git a/migration/migration.c b/migration/migration.c
a83cc2
index 4afc6069b6..f077640df2 100644
a83cc2
--- a/migration/migration.c
a83cc2
+++ b/migration/migration.c
a83cc2
@@ -454,10 +454,6 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
a83cc2
 {
a83cc2
     const char *p = NULL;
a83cc2
 
a83cc2
-    if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) {
a83cc2
-        return;
a83cc2
-    }
a83cc2
-
a83cc2
     qapi_event_send_migration(MIGRATION_STATUS_SETUP);
a83cc2
     if (strstart(uri, "tcp:", &p) ||
a83cc2
         strstart(uri, "unix:", NULL) ||
a83cc2
@@ -472,7 +468,6 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
a83cc2
     } else if (strstart(uri, "fd:", &p)) {
a83cc2
         fd_start_incoming_migration(p, errp);
a83cc2
     } else {
a83cc2
-        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
a83cc2
         error_setg(errp, "unknown migration protocol: %s", uri);
a83cc2
     }
a83cc2
 }
a83cc2
@@ -2095,9 +2090,14 @@ void qmp_migrate_incoming(const char *uri, Error **errp)
a83cc2
         return;
a83cc2
     }
a83cc2
 
a83cc2
+    if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) {
a83cc2
+        return;
a83cc2
+    }
a83cc2
+
a83cc2
     qemu_start_incoming_migration(uri, &local_err);
a83cc2
 
a83cc2
     if (local_err) {
a83cc2
+        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
a83cc2
         error_propagate(errp, local_err);
a83cc2
         return;
a83cc2
     }
a83cc2
@@ -2126,7 +2126,6 @@ void qmp_migrate_recover(const char *uri, Error **errp)
a83cc2
      * only re-setup the migration stream and poke existing migration
a83cc2
      * to continue using that newly established channel.
a83cc2
      */
a83cc2
-    yank_unregister_instance(MIGRATION_YANK_INSTANCE);
a83cc2
     qemu_start_incoming_migration(uri, errp);
a83cc2
 }
a83cc2
 
a83cc2
-- 
a83cc2
2.27.0
a83cc2