提交 66988941 编写于 作者: M Michael R. Hines 提交者: Anthony Liguori

rdma: correct newlines in error statements

Don't print newlines on the error_setg() function,
but still allow newlines on fprintf().
Signed-off-by: NMichael R. Hines <mrhines@us.ibm.com>
Message-id: 1375584894-9917-4-git-send-email-mrhines@linux.vnet.ibm.com
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 8cd31adc
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
*/ */
#define ERROR(errp, fmt, ...) \ #define ERROR(errp, fmt, ...) \
do { \ do { \
fprintf(stderr, "RDMA ERROR: " fmt, ## __VA_ARGS__); \ fprintf(stderr, "RDMA ERROR: " fmt "\n", ## __VA_ARGS__); \
if (errp && (*(errp) == NULL)) { \ if (errp && (*(errp) == NULL)) { \
error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \ error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \
} \ } \
...@@ -748,21 +748,21 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) ...@@ -748,21 +748,21 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
int af = rdma->ipv6 ? PF_INET6 : PF_INET; int af = rdma->ipv6 ? PF_INET6 : PF_INET;
if (rdma->host == NULL || !strcmp(rdma->host, "")) { 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; return -1;
} }
/* create CM channel */ /* create CM channel */
rdma->channel = rdma_create_event_channel(); rdma->channel = rdma_create_event_channel();
if (!rdma->channel) { if (!rdma->channel) {
ERROR(errp, "could not create CM channel\n"); ERROR(errp, "could not create CM channel");
return -1; return -1;
} }
/* create CM id */ /* create CM id */
ret = rdma_create_id(rdma->channel, &rdma->cm_id, NULL, RDMA_PS_TCP); ret = rdma_create_id(rdma->channel, &rdma->cm_id, NULL, RDMA_PS_TCP);
if (ret) { if (ret) {
ERROR(errp, "could not create channel id\n"); ERROR(errp, "could not create channel id");
goto err_resolve_create_id; goto err_resolve_create_id;
} }
...@@ -771,7 +771,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) ...@@ -771,7 +771,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
ret = getaddrinfo(rdma->host, port_str, NULL, &res); ret = getaddrinfo(rdma->host, port_str, NULL, &res);
if (ret < 0) { 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; goto err_resolve_get_addr;
} }
...@@ -783,7 +783,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) ...@@ -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, ret = rdma_resolve_addr(rdma->cm_id, NULL, res->ai_addr,
RDMA_RESOLVE_TIMEOUT_MS); RDMA_RESOLVE_TIMEOUT_MS);
if (ret) { 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; goto err_resolve_get_addr;
} }
...@@ -791,12 +791,12 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) ...@@ -791,12 +791,12 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
ret = rdma_get_cm_event(rdma->channel, &cm_event); ret = rdma_get_cm_event(rdma->channel, &cm_event);
if (ret) { if (ret) {
ERROR(errp, "could not perform event_addr_resolved\n"); ERROR(errp, "could not perform event_addr_resolved");
goto err_resolve_get_addr; goto err_resolve_get_addr;
} }
if (cm_event->event != RDMA_CM_EVENT_ADDR_RESOLVED) { 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)); rdma_event_str(cm_event->event));
perror("rdma_resolve_addr"); perror("rdma_resolve_addr");
goto err_resolve_get_addr; goto err_resolve_get_addr;
...@@ -806,17 +806,17 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) ...@@ -806,17 +806,17 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
/* resolve route */ /* resolve route */
ret = rdma_resolve_route(rdma->cm_id, RDMA_RESOLVE_TIMEOUT_MS); ret = rdma_resolve_route(rdma->cm_id, RDMA_RESOLVE_TIMEOUT_MS);
if (ret) { if (ret) {
ERROR(errp, "could not resolve rdma route\n"); ERROR(errp, "could not resolve rdma route");
goto err_resolve_get_addr; goto err_resolve_get_addr;
} }
ret = rdma_get_cm_event(rdma->channel, &cm_event); ret = rdma_get_cm_event(rdma->channel, &cm_event);
if (ret) { if (ret) {
ERROR(errp, "could not perform event_route_resolved\n"); ERROR(errp, "could not perform event_route_resolved");
goto err_resolve_get_addr; goto err_resolve_get_addr;
} }
if (cm_event->event != RDMA_CM_EVENT_ROUTE_RESOLVED) { 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_event_str(cm_event->event));
rdma_ack_cm_event(cm_event); rdma_ack_cm_event(cm_event);
goto err_resolve_get_addr; goto err_resolve_get_addr;
...@@ -2117,26 +2117,26 @@ static int qemu_rdma_source_init(RDMAContext *rdma, Error **errp, bool pin_all) ...@@ -2117,26 +2117,26 @@ static int qemu_rdma_source_init(RDMAContext *rdma, Error **errp, bool pin_all)
if (ret) { if (ret) {
ERROR(temp, "rdma migration: error allocating pd and cq! Your mlock()" ERROR(temp, "rdma migration: error allocating pd and cq! Your mlock()"
" limits may be too low. Please check $ ulimit -a # and " " 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; goto err_rdma_source_init;
} }
ret = qemu_rdma_alloc_qp(rdma); ret = qemu_rdma_alloc_qp(rdma);
if (ret) { if (ret) {
ERROR(temp, "rdma migration: error allocating qp!\n"); ERROR(temp, "rdma migration: error allocating qp!");
goto err_rdma_source_init; goto err_rdma_source_init;
} }
ret = qemu_rdma_init_ram_blocks(rdma); ret = qemu_rdma_init_ram_blocks(rdma);
if (ret) { if (ret) {
ERROR(temp, "rdma migration: error initializing ram blocks!\n"); ERROR(temp, "rdma migration: error initializing ram blocks!");
goto err_rdma_source_init; 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); ret = qemu_rdma_reg_control(rdma, idx);
if (ret) { if (ret) {
ERROR(temp, "rdma migration: error registering %d control!\n", ERROR(temp, "rdma migration: error registering %d control!",
idx); idx);
goto err_rdma_source_init; goto err_rdma_source_init;
} }
...@@ -2178,7 +2178,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) ...@@ -2178,7 +2178,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
ret = rdma_connect(rdma->cm_id, &conn_param); ret = rdma_connect(rdma->cm_id, &conn_param);
if (ret) { if (ret) {
perror("rdma_connect"); perror("rdma_connect");
ERROR(errp, "connecting to destination!\n"); ERROR(errp, "connecting to destination!");
rdma_destroy_id(rdma->cm_id); rdma_destroy_id(rdma->cm_id);
rdma->cm_id = NULL; rdma->cm_id = NULL;
goto err_rdma_source_connect; goto err_rdma_source_connect;
...@@ -2187,7 +2187,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) ...@@ -2187,7 +2187,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
ret = rdma_get_cm_event(rdma->channel, &cm_event); ret = rdma_get_cm_event(rdma->channel, &cm_event);
if (ret) { if (ret) {
perror("rdma_get_cm_event after rdma_connect"); 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_ack_cm_event(cm_event);
rdma_destroy_id(rdma->cm_id); rdma_destroy_id(rdma->cm_id);
rdma->cm_id = NULL; rdma->cm_id = NULL;
...@@ -2196,7 +2196,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) ...@@ -2196,7 +2196,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) { if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) {
perror("rdma_get_cm_event != EVENT_ESTABLISHED after rdma_connect"); 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_ack_cm_event(cm_event);
rdma_destroy_id(rdma->cm_id); rdma_destroy_id(rdma->cm_id);
rdma->cm_id = NULL; rdma->cm_id = NULL;
...@@ -2212,7 +2212,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) ...@@ -2212,7 +2212,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
*/ */
if (rdma->pin_all && !(cap.flags & RDMA_CAPABILITY_PIN_ALL)) { if (rdma->pin_all && !(cap.flags & RDMA_CAPABILITY_PIN_ALL)) {
ERROR(errp, "Server cannot support pinning all memory. " ERROR(errp, "Server cannot support pinning all memory. "
"Will register memory dynamically.\n"); "Will register memory dynamically.");
rdma->pin_all = false; rdma->pin_all = false;
} }
...@@ -2222,7 +2222,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) ...@@ -2222,7 +2222,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
ret = qemu_rdma_post_recv_control(rdma, 0); ret = qemu_rdma_post_recv_control(rdma, 0);
if (ret) { if (ret) {
ERROR(errp, "posting second control recv!\n"); ERROR(errp, "posting second control recv!");
goto err_rdma_source_connect; goto err_rdma_source_connect;
} }
...@@ -2251,14 +2251,14 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) ...@@ -2251,14 +2251,14 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
} }
if (rdma->host == NULL) { if (rdma->host == NULL) {
ERROR(errp, "RDMA host is not set!\n"); ERROR(errp, "RDMA host is not set!");
rdma->error_state = -EINVAL; rdma->error_state = -EINVAL;
return -1; return -1;
} }
/* create CM channel */ /* create CM channel */
rdma->channel = rdma_create_event_channel(); rdma->channel = rdma_create_event_channel();
if (!rdma->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; rdma->error_state = -EINVAL;
return -1; return -1;
} }
...@@ -2266,7 +2266,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) ...@@ -2266,7 +2266,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
/* create CM id */ /* create CM id */
ret = rdma_create_id(rdma->channel, &listen_id, NULL, RDMA_PS_TCP); ret = rdma_create_id(rdma->channel, &listen_id, NULL, RDMA_PS_TCP);
if (ret) { if (ret) {
ERROR(errp, "could not create cm_id!\n"); ERROR(errp, "could not create cm_id!");
goto err_dest_init_create_listen_id; goto err_dest_init_create_listen_id;
} }
...@@ -2279,7 +2279,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) ...@@ -2279,7 +2279,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
if (rdma->host && strcmp("", rdma->host)) { if (rdma->host && strcmp("", rdma->host)) {
ret = getaddrinfo(rdma->host, port_str, NULL, &res); ret = getaddrinfo(rdma->host, port_str, NULL, &res);
if (ret < 0) { 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; goto err_dest_init_bind_addr;
} }
...@@ -2287,7 +2287,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) ...@@ -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, inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
ip, sizeof ip); ip, sizeof ip);
} else { } else {
ERROR(errp, "migration host and port not specified!\n"); ERROR(errp, "migration host and port not specified!");
ret = -EINVAL; ret = -EINVAL;
goto err_dest_init_bind_addr; goto err_dest_init_bind_addr;
} }
...@@ -2296,7 +2296,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) ...@@ -2296,7 +2296,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
ret = rdma_bind_addr(listen_id, res->ai_addr); ret = rdma_bind_addr(listen_id, res->ai_addr);
if (ret) { 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; goto err_dest_init_bind_addr;
} }
...@@ -3036,7 +3036,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque, ...@@ -3036,7 +3036,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
&reg_result_idx, rdma->pin_all ? &reg_result_idx, rdma->pin_all ?
qemu_rdma_reg_whole_ram_blocks : NULL); qemu_rdma_reg_whole_ram_blocks : NULL);
if (ret < 0) { if (ret < 0) {
ERROR(errp, "receiving remote info!\n"); ERROR(errp, "receiving remote info!");
return ret; return ret;
} }
...@@ -3061,7 +3061,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque, ...@@ -3061,7 +3061,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
if (local->nb_blocks != nb_remote_blocks) { if (local->nb_blocks != nb_remote_blocks) {
ERROR(errp, "ram blocks mismatch #1! " ERROR(errp, "ram blocks mismatch #1! "
"Your QEMU command line parameters are probably " "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; return -EINVAL;
} }
...@@ -3077,7 +3077,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque, ...@@ -3077,7 +3077,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
if (rdma->block[i].length != local->block[j].length) { if (rdma->block[i].length != local->block[j].length) {
ERROR(errp, "ram blocks mismatch #2! " ERROR(errp, "ram blocks mismatch #2! "
"Your QEMU command line parameters are probably " "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; return -EINVAL;
} }
local->block[j].remote_host_addr = local->block[j].remote_host_addr =
...@@ -3089,7 +3089,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque, ...@@ -3089,7 +3089,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
if (j >= local->nb_blocks) { if (j >= local->nb_blocks) {
ERROR(errp, "ram blocks mismatch #3! " ERROR(errp, "ram blocks mismatch #3! "
"Your QEMU command line parameters are probably " "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; return -EINVAL;
} }
} }
...@@ -3163,7 +3163,7 @@ static void rdma_accept_incoming_migration(void *opaque) ...@@ -3163,7 +3163,7 @@ static void rdma_accept_incoming_migration(void *opaque)
ret = qemu_rdma_accept(rdma); ret = qemu_rdma_accept(rdma);
if (ret) { if (ret) {
ERROR(errp, "RDMA Migration initialization failed!\n"); ERROR(errp, "RDMA Migration initialization failed!");
return; return;
} }
...@@ -3171,7 +3171,7 @@ static void rdma_accept_incoming_migration(void *opaque) ...@@ -3171,7 +3171,7 @@ static void rdma_accept_incoming_migration(void *opaque)
f = qemu_fopen_rdma(rdma, "rb"); f = qemu_fopen_rdma(rdma, "rb");
if (f == NULL) { if (f == NULL) {
ERROR(errp, "could not qemu_fopen_rdma!\n"); ERROR(errp, "could not qemu_fopen_rdma!");
qemu_rdma_cleanup(rdma); qemu_rdma_cleanup(rdma);
return; return;
} }
...@@ -3204,7 +3204,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp) ...@@ -3204,7 +3204,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp)
ret = rdma_listen(rdma->listen_id, 5); ret = rdma_listen(rdma->listen_id, 5);
if (ret) { if (ret) {
ERROR(errp, "listening on socket!\n"); ERROR(errp, "listening on socket!");
goto err; goto err;
} }
...@@ -3228,7 +3228,7 @@ void rdma_start_outgoing_migration(void *opaque, ...@@ -3228,7 +3228,7 @@ void rdma_start_outgoing_migration(void *opaque,
int ret = 0; int ret = 0;
if (rdma == NULL) { 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; goto err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册