Skip to content

Commit

Permalink
migration/rdma: Fix qemu_get_cm_event_timeout() to always set error
Browse files Browse the repository at this point in the history
qemu_get_cm_event_timeout() neglects to set an error when it fails
because rdma_get_cm_event() fails.  Harmless, as its caller
qemu_rdma_connect() substitutes a generic error then.  Fix it anyway.

qemu_rdma_connect() also sets the generic error when its own call of
rdma_get_cm_event() fails.  Make the error handling more obvious: set
a specific error right after rdma_get_cm_event() fails.  Delete the
generic error.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20230928132019.2544702-22-armbru@redhat.com>
  • Loading branch information
Markus Armbruster authored and Juan Quintela committed Oct 11, 2023
1 parent 142bd68 commit f35c0d9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions migration/rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,11 @@ static int qemu_get_cm_event_timeout(RDMAContext *rdma,
ERROR(errp, "failed to poll cm event, errno=%i", errno);
return -1;
} else if (poll_fd.revents & POLLIN) {
return rdma_get_cm_event(rdma->channel, cm_event);
if (rdma_get_cm_event(rdma->channel, cm_event) < 0) {
ERROR(errp, "failed to get cm event");
return -1;
}
return 0;
} else {
ERROR(errp, "no POLLIN event, revent=%x", poll_fd.revents);
return -1;
Expand Down Expand Up @@ -2605,6 +2609,9 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool return_path,
ret = qemu_get_cm_event_timeout(rdma, &cm_event, 5000, errp);
} else {
ret = rdma_get_cm_event(rdma->channel, &cm_event);
if (ret < 0) {
ERROR(errp, "failed to get cm event");
}
}
if (ret) {
/*
Expand All @@ -2613,7 +2620,6 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool return_path,
* Will go away later in this series.
*/
perror("rdma_get_cm_event after rdma_connect");
ERROR(errp, "connecting to destination!");
goto err_rdma_source_connect;
}

Expand Down

0 comments on commit f35c0d9

Please sign in to comment.