qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] rdma: clean up of qemu_rdma_cleanup()
@ 2013-08-13  2:12 Isaku Yamahata
  2013-08-22 14:27 ` Michael R. Hines
  2013-09-18 13:02 ` Juan Quintela
  0 siblings, 2 replies; 3+ messages in thread
From: Isaku Yamahata @ 2013-08-13  2:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: owasserm, pbonzini, mrhines, quintela

- 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 <mrhines@us.ibm.com>
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
---
 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) {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] rdma: clean up of qemu_rdma_cleanup()
  2013-08-13  2:12 [Qemu-devel] [PATCH] rdma: clean up of qemu_rdma_cleanup() Isaku Yamahata
@ 2013-08-22 14:27 ` Michael R. Hines
  2013-09-18 13:02 ` Juan Quintela
  1 sibling, 0 replies; 3+ messages in thread
From: Michael R. Hines @ 2013-08-22 14:27 UTC (permalink / raw)
  To: Isaku Yamahata; +Cc: owasserm, quintela, mrhines, qemu-devel, pbonzini

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 <mrhines@us.ibm.com>
> Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
> ---
>   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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] rdma: clean up of qemu_rdma_cleanup()
  2013-08-13  2:12 [Qemu-devel] [PATCH] rdma: clean up of qemu_rdma_cleanup() Isaku Yamahata
  2013-08-22 14:27 ` Michael R. Hines
@ 2013-09-18 13:02 ` Juan Quintela
  1 sibling, 0 replies; 3+ messages in thread
From: Juan Quintela @ 2013-09-18 13:02 UTC (permalink / raw)
  To: Isaku Yamahata; +Cc: owasserm, mrhines, qemu-devel, pbonzini

Isaku Yamahata <yamahata@private.email.ne.jp> 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 <mrhines@us.ibm.com>
> Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>

Reviewed-by: Juan Quintela <quintela@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-18 13:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-13  2:12 [Qemu-devel] [PATCH] rdma: clean up of qemu_rdma_cleanup() Isaku Yamahata
2013-08-22 14:27 ` Michael R. Hines
2013-09-18 13:02 ` Juan Quintela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).