[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 42/53] migration/rdma: Convert qemu_rdma_post_send_control() t
From: |
Markus Armbruster |
Subject: |
[PATCH v2 42/53] migration/rdma: Convert qemu_rdma_post_send_control() to Error |
Date: |
Thu, 28 Sep 2023 15:20:08 +0200 |
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_exchange_send() violates this principle: it calls
error_report() via qemu_rdma_post_send_control(). I elected not to
investigate how callers handle the error, i.e. precise impact is not
known.
Clean this up by converting qemu_rdma_post_send_control() to Error.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
---
migration/rdma.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 528f468dfb..ce56ba9b40 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -1741,7 +1741,8 @@ err_block_for_wrid:
* containing some data and block until the post completes.
*/
static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
- RDMAControlHeader *head)
+ RDMAControlHeader *head,
+ Error **errp)
{
int ret;
RDMAWorkRequestData *wr = &rdma->wr_data[RDMA_WRID_CONTROL];
@@ -1781,13 +1782,13 @@ static int qemu_rdma_post_send_control(RDMAContext
*rdma, uint8_t *buf,
ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
if (ret > 0) {
- error_report("Failed to use post IB SEND for control");
+ error_setg(errp, "Failed to use post IB SEND for control");
return -1;
}
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
if (ret < 0) {
- error_report("rdma migration: send polling control error");
+ error_setg(errp, "rdma migration: send polling control error");
return -1;
}
@@ -1944,10 +1945,9 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,
RDMAControlHeader *head,
/*
* Deliver the control message that was requested.
*/
- ret = qemu_rdma_post_send_control(rdma, data, head);
+ ret = qemu_rdma_post_send_control(rdma, data, head, errp);
if (ret < 0) {
- error_setg(errp, "Failed to send control buffer!");
return -1;
}
@@ -2001,10 +2001,9 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,
RDMAControlHeader *head,
/*
* Inform the source that we're ready to receive a message.
*/
- ret = qemu_rdma_post_send_control(rdma, NULL, &ready);
+ ret = qemu_rdma_post_send_control(rdma, NULL, &ready, errp);
if (ret < 0) {
- error_setg(errp, "Failed to send control buffer!");
return -1;
}
@@ -2377,6 +2376,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *rdma,
static void qemu_rdma_cleanup(RDMAContext *rdma)
{
+ Error *err = NULL;
int idx;
if (rdma->cm_id && rdma->connected) {
@@ -2388,7 +2388,9 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
.repeat = 1,
};
error_report("Early error. Sending error.");
- qemu_rdma_post_send_control(rdma, NULL, &head);
+ if (qemu_rdma_post_send_control(rdma, NULL, &head, &err) < 0) {
+ error_report_err(err);
+ }
}
rdma_disconnect(rdma->cm_id);
@@ -3700,10 +3702,11 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
ret = qemu_rdma_post_send_control(rdma,
- (uint8_t *) rdma->dest_blocks,
&blocks);
+ (uint8_t *) rdma->dest_blocks, &blocks,
+ &err);
if (ret < 0) {
- error_report("rdma migration: error sending remote info");
+ error_report_err(err);
goto err;
}
@@ -3778,10 +3781,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
}
ret = qemu_rdma_post_send_control(rdma,
- (uint8_t *) results, ®_resp);
+ (uint8_t *) results, ®_resp, &err);
if (ret < 0) {
- error_report("Failed to send control buffer");
+ error_report_err(err);
goto err;
}
break;
@@ -3813,10 +3816,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
reg->key.chunk);
}
- ret = qemu_rdma_post_send_control(rdma, NULL, &unreg_resp);
+ ret = qemu_rdma_post_send_control(rdma, NULL, &unreg_resp, &err);
if (ret < 0) {
- error_report("Failed to send control buffer");
+ error_report_err(err);
goto err;
}
break;
--
2.41.0
- [PATCH v2 38/53] migration/rdma: Convert qemu_rdma_reg_whole_ram_blocks() to Error, (continued)
- [PATCH v2 38/53] migration/rdma: Convert qemu_rdma_reg_whole_ram_blocks() to Error, Markus Armbruster, 2023/09/28
- [PATCH v2 05/53] migration/rdma: Consistently use uint64_t for work request IDs, Markus Armbruster, 2023/09/28
- [PATCH v2 03/53] migration/rdma: Clean up rdma_delete_block()'s return type, Markus Armbruster, 2023/09/28
- [PATCH v2 19/53] migration/rdma: Replace dangerous macro CHECK_ERROR_STATE(), Markus Armbruster, 2023/09/28
- [PATCH v2 32/53] migration/rdma: Retire macro ERROR(), Markus Armbruster, 2023/09/28
- [PATCH v2 46/53] migration/rdma: Silence qemu_rdma_connect(), Markus Armbruster, 2023/09/28
- [PATCH v2 31/53] migration/rdma: Delete inappropriate error_report() in macro ERROR(), Markus Armbruster, 2023/09/28
- [PATCH v2 43/53] migration/rdma: Convert qemu_rdma_post_recv_control() to Error, Markus Armbruster, 2023/09/28
- [PATCH v2 17/53] migration/rdma: Ditch useless numeric error codes in error messages, Markus Armbruster, 2023/09/28
- [PATCH v2 39/53] migration/rdma: Convert qemu_rdma_write_flush() to Error, Markus Armbruster, 2023/09/28
- [PATCH v2 42/53] migration/rdma: Convert qemu_rdma_post_send_control() to Error,
Markus Armbruster <=
- [PATCH v2 23/53] migration/rdma: Fix QEMUFileHooks method return values, Markus Armbruster, 2023/09/28
- [PATCH v2 24/53] migration/rdma: Fix rdma_getaddrinfo() error checking, Markus Armbruster, 2023/09/28
- [PATCH v2 10/53] migration/rdma: Put @errp parameter last, Markus Armbruster, 2023/09/28
- [PATCH v2 13/53] migration/rdma: Drop qemu_rdma_search_ram_block() error handling, Markus Armbruster, 2023/09/28
- [PATCH v2 06/53] migration/rdma: Fix unwanted integer truncation, Markus Armbruster, 2023/09/28
- [PATCH v2 29/53] migration/rdma: Check negative error values the same way everywhere, Markus Armbruster, 2023/09/28
- [PATCH v2 41/53] migration/rdma: Convert qemu_rdma_write() to Error, Markus Armbruster, 2023/09/28
- [PATCH v2 34/53] migration/rdma: Drop "@errp is clear" guards around error_setg(), Markus Armbruster, 2023/09/28