thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-migration-Add-migration_incoming_transport_cleanup.patch

0727d3
From 02eab793d82cd3c82d31f1e1f34d16fcc30caf0e Mon Sep 17 00:00:00 2001
0727d3
From: Peter Xu <peterx@redhat.com>
0727d3
Date: Tue, 1 Mar 2022 16:39:14 +0800
0727d3
Subject: [PATCH 27/37] migration: Add migration_incoming_transport_cleanup()
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: [1/2] 57b2a9a165ee7cb2d01519bd54eb8dc4185815e0
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
Add a helper to cleanup the transport listener.
0727d3
0727d3
When do it, we should also null-ify the cleanup hook and the data, then it's
0727d3
even safe to call it multiple times.
0727d3
0727d3
Move the socket_address_list cleanup altogether, because that's a mirror of the
0727d3
listener channels and only for the purpose of query-migrate.  Hence when
0727d3
someone wants to cleanup the listener transport, it should also want to cleanup
0727d3
the socket list too, always.
0727d3
0727d3
No functional change intended.
0727d3
0727d3
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
Signed-off-by: Peter Xu <peterx@redhat.com>
0727d3
Message-Id: <20220301083925.33483-15-peterx@redhat.com>
0727d3
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
(cherry picked from commit e031149c78489413038e934eec9f54ac699cf322)
0727d3
Signed-off-by: Peter Xu <peterx@redhat.com>
0727d3
---
0727d3
 migration/migration.c | 22 ++++++++++++++--------
0727d3
 migration/migration.h |  1 +
0727d3
 2 files changed, 15 insertions(+), 8 deletions(-)
0727d3
0727d3
diff --git a/migration/migration.c b/migration/migration.c
0727d3
index c8aa55d2fe..b787a36789 100644
0727d3
--- a/migration/migration.c
0727d3
+++ b/migration/migration.c
0727d3
@@ -263,6 +263,19 @@ MigrationIncomingState *migration_incoming_get_current(void)
0727d3
     return current_incoming;
0727d3
 }
0727d3
 
0727d3
+void migration_incoming_transport_cleanup(MigrationIncomingState *mis)
0727d3
+{
0727d3
+    if (mis->socket_address_list) {
0727d3
+        qapi_free_SocketAddressList(mis->socket_address_list);
0727d3
+        mis->socket_address_list = NULL;
0727d3
+    }
0727d3
+
0727d3
+    if (mis->transport_cleanup) {
0727d3
+        mis->transport_cleanup(mis->transport_data);
0727d3
+        mis->transport_data = mis->transport_cleanup = NULL;
0727d3
+    }
0727d3
+}
0727d3
+
0727d3
 void migration_incoming_state_destroy(void)
0727d3
 {
0727d3
     struct MigrationIncomingState *mis = migration_incoming_get_current();
0727d3
@@ -283,10 +296,8 @@ void migration_incoming_state_destroy(void)
0727d3
         g_array_free(mis->postcopy_remote_fds, TRUE);
0727d3
         mis->postcopy_remote_fds = NULL;
0727d3
     }
0727d3
-    if (mis->transport_cleanup) {
0727d3
-        mis->transport_cleanup(mis->transport_data);
0727d3
-    }
0727d3
 
0727d3
+    migration_incoming_transport_cleanup(mis);
0727d3
     qemu_event_reset(&mis->main_thread_load_event);
0727d3
 
0727d3
     if (mis->page_requested) {
0727d3
@@ -294,11 +305,6 @@ void migration_incoming_state_destroy(void)
0727d3
         mis->page_requested = NULL;
0727d3
     }
0727d3
 
0727d3
-    if (mis->socket_address_list) {
0727d3
-        qapi_free_SocketAddressList(mis->socket_address_list);
0727d3
-        mis->socket_address_list = NULL;
0727d3
-    }
0727d3
-
0727d3
     yank_unregister_instance(MIGRATION_YANK_INSTANCE);
0727d3
 }
0727d3
 
0727d3
diff --git a/migration/migration.h b/migration/migration.h
0727d3
index 9396b7e90a..243898e3be 100644
0727d3
--- a/migration/migration.h
0727d3
+++ b/migration/migration.h
0727d3
@@ -130,6 +130,7 @@ struct MigrationIncomingState {
0727d3
 
0727d3
 MigrationIncomingState *migration_incoming_get_current(void);
0727d3
 void migration_incoming_state_destroy(void);
0727d3
+void migration_incoming_transport_cleanup(MigrationIncomingState *mis);
0727d3
 /*
0727d3
  * Functions to work with blocktime context
0727d3
  */
0727d3
-- 
0727d3
2.35.3
0727d3