|
|
0a122b |
From 90c28e632cce2d60c8242f5fb3e93f630e6211bc Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
Message-Id: <90c28e632cce2d60c8242f5fb3e93f630e6211bc.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:05 +0100
|
|
|
0a122b |
Subject: [PATCH 29/46] rdma: check if RDMAControlHeader::len match
|
|
|
0a122b |
transferred byte
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Nigel Croxon <ncroxon@redhat.com>
|
|
|
0a122b |
Message-id: <1384469598-13137-30-git-send-email-ncroxon@redhat.com>
|
|
|
0a122b |
Patchwork-id: 55718
|
|
|
0a122b |
O-Subject: [RHEL7.0 PATCH 29/42] rdma: check if RDMAControlHeader::len match transferred byte
|
|
|
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 88571882516a7cb4291a329c537eb79fd126e1f2
|
|
|
0a122b |
Author: Isaku Yamahata <yamahata@private.email.ne.jp>
|
|
|
0a122b |
Date: Fri Aug 9 16:05:42 2013 -0400
|
|
|
0a122b |
|
|
|
0a122b |
rdma: check if RDMAControlHeader::len match transferred byte
|
|
|
0a122b |
|
|
|
0a122b |
RDMAControlHeader::len is provided from remote, so check if the value
|
|
|
0a122b |
match the actual transferred byte_len.
|
|
|
0a122b |
|
|
|
0a122b |
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
0a122b |
Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
|
|
|
0a122b |
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
|
|
|
0a122b |
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
|
|
|
0a122b |
Message-id: 1376078746-24948-4-git-send-email-mrhines@linux.vnet.ibm.com
|
|
|
0a122b |
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
migration-rdma.c | 32 ++++++++++++++++++++++----------
|
|
|
0a122b |
1 files changed, 22 insertions(+), 10 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
migration-rdma.c | 32 ++++++++++++++++++++++----------
|
|
|
0a122b |
1 file changed, 22 insertions(+), 10 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/migration-rdma.c b/migration-rdma.c
|
|
|
0a122b |
index 140d930..9c02ad3 100644
|
|
|
0a122b |
--- a/migration-rdma.c
|
|
|
0a122b |
+++ b/migration-rdma.c
|
|
|
0a122b |
@@ -1214,7 +1214,8 @@ static void qemu_rdma_signal_unregister(RDMAContext *rdma, uint64_t index,
|
|
|
0a122b |
* (of any kind) has completed.
|
|
|
0a122b |
* Return the work request ID that completed.
|
|
|
0a122b |
*/
|
|
|
0a122b |
-static uint64_t qemu_rdma_poll(RDMAContext *rdma, uint64_t *wr_id_out)
|
|
|
0a122b |
+static uint64_t qemu_rdma_poll(RDMAContext *rdma, uint64_t *wr_id_out,
|
|
|
0a122b |
+ uint32_t *byte_len)
|
|
|
0a122b |
{
|
|
|
0a122b |
int ret;
|
|
|
0a122b |
struct ibv_wc wc;
|
|
|
0a122b |
@@ -1285,6 +1286,9 @@ static uint64_t qemu_rdma_poll(RDMAContext *rdma, uint64_t *wr_id_out)
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
*wr_id_out = wc.wr_id;
|
|
|
0a122b |
+ if (byte_len) {
|
|
|
0a122b |
+ *byte_len = wc.byte_len;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
|
|
|
0a122b |
return 0;
|
|
|
0a122b |
}
|
|
|
0a122b |
@@ -1302,7 +1306,8 @@ static uint64_t qemu_rdma_poll(RDMAContext *rdma, uint64_t *wr_id_out)
|
|
|
0a122b |
* completions only need to be recorded, but do not actually
|
|
|
0a122b |
* need further processing.
|
|
|
0a122b |
*/
|
|
|
0a122b |
-static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested)
|
|
|
0a122b |
+static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested,
|
|
|
0a122b |
+ uint32_t *byte_len)
|
|
|
0a122b |
{
|
|
|
0a122b |
int num_cq_events = 0, ret = 0;
|
|
|
0a122b |
struct ibv_cq *cq;
|
|
|
0a122b |
@@ -1314,7 +1319,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested)
|
|
|
0a122b |
}
|
|
|
0a122b |
/* poll cq first */
|
|
|
0a122b |
while (wr_id != wrid_requested) {
|
|
|
0a122b |
- ret = qemu_rdma_poll(rdma, &wr_id_in);
|
|
|
0a122b |
+ ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len);
|
|
|
0a122b |
if (ret < 0) {
|
|
|
0a122b |
return ret;
|
|
|
0a122b |
}
|
|
|
0a122b |
@@ -1356,7 +1361,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested)
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
while (wr_id != wrid_requested) {
|
|
|
0a122b |
- ret = qemu_rdma_poll(rdma, &wr_id_in);
|
|
|
0a122b |
+ ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len);
|
|
|
0a122b |
if (ret < 0) {
|
|
|
0a122b |
goto err_block_for_wrid;
|
|
|
0a122b |
}
|
|
|
0a122b |
@@ -1442,7 +1447,7 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
|
|
|
0a122b |
return ret;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
- ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL);
|
|
|
0a122b |
+ ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
|
|
|
0a122b |
if (ret < 0) {
|
|
|
0a122b |
fprintf(stderr, "rdma migration: send polling control error!\n");
|
|
|
0a122b |
}
|
|
|
0a122b |
@@ -1483,7 +1488,9 @@ static int qemu_rdma_post_recv_control(RDMAContext *rdma, int idx)
|
|
|
0a122b |
static int qemu_rdma_exchange_get_response(RDMAContext *rdma,
|
|
|
0a122b |
RDMAControlHeader *head, int expecting, int idx)
|
|
|
0a122b |
{
|
|
|
0a122b |
- int ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RECV_CONTROL + idx);
|
|
|
0a122b |
+ uint32_t byte_len;
|
|
|
0a122b |
+ int ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RECV_CONTROL + idx,
|
|
|
0a122b |
+ &byte_len);
|
|
|
0a122b |
|
|
|
0a122b |
if (ret < 0) {
|
|
|
0a122b |
fprintf(stderr, "rdma migration: recv polling control error!\n");
|
|
|
0a122b |
@@ -1509,6 +1516,11 @@ static int qemu_rdma_exchange_get_response(RDMAContext *rdma,
|
|
|
0a122b |
fprintf(stderr, "too long length: %d\n", head->len);
|
|
|
0a122b |
return -EINVAL;
|
|
|
0a122b |
}
|
|
|
0a122b |
+ if (sizeof(*head) + head->len != byte_len) {
|
|
|
0a122b |
+ fprintf(stderr, "Malformed length: %d byte_len %d\n",
|
|
|
0a122b |
+ head->len, byte_len);
|
|
|
0a122b |
+ return -EINVAL;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
|
|
|
0a122b |
return 0;
|
|
|
0a122b |
}
|
|
|
0a122b |
@@ -1738,7 +1750,7 @@ retry:
|
|
|
0a122b |
count++, current_index, chunk,
|
|
|
0a122b |
sge.addr, length, rdma->nb_sent, block->nb_chunks);
|
|
|
0a122b |
|
|
|
0a122b |
- ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE);
|
|
|
0a122b |
+ ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL);
|
|
|
0a122b |
|
|
|
0a122b |
if (ret < 0) {
|
|
|
0a122b |
fprintf(stderr, "Failed to Wait for previous write to complete "
|
|
|
0a122b |
@@ -1882,7 +1894,7 @@ retry:
|
|
|
0a122b |
|
|
|
0a122b |
if (ret == ENOMEM) {
|
|
|
0a122b |
DDPRINTF("send queue is full. wait a little....\n");
|
|
|
0a122b |
- ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE);
|
|
|
0a122b |
+ ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL);
|
|
|
0a122b |
if (ret < 0) {
|
|
|
0a122b |
fprintf(stderr, "rdma migration: failed to make "
|
|
|
0a122b |
"room in full send queue! %d\n", ret);
|
|
|
0a122b |
@@ -2471,7 +2483,7 @@ static int qemu_rdma_drain_cq(QEMUFile *f, RDMAContext *rdma)
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
while (rdma->nb_sent) {
|
|
|
0a122b |
- ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE);
|
|
|
0a122b |
+ ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL);
|
|
|
0a122b |
if (ret < 0) {
|
|
|
0a122b |
fprintf(stderr, "rdma migration: complete polling error!\n");
|
|
|
0a122b |
return -EIO;
|
|
|
0a122b |
@@ -2607,7 +2619,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, void *opaque,
|
|
|
0a122b |
*/
|
|
|
0a122b |
while (1) {
|
|
|
0a122b |
uint64_t wr_id, wr_id_in;
|
|
|
0a122b |
- int ret = qemu_rdma_poll(rdma, &wr_id_in);
|
|
|
0a122b |
+ int ret = qemu_rdma_poll(rdma, &wr_id_in, NULL);
|
|
|
0a122b |
if (ret < 0) {
|
|
|
0a122b |
fprintf(stderr, "rdma migration: polling error! %d\n", ret);
|
|
|
0a122b |
goto err;
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.11.7
|
|
|
0a122b |
|