958e1b
From 41048b716132906fe54b6dbca48421a24f78affb Mon Sep 17 00:00:00 2001
958e1b
From: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
958e1b
Date: Fri, 11 Jul 2014 09:05:28 +0200
958e1b
Subject: [PATCH 01/11] rdma: bug fixes
958e1b
958e1b
Message-id: <1405069528-20466-2-git-send-email-dgilbert@redhat.com>
958e1b
Patchwork-id: 59778
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 1/1] rdma: bug fixes
958e1b
Bugzilla: 1107821
958e1b
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
958e1b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
958e1b
958e1b
From: "Michael R. Hines" <mrhines@us.ibm.com>
958e1b
958e1b
1. Fix small memory leak in parsing inet address from command line in data_init()
958e1b
2. Fix ibv_post_send() return value check and pass error code back up correctly.
958e1b
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.
958e1b
958e1b
Reported-by: frank.yangjie@gmail.com
958e1b
Reported-by: dgilbert@redhat.com
958e1b
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
958e1b
Signed-off-by: Juan Quintela <quintela@redhat.com>
958e1b
(cherry picked from commit e325b49a320b493cc5d69e263751ff716dc458fe)
958e1b
---
958e1b
 migration-rdma.c | 20 ++++++++++----------
958e1b
 1 file changed, 10 insertions(+), 10 deletions(-)
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 migration-rdma.c |   20 ++++++++++----------
958e1b
 1 files changed, 10 insertions(+), 10 deletions(-)
958e1b
958e1b
diff --git a/migration-rdma.c b/migration-rdma.c
958e1b
index f79be20..ba4ad76 100644
958e1b
--- a/migration-rdma.c
958e1b
+++ b/migration-rdma.c
958e1b
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
958e1b
     }
958e1b
 
958e1b
 
958e1b
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
958e1b
-        return -1;
958e1b
-    }
958e1b
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
958e1b
 
958e1b
-    if (ret < 0) {
958e1b
+    if (ret > 0) {
958e1b
         fprintf(stderr, "Failed to use post IB SEND for control!\n");
958e1b
-        return ret;
958e1b
+        return -ret;
958e1b
     }
958e1b
 
958e1b
     ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
958e1b
@@ -2237,10 +2235,6 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
958e1b
         }
958e1b
     }
958e1b
 
958e1b
-    if (rdma->qp) {
958e1b
-        rdma_destroy_qp(rdma->cm_id);
958e1b
-        rdma->qp = NULL;
958e1b
-    }
958e1b
     if (rdma->cq) {
958e1b
         ibv_destroy_cq(rdma->cq);
958e1b
         rdma->cq = NULL;
958e1b
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
958e1b
         rdma->listen_id = NULL;
958e1b
     }
958e1b
     if (rdma->cm_id) {
958e1b
+        if (rdma->qp) {
958e1b
+            rdma_destroy_qp(rdma->cm_id);
958e1b
+            rdma->qp = NULL;
958e1b
+        }
958e1b
         rdma_destroy_id(rdma->cm_id);
958e1b
         rdma->cm_id = NULL;
958e1b
     }
958e1b
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
958e1b
         } else {
958e1b
             ERROR(errp, "bad RDMA migration address '%s'", host_port);
958e1b
             g_free(rdma);
958e1b
-            return NULL;
958e1b
+            rdma = NULL;
958e1b
         }
958e1b
+
958e1b
+        qapi_free_InetSocketAddress(addr);
958e1b
     }
958e1b
 
958e1b
     return rdma;
958e1b
-- 
958e1b
1.7.1
958e1b