[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/13] migration/rdma: clean up qemu_rdma_dest_init a
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 02/13] migration/rdma: clean up qemu_rdma_dest_init a bit |
Date: |
Tue, 17 Mar 2015 16:30:24 +0100 |
From: Michael Tokarev <address@hidden>
Do not check for rdma->host being empty twice. This removes a large
"if" block, so code indentation is changed. While at it, remove an
ugly goto from the loop, replacing it with a cleaner if logic. And
finally, there's no need to initialize `ret' variable since is always
has a value.
Signed-off-by: Michael Tokarev <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Tested-by: Dr. David Alan Gilbert <address@hidden>
--
fixed space detected by Dave
Signed-off-by: Juan Quintela <address@hidden>
---
migration/rdma.c | 51 ++++++++++++++++++++++-----------------------------
1 file changed, 22 insertions(+), 29 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index d1c19ff..5dd4863 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -2364,10 +2364,10 @@ err_rdma_source_connect:
static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
{
- int ret = -EINVAL, idx;
+ int ret, idx;
struct rdma_cm_id *listen_id;
char ip[40] = "unknown";
- struct rdma_addrinfo *res;
+ struct rdma_addrinfo *res, *e;
char port_str[16];
for (idx = 0; idx < RDMA_WRID_MAX; idx++) {
@@ -2375,7 +2375,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error
**errp)
rdma->wr_data[idx].control_curr = NULL;
}
- if (rdma->host == NULL) {
+ if (!rdma->host || !rdma->host[0]) {
ERROR(errp, "RDMA host is not set!");
rdma->error_state = -EINVAL;
return -1;
@@ -2398,40 +2398,33 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error
**errp)
snprintf(port_str, 16, "%d", rdma->port);
port_str[15] = '\0';
- if (rdma->host && strcmp("", rdma->host)) {
- struct rdma_addrinfo *e;
+ ret = rdma_getaddrinfo(rdma->host, port_str, NULL, &res);
+ if (ret < 0) {
+ ERROR(errp, "could not rdma_getaddrinfo address %s", rdma->host);
+ goto err_dest_init_bind_addr;
+ }
- ret = rdma_getaddrinfo(rdma->host, port_str, NULL, &res);
- if (ret < 0) {
- ERROR(errp, "could not rdma_getaddrinfo address %s", rdma->host);
- goto err_dest_init_bind_addr;
+ for (e = res; e != NULL; e = e->ai_next) {
+ inet_ntop(e->ai_family,
+ &((struct sockaddr_in *) e->ai_dst_addr)->sin_addr, ip, sizeof ip);
+ trace_qemu_rdma_dest_init_trying(rdma->host, ip);
+ ret = rdma_bind_addr(listen_id, e->ai_dst_addr);
+ if (ret) {
+ continue;
}
-
- for (e = res; e != NULL; e = e->ai_next) {
- inet_ntop(e->ai_family,
- &((struct sockaddr_in *) e->ai_dst_addr)->sin_addr, ip, sizeof
ip);
- trace_qemu_rdma_dest_init_trying(rdma->host, ip);
- ret = rdma_bind_addr(listen_id, e->ai_dst_addr);
- if (!ret) {
- if (e->ai_family == AF_INET6) {
- ret = qemu_rdma_broken_ipv6_kernel(errp, listen_id->verbs);
- if (ret) {
- continue;
- }
- }
-
- goto listen;
+ if (e->ai_family == AF_INET6) {
+ ret = qemu_rdma_broken_ipv6_kernel(errp, listen_id->verbs);
+ if (ret) {
+ continue;
}
}
+ break;
+ }
+ if (!e) {
ERROR(errp, "Error: could not rdma_bind_addr!");
goto err_dest_init_bind_addr;
- } else {
- ERROR(errp, "migration host and port not specified!");
- ret = -EINVAL;
- goto err_dest_init_bind_addr;
}
-listen:
rdma->listen_id = listen_id;
qemu_rdma_dump_gid("dest_init", listen_id);
--
2.1.0
- [Qemu-devel] [PULL 00/13] migration pull queue, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 03/13] migration: Fix some 32 bit compiler errors, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 01/13] migration: Avoid qerror_report_err() outside QMP command handlers, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 06/13] Warn against the use of the string as uri parameter to migrate-incoming, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 02/13] migration/rdma: clean up qemu_rdma_dest_init a bit,
Juan Quintela <=
- [Qemu-devel] [PULL 04/13] migration: Fix remaining 32 bit compiler errors, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 05/13] migrate_incoming: use hmp_handle_error, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 07/13] migrate_incoming: Cleanup/clarify error messages, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 10/13] migration: Rename abbreviated macro MIG_STATE_* to MIGRATION_STATUS_*, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 09/13] migration: Remove unused functions, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 12/13] migration: Convert 'status' of MigrationInfo to use an enum type, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 11/13] hmp: Rename 'MigrationStatus' to 'HMPMigrationStatus', Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 13/13] migration: Expose 'cancelling' status to user, Juan Quintela, 2015/03/17
- [Qemu-devel] [PULL 08/13] arch_init: Count the total number of pages by using helper function, Juan Quintela, 2015/03/17
- Re: [Qemu-devel] [PULL 00/13] migration pull queue, Peter Maydell, 2015/03/17