diff options
Diffstat (limited to 'migration/rdma.c')
-rw-r--r-- | migration/rdma.c | 168 |
1 files changed, 120 insertions, 48 deletions
diff --git a/migration/rdma.c b/migration/rdma.c index 6c0e6cda2c..4074509f06 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -40,13 +40,6 @@ #include "options.h" #include <poll.h> -#define ERROR(errp, fmt, ...) \ - do { \ - if (errp && (*(errp) == NULL)) { \ - error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \ - } \ - } while (0) - #define RDMA_RESOLVE_TIMEOUT_MS 10000 /* Do not merge data if larger than this. */ @@ -865,7 +858,10 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context *verbs, Error **errp) if (ibv_query_port(verbs, 1, &port_attr)) { ibv_close_device(verbs); - ERROR(errp, "Could not query initial IB port"); + if (errp && !*errp) { + error_setg(errp, + "RDMA ERROR: Could not query initial IB port"); + } return -1; } @@ -888,9 +884,12 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context *verbs, Error **errp) " migrate over the IB fabric until the kernel " " fixes the bug.\n"); } else { - ERROR(errp, "You only have RoCE / iWARP devices in your systems" - " and your management software has specified '[::]'" - ", but IPv6 over RoCE / iWARP is not supported in Linux."); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: " + "You only have RoCE / iWARP devices in your systems" + " and your management software has specified '[::]'" + ", but IPv6 over RoCE / iWARP is not supported in Linux."); + } return -1; } } @@ -906,13 +905,18 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context *verbs, Error **errp) /* IB ports start with 1, not 0 */ if (ibv_query_port(verbs, 1, &port_attr)) { - ERROR(errp, "Could not query initial IB port"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: Could not query initial IB port"); + } return -1; } if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) { - ERROR(errp, "Linux kernel's RoCE / iWARP does not support IPv6 " - "(but patches on linux-rdma in progress)"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: " + "Linux kernel's RoCE / iWARP does not support IPv6 " + "(but patches on linux-rdma in progress)"); + } return -1; } @@ -936,21 +940,27 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) struct rdma_addrinfo *e; if (rdma->host == NULL || !strcmp(rdma->host, "")) { - ERROR(errp, "RDMA hostname has not been set"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: 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"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: 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 < 0) { - ERROR(errp, "could not create channel id"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not create channel id"); + } goto err_resolve_create_id; } @@ -959,7 +969,10 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) ret = rdma_getaddrinfo(rdma->host, port_str, NULL, &res); if (ret) { - ERROR(errp, "could not rdma_getaddrinfo address %s", rdma->host); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not rdma_getaddrinfo address %s", + rdma->host); + } goto err_resolve_get_addr; } @@ -982,7 +995,10 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) } rdma_freeaddrinfo(res); - ERROR(errp, "could not resolve address %s", rdma->host); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not resolve address %s", + rdma->host); + } goto err_resolve_get_addr; route: @@ -991,13 +1007,18 @@ route: ret = rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - ERROR(errp, "could not perform event_addr_resolved"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: 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", - rdma_event_str(cm_event->event)); + if (errp && !*errp) { + error_setg(errp, + "RDMA ERROR: result not equal to event_addr_resolved %s", + rdma_event_str(cm_event->event)); + } error_report("rdma_resolve_addr"); rdma_ack_cm_event(cm_event); goto err_resolve_get_addr; @@ -1007,18 +1028,25 @@ route: /* resolve route */ ret = rdma_resolve_route(rdma->cm_id, RDMA_RESOLVE_TIMEOUT_MS); if (ret < 0) { - ERROR(errp, "could not resolve rdma route"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not resolve rdma route"); + } goto err_resolve_get_addr; } ret = rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - ERROR(errp, "could not perform event_route_resolved"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: 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", - rdma_event_str(cm_event->event)); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: " + "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; } @@ -2489,15 +2517,20 @@ static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **errp) ret = qemu_rdma_alloc_pd_cq(rdma); if (ret < 0) { - ERROR(errp, "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"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: " + "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"); + } goto err_rdma_source_init; } ret = qemu_rdma_alloc_qp(rdma); if (ret < 0) { - ERROR(errp, "rdma migration: error allocating qp!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: rdma migration: error allocating qp!"); + } goto err_rdma_source_init; } @@ -2514,8 +2547,11 @@ static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **errp) for (idx = 0; idx < RDMA_WRID_MAX; idx++) { ret = qemu_rdma_reg_control(rdma, idx); if (ret < 0) { - ERROR(errp, "rdma migration: error registering %d control!", - idx); + if (errp && !*errp) { + error_setg(errp, + "RDMA ERROR: rdma migration: error registering %d control!", + idx); + } goto err_rdma_source_init; } } @@ -2543,19 +2579,29 @@ static int qemu_get_cm_event_timeout(RDMAContext *rdma, } while (ret < 0 && errno == EINTR); if (ret == 0) { - ERROR(errp, "poll cm event timeout"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: poll cm event timeout"); + } return -1; } else if (ret < 0) { - ERROR(errp, "failed to poll cm event, errno=%i", errno); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: failed to poll cm event, errno=%i", + errno); + } return -1; } else if (poll_fd.revents & POLLIN) { if (rdma_get_cm_event(rdma->channel, cm_event) < 0) { - ERROR(errp, "failed to get cm event"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: failed to get cm event"); + } return -1; } return 0; } else { - ERROR(errp, "no POLLIN event, revent=%x", poll_fd.revents); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: no POLLIN event, revent=%x", + poll_fd.revents); + } return -1; } } @@ -2588,14 +2634,18 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool return_path, ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); if (ret < 0) { - ERROR(errp, "posting second control recv"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: posting second control recv"); + } goto err_rdma_source_connect; } ret = rdma_connect(rdma->cm_id, &conn_param); if (ret < 0) { perror("rdma_connect"); - ERROR(errp, "connecting to destination!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: connecting to destination!"); + } goto err_rdma_source_connect; } @@ -2604,7 +2654,9 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool return_path, } else { ret = rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - ERROR(errp, "failed to get cm event"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: failed to get cm event"); + } } } if (ret < 0) { @@ -2619,7 +2671,9 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool return_path, if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) { error_report("rdma_get_cm_event != EVENT_ESTABLISHED after rdma_connect"); - ERROR(errp, "connecting to destination!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: connecting to destination!"); + } rdma_ack_cm_event(cm_event); goto err_rdma_source_connect; } @@ -2666,14 +2720,18 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) } if (!rdma->host || !rdma->host[0]) { - ERROR(errp, "RDMA host is not set!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: RDMA host is not set!"); + } rdma->errored = true; return -1; } /* create CM channel */ rdma->channel = rdma_create_event_channel(); if (!rdma->channel) { - ERROR(errp, "could not create rdma event channel"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not create rdma event channel"); + } rdma->errored = true; return -1; } @@ -2681,7 +2739,9 @@ 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 < 0) { - ERROR(errp, "could not create cm_id!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not create cm_id!"); + } goto err_dest_init_create_listen_id; } @@ -2690,14 +2750,19 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) ret = rdma_getaddrinfo(rdma->host, port_str, NULL, &res); if (ret) { - ERROR(errp, "could not rdma_getaddrinfo address %s", rdma->host); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not rdma_getaddrinfo address %s", + rdma->host); + } goto err_dest_init_bind_addr; } ret = rdma_set_option(listen_id, RDMA_OPTION_ID, RDMA_OPTION_ID_REUSEADDR, &reuse, sizeof reuse); if (ret < 0) { - ERROR(errp, "Error: could not set REUSEADDR option"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: Error: could not set REUSEADDR option"); + } goto err_dest_init_bind_addr; } for (e = res; e != NULL; e = e->ai_next) { @@ -2719,7 +2784,9 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) rdma_freeaddrinfo(res); if (!e) { - ERROR(errp, "Error: could not rdma_bind_addr!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: Error: could not rdma_bind_addr!"); + } goto err_dest_init_bind_addr; } @@ -2771,7 +2838,10 @@ static RDMAContext *qemu_rdma_data_init(const char *host_port, Error **errp) rdma->host = g_strdup(addr->host); rdma->host_port = g_strdup(host_port); } else { - ERROR(errp, "bad RDMA migration address '%s'", host_port); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: bad RDMA migration address '%s'", + host_port); + } g_free(rdma); rdma = NULL; } @@ -4145,7 +4215,9 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp) ret = rdma_listen(rdma->listen_id, 5); if (ret < 0) { - ERROR(errp, "listening on socket!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: listening on socket!"); + } goto cleanup_rdma; } |