cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From d54fad56d67682c441b6e79a14df9ab9867a7b21 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <d54fad56d67682c441b6e79a14df9ab9867a7b21.1387382496.git.minovotn@redhat.com>
0a122b
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
From: Nigel Croxon <ncroxon@redhat.com>
0a122b
Date: Thu, 14 Nov 2013 22:53:12 +0100
0a122b
Subject: [PATCH 36/46] rdma: clean up of qemu_rdma_cleanup()
0a122b
0a122b
RH-Author: Nigel Croxon <ncroxon@redhat.com>
0a122b
Message-id: <1384469598-13137-37-git-send-email-ncroxon@redhat.com>
0a122b
Patchwork-id: 55726
0a122b
O-Subject: [RHEL7.0 PATCH 36/42] rdma: clean up of qemu_rdma_cleanup()
0a122b
Bugzilla: 1011720
0a122b
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
0a122b
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
0a122b
Bugzilla: 1011720
0a122b
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
0a122b
0a122b
>From commit ID:
0a122b
commit 5a91337cdf343b94474f8bbecab85a8c00f6d2a1
0a122b
Author: Isaku Yamahata <yamahata@private.email.ne.jp>
0a122b
Date:   Tue Aug 13 11:12:43 2013 +0900
0a122b
0a122b
    rdma: clean up of qemu_rdma_cleanup()
0a122b
0a122b
    - It can't be determined by RDMAContext::cm_id != NULL if the connection
0a122b
      is established or not.
0a122b
    - RDMAContext::cm_id is leaked and not destroyed because it is set to NULL
0a122b
      too early.
0a122b
    - RDMAContext::qp is created by rdma_create_qp() so that it should be destroyed
0a122b
      by rdma_destroy_qp(). not ibv_destroy_qp()
0a122b
0a122b
    Cc: Michael R. Hines <mrhines@us.ibm.com>
0a122b
    Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
0a122b
    Signed-off-by: Juan Quintela <quintela@redhat.com>
0a122b
---
0a122b
 migration-rdma.c |    9 ++++++---
0a122b
 1 files changed, 6 insertions(+), 3 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 migration-rdma.c | 9 ++++++---
0a122b
 1 file changed, 6 insertions(+), 3 deletions(-)
0a122b
0a122b
diff --git a/migration-rdma.c b/migration-rdma.c
0a122b
index 943496f..be3d984 100644
0a122b
--- a/migration-rdma.c
0a122b
+++ b/migration-rdma.c
0a122b
@@ -356,6 +356,7 @@ typedef struct RDMAContext {
0a122b
      */
0a122b
     struct rdma_cm_id *cm_id;               /* connection manager ID */
0a122b
     struct rdma_cm_id *listen_id;
0a122b
+    bool connected;
0a122b
 
0a122b
     struct ibv_context          *verbs;
0a122b
     struct rdma_event_channel   *channel;
0a122b
@@ -2194,7 +2195,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
0a122b
     struct rdma_cm_event *cm_event;
0a122b
     int ret, idx;
0a122b
 
0a122b
-    if (rdma->cm_id) {
0a122b
+    if (rdma->cm_id && rdma->connected) {
0a122b
         if (rdma->error_state) {
0a122b
             RDMAControlHeader head = { .len = 0,
0a122b
                                        .type = RDMA_CONTROL_ERROR,
0a122b
@@ -2213,7 +2214,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
0a122b
             }
0a122b
         }
0a122b
         DDPRINTF("Disconnected.\n");
0a122b
-        rdma->cm_id = NULL;
0a122b
+        rdma->connected = false;
0a122b
     }
0a122b
 
0a122b
     g_free(rdma->block);
0a122b
@@ -2235,7 +2236,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
0a122b
     }
0a122b
 
0a122b
     if (rdma->qp) {
0a122b
-        ibv_destroy_qp(rdma->qp);
0a122b
+        rdma_destroy_qp(rdma->cm_id);
0a122b
         rdma->qp = NULL;
0a122b
     }
0a122b
     if (rdma->cq) {
0a122b
@@ -2372,6 +2373,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
0a122b
         rdma->cm_id = NULL;
0a122b
         goto err_rdma_source_connect;
0a122b
     }
0a122b
+    rdma->connected = true;
0a122b
 
0a122b
     memcpy(&cap, cm_event->param.conn.private_data, sizeof(cap));
0a122b
     network_to_caps(&cap);
0a122b
@@ -2906,6 +2908,7 @@ static int qemu_rdma_accept(RDMAContext *rdma)
0a122b
     }
0a122b
 
0a122b
     rdma_ack_cm_event(cm_event);
0a122b
+    rdma->connected = true;
0a122b
 
0a122b
     ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
0a122b
     if (ret) {
0a122b
-- 
0a122b
1.7.11.7
0a122b