* [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support
@ 2013-08-04 2:54 mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work mrhines
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: mrhines @ 2013-08-04 2:54 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
From: "Michael R. Hines" <mrhines@us.ibm.com>
Changes:
A few bug
1. IPv6 support was broken under libvirt.
2. incorrect use of error_setg()
3. DPRINTF flag was not disabled
4. Numerous other bugfixes.
Isaku Yamahata (4):
rdma: don't use negative index to array
rdma: qemu_rdma_post_send_control uses wrongly RDMA_WRID_MAX
rdma: use RDMA_WRID_READY
rdma: memory leak RDMAContext::host
Michael R. Hines (3):
rdma: bugfix: make IPv6 support work
rdma: forgot to turn off the debugging flag
rdma: correct newlines in error statements
migration-rdma.c | 144 ++++++++++++++++++++++++++++++------------------------
1 file changed, 79 insertions(+), 65 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
@ 2013-08-04 2:54 ` mrhines
2013-08-07 8:39 ` Orit Wasserman
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 2/7] rdma: forgot to turn off the debugging flag mrhines
` (6 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: mrhines @ 2013-08-04 2:54 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
From: "Michael R. Hines" <mrhines@us.ibm.com>
RDMA does not use sockets, so we cannot use many of the socket
helper functions, but we *do* use inet_parse() which gives
RDMA all the necessary details of the connection parameters.
However, when testing with libvirt, a simple IPv6 migration test failed
because we were not using getaddrinfo() properly.
This makes IPv6 migration over RDMA work.
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
migration-rdma.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/migration-rdma.c b/migration-rdma.c
index d044830..9cf73e3 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -392,6 +392,7 @@ typedef struct RDMAContext {
uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX];
GHashTable *blockmap;
+ bool ipv6;
} RDMAContext;
/*
@@ -744,6 +745,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
char port_str[16];
struct rdma_cm_event *cm_event;
char ip[40] = "unknown";
+ int af = rdma->ipv6 ? PF_INET6 : PF_INET;
if (rdma->host == NULL || !strcmp(rdma->host, "")) {
ERROR(errp, "RDMA hostname has not been set\n");
@@ -773,7 +775,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
goto err_resolve_get_addr;
}
- inet_ntop(AF_INET, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
+ inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
ip, sizeof ip);
DPRINTF("%s => %s\n", rdma->host, ip);
@@ -2236,9 +2238,12 @@ err_rdma_source_connect:
static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
{
int ret = -EINVAL, idx;
+ int af = rdma->ipv6 ? PF_INET6 : PF_INET;
struct sockaddr_in sin;
struct rdma_cm_id *listen_id;
char ip[40] = "unknown";
+ struct addrinfo *res;
+ char port_str[16];
for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
rdma->wr_data[idx].control_len = 0;
@@ -2266,27 +2271,30 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
}
memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
+ sin.sin_family = af;
sin.sin_port = htons(rdma->port);
+ snprintf(port_str, 16, "%d", rdma->port);
+ port_str[15] = '\0';
if (rdma->host && strcmp("", rdma->host)) {
- struct hostent *dest_addr;
- dest_addr = gethostbyname(rdma->host);
- if (!dest_addr) {
- ERROR(errp, "migration could not gethostbyname!\n");
- ret = -EINVAL;
+ ret = getaddrinfo(rdma->host, port_str, NULL, &res);
+ if (ret < 0) {
+ ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
goto err_dest_init_bind_addr;
}
- memcpy(&sin.sin_addr.s_addr, dest_addr->h_addr,
- dest_addr->h_length);
- inet_ntop(AF_INET, dest_addr->h_addr, ip, sizeof ip);
+
+
+ inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
+ ip, sizeof ip);
} else {
- sin.sin_addr.s_addr = INADDR_ANY;
+ ERROR(errp, "migration host and port not specified!\n");
+ ret = -EINVAL;
+ goto err_dest_init_bind_addr;
}
DPRINTF("%s => %s\n", rdma->host, ip);
- ret = rdma_bind_addr(listen_id, (struct sockaddr *)&sin);
+ ret = rdma_bind_addr(listen_id, res->ai_addr);
if (ret) {
ERROR(errp, "Error: could not rdma_bind_addr!\n");
goto err_dest_init_bind_addr;
@@ -2321,6 +2329,7 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
if (addr != NULL) {
rdma->port = atoi(addr->port);
rdma->host = g_strdup(addr->host);
+ rdma->ipv6 = addr->ipv6;
} else {
ERROR(errp, "bad RDMA migration address '%s'", host_port);
g_free(rdma);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v3 For-1.6 2/7] rdma: forgot to turn off the debugging flag
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work mrhines
@ 2013-08-04 2:54 ` mrhines
2013-08-07 8:39 ` Orit Wasserman
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 3/7] rdma: correct newlines in error statements mrhines
` (5 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: mrhines @ 2013-08-04 2:54 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
From: "Michael R. Hines" <mrhines@us.ibm.com>
Ooops. We forgot to turn off the flag.
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
migration-rdma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/migration-rdma.c b/migration-rdma.c
index 9cf73e3..fe6118d 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -27,7 +27,7 @@
#include <string.h>
#include <rdma/rdma_cma.h>
-#define DEBUG_RDMA
+//#define DEBUG_RDMA
//#define DEBUG_RDMA_VERBOSE
//#define DEBUG_RDMA_REALLY_VERBOSE
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v3 For-1.6 3/7] rdma: correct newlines in error statements
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 2/7] rdma: forgot to turn off the debugging flag mrhines
@ 2013-08-04 2:54 ` mrhines
2013-08-07 8:45 ` Orit Wasserman
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 4/7] rdma: don't use negative index to array mrhines
` (4 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: mrhines @ 2013-08-04 2:54 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
From: "Michael R. Hines" <mrhines@us.ibm.com>
Don't print newlines on the error_setg() function,
but still allow newlines on fprintf().
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
migration-rdma.c | 68 +++++++++++++++++++++++++++---------------------------
1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/migration-rdma.c b/migration-rdma.c
index fe6118d..c958e5f 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -60,7 +60,7 @@
*/
#define ERROR(errp, fmt, ...) \
do { \
- fprintf(stderr, "RDMA ERROR: " fmt, ## __VA_ARGS__); \
+ fprintf(stderr, "RDMA ERROR: " fmt "\n", ## __VA_ARGS__); \
if (errp && (*(errp) == NULL)) { \
error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \
} \
@@ -748,21 +748,21 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
int af = rdma->ipv6 ? PF_INET6 : PF_INET;
if (rdma->host == NULL || !strcmp(rdma->host, "")) {
- ERROR(errp, "RDMA hostname has not been set\n");
+ ERROR(errp, "RDMA hostname has not been set");
return -1;
}
/* create CM channel */
rdma->channel = rdma_create_event_channel();
if (!rdma->channel) {
- ERROR(errp, "could not create CM channel\n");
+ ERROR(errp, "could not create CM channel");
return -1;
}
/* create CM id */
ret = rdma_create_id(rdma->channel, &rdma->cm_id, NULL, RDMA_PS_TCP);
if (ret) {
- ERROR(errp, "could not create channel id\n");
+ ERROR(errp, "could not create channel id");
goto err_resolve_create_id;
}
@@ -771,7 +771,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
ret = getaddrinfo(rdma->host, port_str, NULL, &res);
if (ret < 0) {
- ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
+ ERROR(errp, "could not getaddrinfo address %s", rdma->host);
goto err_resolve_get_addr;
}
@@ -783,7 +783,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
ret = rdma_resolve_addr(rdma->cm_id, NULL, res->ai_addr,
RDMA_RESOLVE_TIMEOUT_MS);
if (ret) {
- ERROR(errp, "could not resolve address %s\n", rdma->host);
+ ERROR(errp, "could not resolve address %s", rdma->host);
goto err_resolve_get_addr;
}
@@ -791,12 +791,12 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
ret = rdma_get_cm_event(rdma->channel, &cm_event);
if (ret) {
- ERROR(errp, "could not perform event_addr_resolved\n");
+ ERROR(errp, "could not perform event_addr_resolved");
goto err_resolve_get_addr;
}
if (cm_event->event != RDMA_CM_EVENT_ADDR_RESOLVED) {
- ERROR(errp, "result not equal to event_addr_resolved %s\n",
+ ERROR(errp, "result not equal to event_addr_resolved %s",
rdma_event_str(cm_event->event));
perror("rdma_resolve_addr");
goto err_resolve_get_addr;
@@ -806,17 +806,17 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
/* resolve route */
ret = rdma_resolve_route(rdma->cm_id, RDMA_RESOLVE_TIMEOUT_MS);
if (ret) {
- ERROR(errp, "could not resolve rdma route\n");
+ ERROR(errp, "could not resolve rdma route");
goto err_resolve_get_addr;
}
ret = rdma_get_cm_event(rdma->channel, &cm_event);
if (ret) {
- ERROR(errp, "could not perform event_route_resolved\n");
+ ERROR(errp, "could not perform event_route_resolved");
goto err_resolve_get_addr;
}
if (cm_event->event != RDMA_CM_EVENT_ROUTE_RESOLVED) {
- ERROR(errp, "result not equal to event_route_resolved: %s\n",
+ ERROR(errp, "result not equal to event_route_resolved: %s",
rdma_event_str(cm_event->event));
rdma_ack_cm_event(cm_event);
goto err_resolve_get_addr;
@@ -2117,26 +2117,26 @@ static int qemu_rdma_source_init(RDMAContext *rdma, Error **errp, bool pin_all)
if (ret) {
ERROR(temp, "rdma migration: error allocating pd and cq! Your mlock()"
" limits may be too low. Please check $ ulimit -a # and "
- "search for 'ulimit -l' in the output\n");
+ "search for 'ulimit -l' in the output");
goto err_rdma_source_init;
}
ret = qemu_rdma_alloc_qp(rdma);
if (ret) {
- ERROR(temp, "rdma migration: error allocating qp!\n");
+ ERROR(temp, "rdma migration: error allocating qp!");
goto err_rdma_source_init;
}
ret = qemu_rdma_init_ram_blocks(rdma);
if (ret) {
- ERROR(temp, "rdma migration: error initializing ram blocks!\n");
+ ERROR(temp, "rdma migration: error initializing ram blocks!");
goto err_rdma_source_init;
}
for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
ret = qemu_rdma_reg_control(rdma, idx);
if (ret) {
- ERROR(temp, "rdma migration: error registering %d control!\n",
+ ERROR(temp, "rdma migration: error registering %d control!",
idx);
goto err_rdma_source_init;
}
@@ -2178,7 +2178,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
ret = rdma_connect(rdma->cm_id, &conn_param);
if (ret) {
perror("rdma_connect");
- ERROR(errp, "connecting to destination!\n");
+ ERROR(errp, "connecting to destination!");
rdma_destroy_id(rdma->cm_id);
rdma->cm_id = NULL;
goto err_rdma_source_connect;
@@ -2187,7 +2187,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
ret = rdma_get_cm_event(rdma->channel, &cm_event);
if (ret) {
perror("rdma_get_cm_event after rdma_connect");
- ERROR(errp, "connecting to destination!\n");
+ ERROR(errp, "connecting to destination!");
rdma_ack_cm_event(cm_event);
rdma_destroy_id(rdma->cm_id);
rdma->cm_id = NULL;
@@ -2196,7 +2196,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) {
perror("rdma_get_cm_event != EVENT_ESTABLISHED after rdma_connect");
- ERROR(errp, "connecting to destination!\n");
+ ERROR(errp, "connecting to destination!");
rdma_ack_cm_event(cm_event);
rdma_destroy_id(rdma->cm_id);
rdma->cm_id = NULL;
@@ -2212,7 +2212,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
*/
if (rdma->pin_all && !(cap.flags & RDMA_CAPABILITY_PIN_ALL)) {
ERROR(errp, "Server cannot support pinning all memory. "
- "Will register memory dynamically.\n");
+ "Will register memory dynamically.");
rdma->pin_all = false;
}
@@ -2222,7 +2222,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
ret = qemu_rdma_post_recv_control(rdma, 0);
if (ret) {
- ERROR(errp, "posting second control recv!\n");
+ ERROR(errp, "posting second control recv!");
goto err_rdma_source_connect;
}
@@ -2251,14 +2251,14 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
}
if (rdma->host == NULL) {
- ERROR(errp, "RDMA host is not set!\n");
+ ERROR(errp, "RDMA host is not set!");
rdma->error_state = -EINVAL;
return -1;
}
/* create CM channel */
rdma->channel = rdma_create_event_channel();
if (!rdma->channel) {
- ERROR(errp, "could not create rdma event channel\n");
+ ERROR(errp, "could not create rdma event channel");
rdma->error_state = -EINVAL;
return -1;
}
@@ -2266,7 +2266,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
/* create CM id */
ret = rdma_create_id(rdma->channel, &listen_id, NULL, RDMA_PS_TCP);
if (ret) {
- ERROR(errp, "could not create cm_id!\n");
+ ERROR(errp, "could not create cm_id!");
goto err_dest_init_create_listen_id;
}
@@ -2279,7 +2279,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
if (rdma->host && strcmp("", rdma->host)) {
ret = getaddrinfo(rdma->host, port_str, NULL, &res);
if (ret < 0) {
- ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
+ ERROR(errp, "could not getaddrinfo address %s", rdma->host);
goto err_dest_init_bind_addr;
}
@@ -2287,7 +2287,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
ip, sizeof ip);
} else {
- ERROR(errp, "migration host and port not specified!\n");
+ ERROR(errp, "migration host and port not specified!");
ret = -EINVAL;
goto err_dest_init_bind_addr;
}
@@ -2296,7 +2296,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
ret = rdma_bind_addr(listen_id, res->ai_addr);
if (ret) {
- ERROR(errp, "Error: could not rdma_bind_addr!\n");
+ ERROR(errp, "Error: could not rdma_bind_addr!");
goto err_dest_init_bind_addr;
}
@@ -3036,7 +3036,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
®_result_idx, rdma->pin_all ?
qemu_rdma_reg_whole_ram_blocks : NULL);
if (ret < 0) {
- ERROR(errp, "receiving remote info!\n");
+ ERROR(errp, "receiving remote info!");
return ret;
}
@@ -3061,7 +3061,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
if (local->nb_blocks != nb_remote_blocks) {
ERROR(errp, "ram blocks mismatch #1! "
"Your QEMU command line parameters are probably "
- "not identical on both the source and destination.\n");
+ "not identical on both the source and destination.");
return -EINVAL;
}
@@ -3077,7 +3077,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
if (rdma->block[i].length != local->block[j].length) {
ERROR(errp, "ram blocks mismatch #2! "
"Your QEMU command line parameters are probably "
- "not identical on both the source and destination.\n");
+ "not identical on both the source and destination.");
return -EINVAL;
}
local->block[j].remote_host_addr =
@@ -3089,7 +3089,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
if (j >= local->nb_blocks) {
ERROR(errp, "ram blocks mismatch #3! "
"Your QEMU command line parameters are probably "
- "not identical on both the source and destination.\n");
+ "not identical on both the source and destination.");
return -EINVAL;
}
}
@@ -3163,7 +3163,7 @@ static void rdma_accept_incoming_migration(void *opaque)
ret = qemu_rdma_accept(rdma);
if (ret) {
- ERROR(errp, "RDMA Migration initialization failed!\n");
+ ERROR(errp, "RDMA Migration initialization failed!");
return;
}
@@ -3171,7 +3171,7 @@ static void rdma_accept_incoming_migration(void *opaque)
f = qemu_fopen_rdma(rdma, "rb");
if (f == NULL) {
- ERROR(errp, "could not qemu_fopen_rdma!\n");
+ ERROR(errp, "could not qemu_fopen_rdma!");
qemu_rdma_cleanup(rdma);
return;
}
@@ -3204,7 +3204,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp)
ret = rdma_listen(rdma->listen_id, 5);
if (ret) {
- ERROR(errp, "listening on socket!\n");
+ ERROR(errp, "listening on socket!");
goto err;
}
@@ -3228,7 +3228,7 @@ void rdma_start_outgoing_migration(void *opaque,
int ret = 0;
if (rdma == NULL) {
- ERROR(temp, "Failed to initialize RDMA data structures! %d\n", ret);
+ ERROR(temp, "Failed to initialize RDMA data structures! %d", ret);
goto err;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v3 For-1.6 4/7] rdma: don't use negative index to array
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
` (2 preceding siblings ...)
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 3/7] rdma: correct newlines in error statements mrhines
@ 2013-08-04 2:54 ` mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 5/7] rdma: qemu_rdma_post_send_control uses wrongly RDMA_WRID_MAX mrhines
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: mrhines @ 2013-08-04 2:54 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
From: Isaku Yamahata <yamahata@private.email.ne.jp>
Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
migration-rdma.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/migration-rdma.c b/migration-rdma.c
index c958e5f..7266803 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -1933,10 +1933,21 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMAContext *rdma)
static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
uint64_t offset, uint64_t len)
{
- RDMALocalBlock *block =
- &(rdma->local_ram_blocks.block[rdma->current_index]);
- uint8_t *host_addr = block->local_host_addr + (offset - block->offset);
- uint8_t *chunk_end = ram_chunk_end(block, rdma->current_chunk);
+ RDMALocalBlock *block;
+ uint8_t *host_addr;
+ uint8_t *chunk_end;
+
+ if (rdma->current_index < 0) {
+ return 0;
+ }
+
+ if (rdma->current_chunk < 0) {
+ return 0;
+ }
+
+ block = &(rdma->local_ram_blocks.block[rdma->current_index]);
+ host_addr = block->local_host_addr + (offset - block->offset);
+ chunk_end = ram_chunk_end(block, rdma->current_chunk);
if (rdma->current_length == 0) {
return 0;
@@ -1949,10 +1960,6 @@ static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
return 0;
}
- if (rdma->current_index < 0) {
- return 0;
- }
-
if (offset < block->offset) {
return 0;
}
@@ -1961,10 +1968,6 @@ static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
return 0;
}
- if (rdma->current_chunk < 0) {
- return 0;
- }
-
if ((host_addr + len) > chunk_end) {
return 0;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v3 For-1.6 5/7] rdma: qemu_rdma_post_send_control uses wrongly RDMA_WRID_MAX
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
` (3 preceding siblings ...)
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 4/7] rdma: don't use negative index to array mrhines
@ 2013-08-04 2:54 ` mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 6/7] rdma: use RDMA_WRID_READY mrhines
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: mrhines @ 2013-08-04 2:54 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
From: Isaku Yamahata <yamahata@private.email.ne.jp>
RDMA_WRID_CONTROL should be used. And remove related work around.
Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
migration-rdma.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/migration-rdma.c b/migration-rdma.c
index 7266803..ea16f0e 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -322,7 +322,7 @@ typedef struct RDMAContext {
char *host;
int port;
- RDMAWorkRequestData wr_data[RDMA_WRID_MAX + 1];
+ RDMAWorkRequestData wr_data[RDMA_WRID_MAX];
/*
* This is used by *_exchange_send() to figure out whether or not
@@ -1399,7 +1399,7 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
RDMAControlHeader *head)
{
int ret = 0;
- RDMAWorkRequestData *wr = &rdma->wr_data[RDMA_WRID_MAX];
+ RDMAWorkRequestData *wr = &rdma->wr_data[RDMA_WRID_CONTROL];
struct ibv_send_wr *bad_wr;
struct ibv_sge sge = {
.addr = (uint64_t)(wr->control),
@@ -2054,7 +2054,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
g_free(rdma->block);
rdma->block = NULL;
- for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
+ for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
if (rdma->wr_data[idx].control_mr) {
rdma->total_registrations--;
ibv_dereg_mr(rdma->wr_data[idx].control_mr);
@@ -2136,7 +2136,7 @@ static int qemu_rdma_source_init(RDMAContext *rdma, Error **errp, bool pin_all)
goto err_rdma_source_init;
}
- for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
+ for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
ret = qemu_rdma_reg_control(rdma, idx);
if (ret) {
ERROR(temp, "rdma migration: error registering %d control!",
@@ -2248,7 +2248,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
struct addrinfo *res;
char port_str[16];
- for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
+ for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
rdma->wr_data[idx].control_len = 0;
rdma->wr_data[idx].control_curr = NULL;
}
@@ -2705,7 +2705,7 @@ static int qemu_rdma_accept(RDMAContext *rdma)
goto err_rdma_dest_wait;
}
- for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
+ for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
ret = qemu_rdma_reg_control(rdma, idx);
if (ret) {
fprintf(stderr, "rdma: error registering %d control!\n", idx);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v3 For-1.6 6/7] rdma: use RDMA_WRID_READY
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
` (4 preceding siblings ...)
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 5/7] rdma: qemu_rdma_post_send_control uses wrongly RDMA_WRID_MAX mrhines
@ 2013-08-04 2:54 ` mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 7/7] rdma: memory leak RDMAContext::host mrhines
2013-08-14 16:27 ` [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support Anthony Liguori
7 siblings, 0 replies; 13+ messages in thread
From: mrhines @ 2013-08-04 2:54 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
From: Isaku Yamahata <yamahata@private.email.ne.jp>
Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
migration-rdma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/migration-rdma.c b/migration-rdma.c
index ea16f0e..6afe98c 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -2223,7 +2223,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
rdma_ack_cm_event(cm_event);
- ret = qemu_rdma_post_recv_control(rdma, 0);
+ ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
if (ret) {
ERROR(errp, "posting second control recv!");
goto err_rdma_source_connect;
@@ -2735,7 +2735,7 @@ static int qemu_rdma_accept(RDMAContext *rdma)
rdma_ack_cm_event(cm_event);
- ret = qemu_rdma_post_recv_control(rdma, 0);
+ ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
if (ret) {
fprintf(stderr, "rdma migration: error posting second control recv!\n");
goto err_rdma_dest_wait;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v3 For-1.6 7/7] rdma: memory leak RDMAContext::host
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
` (5 preceding siblings ...)
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 6/7] rdma: use RDMA_WRID_READY mrhines
@ 2013-08-04 2:54 ` mrhines
2013-08-14 16:27 ` [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support Anthony Liguori
7 siblings, 0 replies; 13+ messages in thread
From: mrhines @ 2013-08-04 2:54 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
From: Isaku Yamahata <yamahata@private.email.ne.jp>
It is allocated by g_strdup(), so needs to be freed.
Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
migration-rdma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/migration-rdma.c b/migration-rdma.c
index 6afe98c..ff0a823 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -2097,6 +2097,8 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
rdma_destroy_event_channel(rdma->channel);
rdma->channel = NULL;
}
+ g_free(rdma->host);
+ rdma->host = NULL;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work mrhines
@ 2013-08-07 8:39 ` Orit Wasserman
2013-08-07 14:53 ` Michael R. Hines
0 siblings, 1 reply; 13+ messages in thread
From: Orit Wasserman @ 2013-08-07 8:39 UTC (permalink / raw)
To: mrhines; +Cc: yamahata, aliguori, quintela, qemu-devel, mrhines, pbonzini
On 08/04/2013 05:54 AM, mrhines@linux.vnet.ibm.com wrote:
> From: "Michael R. Hines" <mrhines@us.ibm.com>
>
> RDMA does not use sockets, so we cannot use many of the socket
> helper functions, but we *do* use inet_parse() which gives
> RDMA all the necessary details of the connection parameters.
>
> However, when testing with libvirt, a simple IPv6 migration test failed
> because we were not using getaddrinfo() properly.
>
> This makes IPv6 migration over RDMA work.
>
> Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
> ---
> migration-rdma.c | 33 +++++++++++++++++++++------------
> 1 file changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/migration-rdma.c b/migration-rdma.c
> index d044830..9cf73e3 100644
> --- a/migration-rdma.c
> +++ b/migration-rdma.c
> @@ -392,6 +392,7 @@ typedef struct RDMAContext {
> uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX];
>
> GHashTable *blockmap;
> + bool ipv6;
> } RDMAContext;
>
> /*
> @@ -744,6 +745,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
> char port_str[16];
> struct rdma_cm_event *cm_event;
> char ip[40] = "unknown";
> + int af = rdma->ipv6 ? PF_INET6 : PF_INET;
>
> if (rdma->host == NULL || !strcmp(rdma->host, "")) {
> ERROR(errp, "RDMA hostname has not been set\n");
> @@ -773,7 +775,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
> goto err_resolve_get_addr;
> }
>
> - inet_ntop(AF_INET, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
> + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
> ip, sizeof ip);
> DPRINTF("%s => %s\n", rdma->host, ip);
>
> @@ -2236,9 +2238,12 @@ err_rdma_source_connect:
> static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
> {
> int ret = -EINVAL, idx;
> + int af = rdma->ipv6 ? PF_INET6 : PF_INET;
> struct sockaddr_in sin;
> struct rdma_cm_id *listen_id;
> char ip[40] = "unknown";
> + struct addrinfo *res;
> + char port_str[16];
>
> for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
> rdma->wr_data[idx].control_len = 0;
> @@ -2266,27 +2271,30 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
> }
>
> memset(&sin, 0, sizeof(sin));
> - sin.sin_family = AF_INET;
> + sin.sin_family = af;
> sin.sin_port = htons(rdma->port);
> + snprintf(port_str, 16, "%d", rdma->port);
> + port_str[15] = '\0';
>
> if (rdma->host && strcmp("", rdma->host)) {
> - struct hostent *dest_addr;
> - dest_addr = gethostbyname(rdma->host);
> - if (!dest_addr) {
> - ERROR(errp, "migration could not gethostbyname!\n");
> - ret = -EINVAL;
> + ret = getaddrinfo(rdma->host, port_str, NULL, &res);
Hi Michael,
getaddrinfo can return a list of addresses, you need to handle it.
Look at qemu-sockets.c for example.
Regards,
Orit
> + if (ret < 0) {
> + ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
> goto err_dest_init_bind_addr;
> }
> - memcpy(&sin.sin_addr.s_addr, dest_addr->h_addr,
> - dest_addr->h_length);
> - inet_ntop(AF_INET, dest_addr->h_addr, ip, sizeof ip);
> +
> +
> + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
> + ip, sizeof ip);
> } else {
> - sin.sin_addr.s_addr = INADDR_ANY;
> + ERROR(errp, "migration host and port not specified!\n");
> + ret = -EINVAL;
> + goto err_dest_init_bind_addr;
> }
>
> DPRINTF("%s => %s\n", rdma->host, ip);
>
> - ret = rdma_bind_addr(listen_id, (struct sockaddr *)&sin);
> + ret = rdma_bind_addr(listen_id, res->ai_addr);
> if (ret) {
> ERROR(errp, "Error: could not rdma_bind_addr!\n");
> goto err_dest_init_bind_addr;
> @@ -2321,6 +2329,7 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
> if (addr != NULL) {
> rdma->port = atoi(addr->port);
> rdma->host = g_strdup(addr->host);
> + rdma->ipv6 = addr->ipv6;
> } else {
> ERROR(errp, "bad RDMA migration address '%s'", host_port);
> g_free(rdma);
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v3 For-1.6 2/7] rdma: forgot to turn off the debugging flag
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 2/7] rdma: forgot to turn off the debugging flag mrhines
@ 2013-08-07 8:39 ` Orit Wasserman
0 siblings, 0 replies; 13+ messages in thread
From: Orit Wasserman @ 2013-08-07 8:39 UTC (permalink / raw)
To: mrhines; +Cc: yamahata, aliguori, quintela, qemu-devel, mrhines, pbonzini
On 08/04/2013 05:54 AM, mrhines@linux.vnet.ibm.com wrote:
> From: "Michael R. Hines" <mrhines@us.ibm.com>
>
> Ooops. We forgot to turn off the flag.
>
> Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
> ---
> migration-rdma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/migration-rdma.c b/migration-rdma.c
> index 9cf73e3..fe6118d 100644
> --- a/migration-rdma.c
> +++ b/migration-rdma.c
> @@ -27,7 +27,7 @@
> #include <string.h>
> #include <rdma/rdma_cma.h>
>
> -#define DEBUG_RDMA
> +//#define DEBUG_RDMA
> //#define DEBUG_RDMA_VERBOSE
> //#define DEBUG_RDMA_REALLY_VERBOSE
>
>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v3 For-1.6 3/7] rdma: correct newlines in error statements
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 3/7] rdma: correct newlines in error statements mrhines
@ 2013-08-07 8:45 ` Orit Wasserman
0 siblings, 0 replies; 13+ messages in thread
From: Orit Wasserman @ 2013-08-07 8:45 UTC (permalink / raw)
To: mrhines; +Cc: yamahata, aliguori, quintela, qemu-devel, mrhines, pbonzini
On 08/04/2013 05:54 AM, mrhines@linux.vnet.ibm.com wrote:
> From: "Michael R. Hines" <mrhines@us.ibm.com>
>
> Don't print newlines on the error_setg() function,
> but still allow newlines on fprintf().
>
> Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
> ---
> migration-rdma.c | 68 +++++++++++++++++++++++++++---------------------------
> 1 file changed, 34 insertions(+), 34 deletions(-)
>
> diff --git a/migration-rdma.c b/migration-rdma.c
> index fe6118d..c958e5f 100644
> --- a/migration-rdma.c
> +++ b/migration-rdma.c
> @@ -60,7 +60,7 @@
> */
> #define ERROR(errp, fmt, ...) \
> do { \
> - fprintf(stderr, "RDMA ERROR: " fmt, ## __VA_ARGS__); \
> + fprintf(stderr, "RDMA ERROR: " fmt "\n", ## __VA_ARGS__); \
> if (errp && (*(errp) == NULL)) { \
> error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \
> } \
> @@ -748,21 +748,21 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
> int af = rdma->ipv6 ? PF_INET6 : PF_INET;
>
> if (rdma->host == NULL || !strcmp(rdma->host, "")) {
> - ERROR(errp, "RDMA hostname has not been set\n");
> + ERROR(errp, "RDMA hostname has not been set");
> return -1;
> }
>
> /* create CM channel */
> rdma->channel = rdma_create_event_channel();
> if (!rdma->channel) {
> - ERROR(errp, "could not create CM channel\n");
> + ERROR(errp, "could not create CM channel");
> return -1;
> }
>
> /* create CM id */
> ret = rdma_create_id(rdma->channel, &rdma->cm_id, NULL, RDMA_PS_TCP);
> if (ret) {
> - ERROR(errp, "could not create channel id\n");
> + ERROR(errp, "could not create channel id");
> goto err_resolve_create_id;
> }
>
> @@ -771,7 +771,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
>
> ret = getaddrinfo(rdma->host, port_str, NULL, &res);
> if (ret < 0) {
> - ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
> + ERROR(errp, "could not getaddrinfo address %s", rdma->host);
> goto err_resolve_get_addr;
> }
>
> @@ -783,7 +783,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
> ret = rdma_resolve_addr(rdma->cm_id, NULL, res->ai_addr,
> RDMA_RESOLVE_TIMEOUT_MS);
> if (ret) {
> - ERROR(errp, "could not resolve address %s\n", rdma->host);
> + ERROR(errp, "could not resolve address %s", rdma->host);
> goto err_resolve_get_addr;
> }
>
> @@ -791,12 +791,12 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
>
> ret = rdma_get_cm_event(rdma->channel, &cm_event);
> if (ret) {
> - ERROR(errp, "could not perform event_addr_resolved\n");
> + ERROR(errp, "could not perform event_addr_resolved");
> goto err_resolve_get_addr;
> }
>
> if (cm_event->event != RDMA_CM_EVENT_ADDR_RESOLVED) {
> - ERROR(errp, "result not equal to event_addr_resolved %s\n",
> + ERROR(errp, "result not equal to event_addr_resolved %s",
> rdma_event_str(cm_event->event));
> perror("rdma_resolve_addr");
> goto err_resolve_get_addr;
> @@ -806,17 +806,17 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
> /* resolve route */
> ret = rdma_resolve_route(rdma->cm_id, RDMA_RESOLVE_TIMEOUT_MS);
> if (ret) {
> - ERROR(errp, "could not resolve rdma route\n");
> + ERROR(errp, "could not resolve rdma route");
> goto err_resolve_get_addr;
> }
>
> ret = rdma_get_cm_event(rdma->channel, &cm_event);
> if (ret) {
> - ERROR(errp, "could not perform event_route_resolved\n");
> + ERROR(errp, "could not perform event_route_resolved");
> goto err_resolve_get_addr;
> }
> if (cm_event->event != RDMA_CM_EVENT_ROUTE_RESOLVED) {
> - ERROR(errp, "result not equal to event_route_resolved: %s\n",
> + ERROR(errp, "result not equal to event_route_resolved: %s",
> rdma_event_str(cm_event->event));
> rdma_ack_cm_event(cm_event);
> goto err_resolve_get_addr;
> @@ -2117,26 +2117,26 @@ static int qemu_rdma_source_init(RDMAContext *rdma, Error **errp, bool pin_all)
> if (ret) {
> ERROR(temp, "rdma migration: error allocating pd and cq! Your mlock()"
> " limits may be too low. Please check $ ulimit -a # and "
> - "search for 'ulimit -l' in the output\n");
> + "search for 'ulimit -l' in the output");
> goto err_rdma_source_init;
> }
>
> ret = qemu_rdma_alloc_qp(rdma);
> if (ret) {
> - ERROR(temp, "rdma migration: error allocating qp!\n");
> + ERROR(temp, "rdma migration: error allocating qp!");
> goto err_rdma_source_init;
> }
>
> ret = qemu_rdma_init_ram_blocks(rdma);
> if (ret) {
> - ERROR(temp, "rdma migration: error initializing ram blocks!\n");
> + ERROR(temp, "rdma migration: error initializing ram blocks!");
> goto err_rdma_source_init;
> }
>
> for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
> ret = qemu_rdma_reg_control(rdma, idx);
> if (ret) {
> - ERROR(temp, "rdma migration: error registering %d control!\n",
> + ERROR(temp, "rdma migration: error registering %d control!",
> idx);
> goto err_rdma_source_init;
> }
> @@ -2178,7 +2178,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
> ret = rdma_connect(rdma->cm_id, &conn_param);
> if (ret) {
> perror("rdma_connect");
> - ERROR(errp, "connecting to destination!\n");
> + ERROR(errp, "connecting to destination!");
> rdma_destroy_id(rdma->cm_id);
> rdma->cm_id = NULL;
> goto err_rdma_source_connect;
> @@ -2187,7 +2187,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
> ret = rdma_get_cm_event(rdma->channel, &cm_event);
> if (ret) {
> perror("rdma_get_cm_event after rdma_connect");
> - ERROR(errp, "connecting to destination!\n");
> + ERROR(errp, "connecting to destination!");
> rdma_ack_cm_event(cm_event);
> rdma_destroy_id(rdma->cm_id);
> rdma->cm_id = NULL;
> @@ -2196,7 +2196,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
>
> if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) {
> perror("rdma_get_cm_event != EVENT_ESTABLISHED after rdma_connect");
> - ERROR(errp, "connecting to destination!\n");
> + ERROR(errp, "connecting to destination!");
> rdma_ack_cm_event(cm_event);
> rdma_destroy_id(rdma->cm_id);
> rdma->cm_id = NULL;
> @@ -2212,7 +2212,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
> */
> if (rdma->pin_all && !(cap.flags & RDMA_CAPABILITY_PIN_ALL)) {
> ERROR(errp, "Server cannot support pinning all memory. "
> - "Will register memory dynamically.\n");
> + "Will register memory dynamically.");
> rdma->pin_all = false;
> }
>
> @@ -2222,7 +2222,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
>
> ret = qemu_rdma_post_recv_control(rdma, 0);
> if (ret) {
> - ERROR(errp, "posting second control recv!\n");
> + ERROR(errp, "posting second control recv!");
> goto err_rdma_source_connect;
> }
>
> @@ -2251,14 +2251,14 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
> }
>
> if (rdma->host == NULL) {
> - ERROR(errp, "RDMA host is not set!\n");
> + ERROR(errp, "RDMA host is not set!");
> rdma->error_state = -EINVAL;
> return -1;
> }
> /* create CM channel */
> rdma->channel = rdma_create_event_channel();
> if (!rdma->channel) {
> - ERROR(errp, "could not create rdma event channel\n");
> + ERROR(errp, "could not create rdma event channel");
> rdma->error_state = -EINVAL;
> return -1;
> }
> @@ -2266,7 +2266,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
> /* create CM id */
> ret = rdma_create_id(rdma->channel, &listen_id, NULL, RDMA_PS_TCP);
> if (ret) {
> - ERROR(errp, "could not create cm_id!\n");
> + ERROR(errp, "could not create cm_id!");
> goto err_dest_init_create_listen_id;
> }
>
> @@ -2279,7 +2279,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
> if (rdma->host && strcmp("", rdma->host)) {
> ret = getaddrinfo(rdma->host, port_str, NULL, &res);
> if (ret < 0) {
> - ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
> + ERROR(errp, "could not getaddrinfo address %s", rdma->host);
> goto err_dest_init_bind_addr;
> }
>
> @@ -2287,7 +2287,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
> inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
> ip, sizeof ip);
> } else {
> - ERROR(errp, "migration host and port not specified!\n");
> + ERROR(errp, "migration host and port not specified!");
> ret = -EINVAL;
> goto err_dest_init_bind_addr;
> }
> @@ -2296,7 +2296,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
>
> ret = rdma_bind_addr(listen_id, res->ai_addr);
> if (ret) {
> - ERROR(errp, "Error: could not rdma_bind_addr!\n");
> + ERROR(errp, "Error: could not rdma_bind_addr!");
> goto err_dest_init_bind_addr;
> }
>
> @@ -3036,7 +3036,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
> ®_result_idx, rdma->pin_all ?
> qemu_rdma_reg_whole_ram_blocks : NULL);
> if (ret < 0) {
> - ERROR(errp, "receiving remote info!\n");
> + ERROR(errp, "receiving remote info!");
> return ret;
> }
>
> @@ -3061,7 +3061,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
> if (local->nb_blocks != nb_remote_blocks) {
> ERROR(errp, "ram blocks mismatch #1! "
> "Your QEMU command line parameters are probably "
> - "not identical on both the source and destination.\n");
> + "not identical on both the source and destination.");
> return -EINVAL;
> }
>
> @@ -3077,7 +3077,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
> if (rdma->block[i].length != local->block[j].length) {
> ERROR(errp, "ram blocks mismatch #2! "
> "Your QEMU command line parameters are probably "
> - "not identical on both the source and destination.\n");
> + "not identical on both the source and destination.");
> return -EINVAL;
> }
> local->block[j].remote_host_addr =
> @@ -3089,7 +3089,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
> if (j >= local->nb_blocks) {
> ERROR(errp, "ram blocks mismatch #3! "
> "Your QEMU command line parameters are probably "
> - "not identical on both the source and destination.\n");
> + "not identical on both the source and destination.");
> return -EINVAL;
> }
> }
> @@ -3163,7 +3163,7 @@ static void rdma_accept_incoming_migration(void *opaque)
> ret = qemu_rdma_accept(rdma);
>
> if (ret) {
> - ERROR(errp, "RDMA Migration initialization failed!\n");
> + ERROR(errp, "RDMA Migration initialization failed!");
> return;
> }
>
> @@ -3171,7 +3171,7 @@ static void rdma_accept_incoming_migration(void *opaque)
>
> f = qemu_fopen_rdma(rdma, "rb");
> if (f == NULL) {
> - ERROR(errp, "could not qemu_fopen_rdma!\n");
> + ERROR(errp, "could not qemu_fopen_rdma!");
> qemu_rdma_cleanup(rdma);
> return;
> }
> @@ -3204,7 +3204,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp)
> ret = rdma_listen(rdma->listen_id, 5);
>
> if (ret) {
> - ERROR(errp, "listening on socket!\n");
> + ERROR(errp, "listening on socket!");
> goto err;
> }
>
> @@ -3228,7 +3228,7 @@ void rdma_start_outgoing_migration(void *opaque,
> int ret = 0;
>
> if (rdma == NULL) {
> - ERROR(temp, "Failed to initialize RDMA data structures! %d\n", ret);
> + ERROR(temp, "Failed to initialize RDMA data structures! %d", ret);
> goto err;
> }
>
>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work
2013-08-07 8:39 ` Orit Wasserman
@ 2013-08-07 14:53 ` Michael R. Hines
0 siblings, 0 replies; 13+ messages in thread
From: Michael R. Hines @ 2013-08-07 14:53 UTC (permalink / raw)
To: Orit Wasserman
Cc: yamahata, aliguori, quintela, qemu-devel, mrhines, pbonzini
On 08/07/2013 04:39 AM, Orit Wasserman wrote:
> On 08/04/2013 05:54 AM, mrhines@linux.vnet.ibm.com wrote:
>> From: "Michael R. Hines" <mrhines@us.ibm.com>
>>
>> RDMA does not use sockets, so we cannot use many of the socket
>> helper functions, but we *do* use inet_parse() which gives
>> RDMA all the necessary details of the connection parameters.
>>
>> However, when testing with libvirt, a simple IPv6 migration test failed
>> because we were not using getaddrinfo() properly.
>>
>> This makes IPv6 migration over RDMA work.
>>
>> Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
>> ---
>> migration-rdma.c | 33 +++++++++++++++++++++------------
>> 1 file changed, 21 insertions(+), 12 deletions(-)
>>
>> diff --git a/migration-rdma.c b/migration-rdma.c
>> index d044830..9cf73e3 100644
>> --- a/migration-rdma.c
>> +++ b/migration-rdma.c
>> @@ -392,6 +392,7 @@ typedef struct RDMAContext {
>> uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX];
>>
>> GHashTable *blockmap;
>> + bool ipv6;
>> } RDMAContext;
>>
>> /*
>> @@ -744,6 +745,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
>> char port_str[16];
>> struct rdma_cm_event *cm_event;
>> char ip[40] = "unknown";
>> + int af = rdma->ipv6 ? PF_INET6 : PF_INET;
>>
>> if (rdma->host == NULL || !strcmp(rdma->host, "")) {
>> ERROR(errp, "RDMA hostname has not been set\n");
>> @@ -773,7 +775,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
>> goto err_resolve_get_addr;
>> }
>>
>> - inet_ntop(AF_INET, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
>> + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
>> ip, sizeof ip);
>> DPRINTF("%s => %s\n", rdma->host, ip);
>>
>> @@ -2236,9 +2238,12 @@ err_rdma_source_connect:
>> static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
>> {
>> int ret = -EINVAL, idx;
>> + int af = rdma->ipv6 ? PF_INET6 : PF_INET;
>> struct sockaddr_in sin;
>> struct rdma_cm_id *listen_id;
>> char ip[40] = "unknown";
>> + struct addrinfo *res;
>> + char port_str[16];
>>
>> for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
>> rdma->wr_data[idx].control_len = 0;
>> @@ -2266,27 +2271,30 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
>> }
>>
>> memset(&sin, 0, sizeof(sin));
>> - sin.sin_family = AF_INET;
>> + sin.sin_family = af;
>> sin.sin_port = htons(rdma->port);
>> + snprintf(port_str, 16, "%d", rdma->port);
>> + port_str[15] = '\0';
>>
>> if (rdma->host && strcmp("", rdma->host)) {
>> - struct hostent *dest_addr;
>> - dest_addr = gethostbyname(rdma->host);
>> - if (!dest_addr) {
>> - ERROR(errp, "migration could not gethostbyname!\n");
>> - ret = -EINVAL;
>> + ret = getaddrinfo(rdma->host, port_str, NULL, &res);
> Hi Michael,
>
> getaddrinfo can return a list of addresses, you need to handle it.
> Look at qemu-sockets.c for example.
>
> Regards,
> Orit
>> + if (ret < 0) {
>> + ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
>> goto err_dest_init_bind_addr;
>> }
>> - memcpy(&sin.sin_addr.s_addr, dest_addr->h_addr,
>> - dest_addr->h_length);
>> - inet_ntop(AF_INET, dest_addr->h_addr, ip, sizeof ip);
>> +
>> +
>> + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
>> + ip, sizeof ip);
>> } else {
>> - sin.sin_addr.s_addr = INADDR_ANY;
>> + ERROR(errp, "migration host and port not specified!\n");
>> + ret = -EINVAL;
>> + goto err_dest_init_bind_addr;
>> }
>>
>> DPRINTF("%s => %s\n", rdma->host, ip);
>>
>> - ret = rdma_bind_addr(listen_id, (struct sockaddr *)&sin);
>> + ret = rdma_bind_addr(listen_id, res->ai_addr);
>> if (ret) {
>> ERROR(errp, "Error: could not rdma_bind_addr!\n");
>> goto err_dest_init_bind_addr;
>> @@ -2321,6 +2329,7 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
>> if (addr != NULL) {
>> rdma->port = atoi(addr->port);
>> rdma->host = g_strdup(addr->host);
>> + rdma->ipv6 = addr->ipv6;
>> } else {
>> ERROR(errp, "bad RDMA migration address '%s'", host_port);
>> g_free(rdma);
>>
>
Acknowledged.
- Michael
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
` (6 preceding siblings ...)
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 7/7] rdma: memory leak RDMAContext::host mrhines
@ 2013-08-14 16:27 ` Anthony Liguori
7 siblings, 0 replies; 13+ messages in thread
From: Anthony Liguori @ 2013-08-14 16:27 UTC (permalink / raw)
To: mrhines, qemu-devel
Cc: yamahata, aliguori, quintela, owasserm, mrhines, pbonzini
Applied. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-08-14 16:28 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work mrhines
2013-08-07 8:39 ` Orit Wasserman
2013-08-07 14:53 ` Michael R. Hines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 2/7] rdma: forgot to turn off the debugging flag mrhines
2013-08-07 8:39 ` Orit Wasserman
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 3/7] rdma: correct newlines in error statements mrhines
2013-08-07 8:45 ` Orit Wasserman
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 4/7] rdma: don't use negative index to array mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 5/7] rdma: qemu_rdma_post_send_control uses wrongly RDMA_WRID_MAX mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 6/7] rdma: use RDMA_WRID_READY mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 7/7] rdma: memory leak RDMAContext::host mrhines
2013-08-14 16:27 ` [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support Anthony Liguori
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).