From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb92t-0002g2-T8 for qemu-devel@nongnu.org; Thu, 26 Mar 2015 10:46:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yb92s-0005dC-JZ for qemu-devel@nongnu.org; Thu, 26 Mar 2015 10:46:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb92s-0005cw-AD for qemu-devel@nongnu.org; Thu, 26 Mar 2015 10:46:06 -0400 From: Juan Quintela Date: Thu, 26 Mar 2015 15:45:57 +0100 Message-Id: <1427381158-9069-3-git-send-email-quintela@redhat.com> In-Reply-To: <1427381158-9069-1-git-send-email-quintela@redhat.com> References: <1427381158-9069-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PULL 2/3] rdma: Fix cleanup in error paths List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Padmanabh Ratnakar , Meghana Cheripady From: Padmanabh Ratnakar As part of commit e325b49a320b493cc5d69e263751ff716dc458fe, order in which resources are destroyed was changed for fixing a seg fault. Due to this change, CQ will never get destroyed as CQ should be destroyed after QP destruction. Seg fault is caused improper cleanup when connection fails. Fixing cleanup after connection failure and order in which resources are destroyed in qemu_rdma_cleanup() routine. Signed-off-by: Meghana Cheripady Signed-off-by: Padmanabh Ratnakar Signed-off-by: Juan Quintela --- migration/rdma.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index e6c3a67..77e3444 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2194,6 +2194,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) } } + if (rdma->qp) { + rdma_destroy_qp(rdma->cm_id); + rdma->qp = NULL; + } if (rdma->cq) { ibv_destroy_cq(rdma->cq); rdma->cq = NULL; @@ -2206,18 +2210,14 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) ibv_dealloc_pd(rdma->pd); rdma->pd = NULL; } - if (rdma->listen_id) { - rdma_destroy_id(rdma->listen_id); - rdma->listen_id = NULL; - } if (rdma->cm_id) { - if (rdma->qp) { - rdma_destroy_qp(rdma->cm_id); - rdma->qp = NULL; - } rdma_destroy_id(rdma->cm_id); rdma->cm_id = NULL; } + if (rdma->listen_id) { + rdma_destroy_id(rdma->listen_id); + rdma->listen_id = NULL; + } if (rdma->channel) { rdma_destroy_event_channel(rdma->channel); rdma->channel = NULL; @@ -2309,8 +2309,6 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) if (ret) { perror("rdma_connect"); ERROR(errp, "connecting to destination!"); - rdma_destroy_id(rdma->cm_id); - rdma->cm_id = NULL; goto err_rdma_source_connect; } @@ -2319,8 +2317,6 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) perror("rdma_get_cm_event after rdma_connect"); ERROR(errp, "connecting to destination!"); rdma_ack_cm_event(cm_event); - rdma_destroy_id(rdma->cm_id); - rdma->cm_id = NULL; goto err_rdma_source_connect; } @@ -2328,8 +2324,6 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) perror("rdma_get_cm_event != EVENT_ESTABLISHED after rdma_connect"); ERROR(errp, "connecting to destination!"); rdma_ack_cm_event(cm_event); - rdma_destroy_id(rdma->cm_id); - rdma->cm_id = NULL; goto err_rdma_source_connect; } rdma->connected = true; -- 2.1.0