Functions that use an Error **errp parameter to return errors should
not also report them to the user, because reporting is the caller's
job. When the caller does, the error is reported twice. When it
doesn't (because it recovered from the error), there is no error to
report, i.e. the report is bogus.
qemu_rdma_write_flush() violates this principle: it calls
error_report() via qemu_rdma_write_one(). I elected not to
investigate how callers handle the error, i.e. precise impact is not
known.
Clean this up by converting qemu_rdma_write_one() to Error.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
migration/rdma.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index c3c33fe242..9b8cbadfcd 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -2019,9 +2019,8 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma, RDMAControlHeader *head,
*/
static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma,
int current_index, uint64_t current_addr,
- uint64_t length)
+ uint64_t length, Error **errp)
{
- Error *err = NULL;
struct ibv_sge sge;
struct ibv_send_wr send_wr = { 0 };
struct ibv_send_wr *bad_wr;
@@ -2075,7 +2074,7 @@ retry:
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL);
if (ret < 0) {
- error_report("Failed to Wait for previous write to complete "
+ error_setg(errp, "Failed to Wait for previous write to complete "
"block %d chunk %" PRIu64
" current %" PRIu64 " len %" PRIu64 " %d",
current_index, chunk, sge.addr, length, rdma->nb_sent);
@@ -2107,10 +2106,9 @@ retry:
compress_to_network(rdma, &comp);
ret = qemu_rdma_exchange_send(rdma, &head,
- (uint8_t *) &comp, NULL, NULL, NULL, &err);
+ (uint8_t *) &comp, NULL, NULL, NULL, errp);
if (ret < 0) {
- error_report_err(err);
return -1;
}
@@ -2136,9 +2134,8 @@ retry:
register_to_network(rdma, ®);
ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®,
- &resp, ®_result_idx, NULL, &err);
+ &resp, ®_result_idx, NULL, errp);
if (ret < 0) {
- error_report_err(err);
return -1;
}
@@ -2146,7 +2143,7 @@ retry:
if (qemu_rdma_register_and_get_keys(rdma, block, sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
- error_report("cannot get lkey");
+ error_setg(errp, "cannot get lkey");
return -1;
}
@@ -2165,7 +2162,7 @@ retry:
if (qemu_rdma_register_and_get_keys(rdma, block, sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
- error_report("cannot get lkey!");
+ error_setg(errp, "cannot get lkey!");
return -1;
}
}
@@ -2177,7 +2174,7 @@ retry:
if (qemu_rdma_register_and_get_keys(rdma, block, sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
- error_report("cannot get lkey!");
+ error_setg(errp, "cannot get lkey!");
return -1;
}
}
@@ -2211,7 +2208,7 @@ retry:
trace_qemu_rdma_write_one_queue_full();
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL);
if (ret < 0) {
- error_report("rdma migration: failed to make "
+ error_setg(errp, "rdma migration: failed to make "
"room in full send queue!");
return -1;
}
@@ -2219,7 +2216,7 @@ retry:
goto retry;
} else if (ret > 0) {
- perror("rdma migration: post rdma write failed");
+ error_setg(errp, "rdma migration: post rdma write failed");
return -1;
}
@@ -2248,10 +2245,10 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMAContext *rdma,
}
ret = qemu_rdma_write_one(f, rdma,
- rdma->current_index, rdma->current_addr, rdma->current_length);
+ rdma->current_index, rdma->current_addr, rdma->current_length,
+ errp);
if (ret < 0) {
- error_setg(errp, "FIXME temporary error message");
return -1;
}
--
2.41.0