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

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