Skip to contentSkip to conversation

rdma: bug fixes

PATCH Applied [email protected] 4 participants 9 messages Feb 18, 2014 – Jun 16, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rdma: bug fixes

From: "Michael R. Hines" <[email protected]>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

---
 migration-rdma.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
migration-rdma.c +10 -10
index f94f3b4..29351a6 100644
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
     }
 
 
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
 
-    if (ret < 0) {
+    if (ret > 0) {
         fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
     }
 
     ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2237,10 +2235,6 @@ 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;
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
         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;
     }
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
         } else {
             ERROR(errp, "bad RDMA migration address '%s'", host_port);
             g_free(rdma);
-            return NULL;
+            rdma = NULL;
         }
+
+        qapi_free_InetSocketAddress(addr);
     }
 
     return rdma;
Signature · 1 line
1.8.1.2
Reviewed-by on v1 1/1
#1 lore raw

Quoting [email protected] (2014-02-17 20:34:06)

Quoted 9 lines

From: "Michael R. Hines" <[email protected]>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

Quoted 61 lines
---
 migration-rdma.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
migration-rdma.c +10 -10
index f94f3b4..29351a6 100644
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
     }
 
 
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
 
-    if (ret < 0) {
+    if (ret > 0) {
         fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
     }
 
     ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2237,10 +2235,6 @@ 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;
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
         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;
     }
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
         } else {
             ERROR(errp, "bad RDMA migration address '%s'", host_port);
             g_free(rdma);
-            return NULL;
+            rdma = NULL;
         }
+
+        qapi_free_InetSocketAddress(addr);
     }
 
     return rdma;
Signature · 1 line
1.8.1.2
#2 lore raw
In reply to [email protected]

Quoting [email protected] (2014-02-17 20:34:06)

Quoted 9 lines

From: "Michael R. Hines" <[email protected]>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

Ping: last call for 1.7.1 (freeze today)

Quoted 61 lines
---
 migration-rdma.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
migration-rdma.c +10 -10
index f94f3b4..29351a6 100644
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
     }
 
 
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
 
-    if (ret < 0) {
+    if (ret > 0) {
         fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
     }
 
     ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2237,10 +2235,6 @@ 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;
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
         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;
     }
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
         } else {
             ERROR(errp, "bad RDMA migration address '%s'", host_port);
             g_free(rdma);
-            return NULL;
+            rdma = NULL;
         }
+
+        qapi_free_InetSocketAddress(addr);
     }
 
     return rdma;
Signature · 1 line
1.8.1.2
#3 lore raw

I think that's correct. It doesn't meet cold filter criteria.

Pelle

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Michael Roth
Sent: Thursday, February 27, 2014 10:49 AM
To: [email protected]; [email protected]
Cc: Michael R. Hines; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-stable] [PATCH] rdma: bug fixes

Quoting [email protected] (2014-02-17 20:34:06)

Quoted 9 lines

From: "Michael R. Hines" <[email protected]>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

Ping: last call for 1.7.1 (freeze today)

Quoted 61 lines
---
 migration-rdma.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
migration-rdma.c +10 -10
index f94f3b4..29351a6 100644
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
     }
 
 
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
 
-    if (ret < 0) {
+    if (ret > 0) {
         fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
     }
 
     ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2237,10 +2235,6 @@ 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;
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
         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;
     }
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
         } else {
             ERROR(errp, "bad RDMA migration address '%s'", host_port);
             g_free(rdma);
-            return NULL;
+            rdma = NULL;
         }
+
+        qapi_free_InetSocketAddress(addr);
     }
 
     return rdma;
Signature · 1 line
1.8.1.2
#4 lore raw

Quoting Wahlstrom, Pelle (2014-02-27 09:57:33)

Quoted 1 line

I think that's correct. It doesn't meet cold filter criteria.

Not sure I understand, what criteria are you referring to?

Quoted 84 lines

Pelle

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Michael Roth
Sent: Thursday, February 27, 2014 10:49 AM
To: [email protected]; [email protected]
Cc: Michael R. Hines; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-stable] [PATCH] rdma: bug fixes

Quoting [email protected] (2014-02-17 20:34:06)

Quoted 9 lines

From: "Michael R. Hines" <[email protected]>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

Ping: last call for 1.7.1 (freeze today)

Quoted 61 lines
---
 migration-rdma.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
migration-rdma.c +10 -10
index f94f3b4..29351a6 100644
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
     }
 
 
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
 
-    if (ret < 0) {
+    if (ret > 0) {
         fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
     }
 
     ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2237,10 +2235,6 @@ 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;
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
         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;
     }
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
         } else {
             ERROR(errp, "bad RDMA migration address '%s'", host_port);
             g_free(rdma);
-            return NULL;
+            rdma = NULL;
         }
+
+        qapi_free_InetSocketAddress(addr);
     }
 
     return rdma;
Signature · 1 line
1.8.1.2
#5 lore raw
In reply to Michael Roth
Quoted 11 lines · Michael Roth

Quoting [email protected] (2014-02-17 20:34:06)

Quoted 9 lines

From: "Michael R. Hines" <[email protected]>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

Ping: last call for 1.7.1 (freeze today)

Is this ping for me or the maintainer? Did I miss anything?

- Michael

Quoted 61 lines
Quoted 61 lines
---
  migration-rdma.c | 20 ++++++++++----------
  1 file changed, 10 insertions(+), 10 deletions(-)
migration-rdma.c +10 -10
index f94f3b4..29351a6 100644
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
      }
 
 
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
 
-    if (ret < 0) {
+    if (ret > 0) {
          fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
      }
 
      ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2237,10 +2235,6 @@ 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;
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
          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;
      }
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
          } else {
              ERROR(errp, "bad RDMA migration address '%s'", host_port);
              g_free(rdma);
-            return NULL;
+            rdma = NULL;
          }
+
+        qapi_free_InetSocketAddress(addr);
      }
 
      return rdma;
Signature · 1 line
1.8.1.2
#6 lore raw

Quoting Michael R. Hines (2014-03-26 22:14:27)

Quoted 8 lines · Michael Roth
Quoted 7 lines

Quoting [email protected] (2014-02-17 20:34:06)

Quoted 6 lines

From: "Michael R. Hines" <[email protected]>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Ping: last call for 1.7.1 (freeze today)

Is this ping for me or the maintainer? Did I miss anything?

Just a ping for the maintainers, to try to get it committed upstream prior to stable freeze. Ship has sailed for 1.7.1, but hopefully we can get it in for 1.7.2: ping :)

Quoted 64 lines

- Michael

Quoted 61 lines
Quoted 61 lines
---
  migration-rdma.c | 20 ++++++++++----------
  1 file changed, 10 insertions(+), 10 deletions(-)
migration-rdma.c +10 -10
index f94f3b4..29351a6 100644
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
      }
 
 
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
 
-    if (ret < 0) {
+    if (ret > 0) {
          fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
      }
 
      ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2237,10 +2235,6 @@ 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;
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
          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;
      }
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
          } else {
              ERROR(errp, "bad RDMA migration address '%s'", host_port);
              g_free(rdma);
-            return NULL;
+            rdma = NULL;
          }
+
+        qapi_free_InetSocketAddress(addr);
      }
 
      return rdma;
Signature · 1 line
1.8.1.2
#7 lore raw
In reply to [email protected]
Quoted 58 lines · On 02/18/2014 10:34 AM, [email protected] wrote:

From: "Michael R. Hines" <[email protected]>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

---
  migration-rdma.c | 20 ++++++++++----------
  1 file changed, 10 insertions(+), 10 deletions(-)
migration-rdma.c +7 -9
index f94f3b4..29351a6 100644
@@ -1589,13 +1589,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
      }
 
 
-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
 
-    if (ret < 0) {
+    if (ret > 0) {
          fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
      }
 
      ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2237,10 +2235,6 @@ 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;
@@ -2258,6 +2252,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
          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;
      }
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
          } else {

migration-rdma.c static void *qemu_rdma_data_init(const char *host_port, Error **errp) · line 2519

Quoted 10 lines
migration-rdma.c +3 -1
              ERROR(errp, "bad RDMA migration address '%s'", host_port);
              g_free(rdma);
-            return NULL;
+            rdma = NULL;
          }
+
+        qapi_free_InetSocketAddress(addr);
      }
 
      return rdma;

Juan? Ping again?

- Michael

#8 lore raw
Quoted 2 lines · Michael R. Hines
Quoted 1 line · On 02/18/2014 10:34 AM, [email protected] wrote:

From: "Michael R. Hines" <[email protected]>

Applied, would go in next pull request.

Quoted 11 lines
Quoted 11 lines
migration-rdma.c +3 -1
@@ -2512,8 +2510,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
          } else {
              ERROR(errp, "bad RDMA migration address '%s'", host_port);
              g_free(rdma);
-            return NULL;
+            rdma = NULL;
          }
+
+        qapi_free_InetSocketAddress(addr);
      }
 
Quoted 3 lines

migration-rdma.c static void *qemu_rdma_data_init(const char *host_port, Error **errp) · line 2519

Quoted 1 line
migration-rdma.c +0 -0
      return rdma;

Juan? Ping again?

I obviously missed this one, sorry :-(

Later, Juan.)