migration/rdma: Fix qemu_get_cm_event_timeout() to always set error

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>
This commit is contained in:
Markus Armbruster 2023-09-28 15:19:47 +02:00 committed by Juan Quintela
parent 142bd685ae
commit f35c0d9b07

View File

@ -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;
@ -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) {
/*
@ -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;
}