From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCVrZ-00086g-V6 for qemu-devel@nongnu.org; Thu, 22 Aug 2013 10:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCVrR-0004Bh-W0 for qemu-devel@nongnu.org; Thu, 22 Aug 2013 10:27:49 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:49895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCVrR-0004BK-Q3 for qemu-devel@nongnu.org; Thu, 22 Aug 2013 10:27:41 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Aug 2013 08:27:38 -0600 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 5CA9E1FF001C for ; Thu, 22 Aug 2013 08:22:05 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7MERL8E161856 for ; Thu, 22 Aug 2013 08:27:28 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r7MERKvP019890 for ; Thu, 22 Aug 2013 08:27:20 -0600 Message-ID: <52161FC7.5030806@linux.vnet.ibm.com> Date: Thu, 22 Aug 2013 10:27:19 -0400 From: "Michael R. Hines" MIME-Version: 1.0 References: <1f3a31a10f23b1dfafc4e178d6a4b0f07e384700.1376359935.git.yamahata@private.email.ne.jp> In-Reply-To: <1f3a31a10f23b1dfafc4e178d6a4b0f07e384700.1376359935.git.yamahata@private.email.ne.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] rdma: clean up of qemu_rdma_cleanup() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: owasserm@redhat.com, quintela@redhat.com, mrhines@us.ibm.com, qemu-devel@nongnu.org, pbonzini@redhat.com On 08/12/2013 10:12 PM, Isaku Yamahata wrote: > - It can't be determined by RDMAContext::cm_id != NULL if the connection > is established or not. > - RDMAContext::cm_id is leaked and not destroyed because it is set to NULL > too early. > - RDMAContext::qp is created by rdma_create_qp() so that it should be destroyed > by rdma_destroy_qp(). not ibv_destroy_qp() > > Cc: Michael R. Hines > Signed-off-by: Isaku Yamahata > --- > migration-rdma.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/migration-rdma.c b/migration-rdma.c > index 3d1266f..e71c10a 100644 > --- a/migration-rdma.c > +++ b/migration-rdma.c > @@ -356,6 +356,7 @@ typedef struct RDMAContext { > */ > struct rdma_cm_id *cm_id; /* connection manager ID */ > struct rdma_cm_id *listen_id; > + bool connected; > > struct ibv_context *verbs; > struct rdma_event_channel *channel; > @@ -2192,7 +2193,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) > struct rdma_cm_event *cm_event; > int ret, idx; > > - if (rdma->cm_id) { > + if (rdma->cm_id && rdma->connected) { > if (rdma->error_state) { > RDMAControlHeader head = { .len = 0, > .type = RDMA_CONTROL_ERROR, > @@ -2211,7 +2212,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) > } > } > DDPRINTF("Disconnected.\n"); > - rdma->cm_id = NULL; > + rdma->connected = false; > } > > g_free(rdma->block); > @@ -2233,7 +2234,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) > } > > if (rdma->qp) { > - ibv_destroy_qp(rdma->qp); > + rdma_destroy_qp(rdma->cm_id); > rdma->qp = NULL; > } > if (rdma->cq) { > @@ -2370,6 +2371,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) > rdma->cm_id = NULL; > goto err_rdma_source_connect; > } > + rdma->connected = true; > > memcpy(&cap, cm_event->param.conn.private_data, sizeof(cap)); > network_to_caps(&cap); > @@ -2904,6 +2906,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) > } > > rdma_ack_cm_event(cm_event); > + rdma->connected = true; > > ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); > if (ret) { I have applied this to my tree. Thanks. - Michael