diff mbox series

[RFC,14/14] migration/rdma: RDMA cleanup for multifd migration

Message ID 20200213093755.370-15-fengzhimin1@huawei.com (mailing list archive)
State New, archived
Headers show
Series *** multifd for RDMA v2 *** | expand

Commit Message

fengzhimin Feb. 13, 2020, 9:37 a.m. UTC
Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>
---
 migration/multifd.c | 6 ++++++
 migration/rdma.c    | 5 ++---
 migration/rdma.h    | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/migration/multifd.c b/migration/multifd.c
index ba5e0b11d0..886c8e1271 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -429,6 +429,9 @@  void multifd_save_cleanup(void)
         g_free(p->packet);
         p->packet = NULL;
         if (migrate_use_rdma()) {
+            p->rdma->listen_id = NULL;
+            p->rdma->channel = NULL;
+            qemu_rdma_cleanup(p->rdma);
             g_free(p->rdma);
         }
     }
@@ -835,6 +838,9 @@  int multifd_load_cleanup(Error **errp)
         g_free(p->packet);
         p->packet = NULL;
         if (migrate_use_rdma()) {
+            p->rdma->listen_id = NULL;
+            p->rdma->channel = NULL;
+            qemu_rdma_cleanup(p->rdma);
             g_free(p->rdma);
         }
     }
diff --git a/migration/rdma.c b/migration/rdma.c
index b7b56c0493..0a48713d03 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -2096,11 +2096,11 @@  static int qemu_rdma_write(QEMUFile *f, RDMAContext *rdma,
     return 0;
 }
 
-static void qemu_rdma_cleanup(RDMAContext *rdma)
+void qemu_rdma_cleanup(RDMAContext *rdma)
 {
     int idx;
 
-    if (rdma->cm_id && rdma->connected) {
+    if (rdma->channel && rdma->cm_id && rdma->connected) {
         if ((rdma->error_state ||
              migrate_get_current()->state == MIGRATION_STATUS_CANCELLING) &&
             !rdma->received_error) {
@@ -2181,7 +2181,6 @@  static void qemu_rdma_cleanup(RDMAContext *rdma)
     rdma->host = NULL;
 }
 
-
 static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **errp)
 {
     int ret, idx;
diff --git a/migration/rdma.h b/migration/rdma.h
index 7dc3895698..b78f79ddc2 100644
--- a/migration/rdma.h
+++ b/migration/rdma.h
@@ -283,6 +283,7 @@  int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,
 int qemu_rdma_registration(void *opaque);
 int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested,
                              uint32_t *byte_len);
+void qemu_rdma_cleanup(RDMAContext *rdma);
 
 void rdma_start_outgoing_migration(void *opaque, const char *host_port,
                                    Error **errp);