[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 49/65] migration/rdma: Convert qemu_rdma_post_send_control() to Er
From: |
Juan Quintela |
Subject: |
[PULL 49/65] migration/rdma: Convert qemu_rdma_post_send_control() to Error |
Date: |
Wed, 11 Oct 2023 11:21:47 +0200 |
From: Markus Armbruster <armbru@redhat.com>
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>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20230928132019.2544702-43-armbru@redhat.com>
---
migration/rdma.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 9f45f6a91d..aeb0a8921e 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;
}
@@ -1945,10 +1946,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;
}
@@ -2002,10 +2002,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;
}
@@ -2394,6 +2393,7 @@ static int qemu_rdma_write(RDMAContext *rdma,
static void qemu_rdma_cleanup(RDMAContext *rdma)
{
+ Error *err = NULL;
int idx;
if (rdma->cm_id && rdma->connected) {
@@ -2405,7 +2405,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);
@@ -3705,10 +3707,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;
}
@@ -3783,10 +3786,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;
@@ -3818,10 +3821,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
- [PULL 38/65] migration/rdma: Delete inappropriate error_report() in macro ERROR(), (continued)
- [PULL 38/65] migration/rdma: Delete inappropriate error_report() in macro ERROR(), Juan Quintela, 2023/10/11
- [PULL 41/65] migration/rdma: Drop "@errp is clear" guards around error_setg(), Juan Quintela, 2023/10/11
- [PULL 43/65] migration/rdma: Convert qemu_rdma_exchange_send() to Error, Juan Quintela, 2023/10/11
- [PULL 39/65] migration/rdma: Retire macro ERROR(), Juan Quintela, 2023/10/11
- [PULL 44/65] migration/rdma: Convert qemu_rdma_exchange_get_response() to Error, Juan Quintela, 2023/10/11
- [PULL 40/65] migration/rdma: Fix error handling around rdma_getaddrinfo(), Juan Quintela, 2023/10/11
- [PULL 42/65] migration/rdma: Convert qemu_rdma_exchange_recv() to Error, Juan Quintela, 2023/10/11
- [PULL 46/65] migration/rdma: Convert qemu_rdma_write_flush() to Error, Juan Quintela, 2023/10/11
- [PULL 48/65] migration/rdma: Convert qemu_rdma_write() to Error, Juan Quintela, 2023/10/11
- [PULL 47/65] migration/rdma: Convert qemu_rdma_write_one() to Error, Juan Quintela, 2023/10/11
- [PULL 49/65] migration/rdma: Convert qemu_rdma_post_send_control() to Error,
Juan Quintela <=
- [PULL 45/65] migration/rdma: Convert qemu_rdma_reg_whole_ram_blocks() to Error, Juan Quintela, 2023/10/11
- [PULL 50/65] migration/rdma: Convert qemu_rdma_post_recv_control() to Error, Juan Quintela, 2023/10/11
- [PULL 51/65] migration/rdma: Convert qemu_rdma_alloc_pd_cq() to Error, Juan Quintela, 2023/10/11
- [PULL 53/65] migration/rdma: Silence qemu_rdma_connect(), Juan Quintela, 2023/10/11
- [PULL 52/65] migration/rdma: Silence qemu_rdma_resolve_host(), Juan Quintela, 2023/10/11
- [PULL 55/65] migration/rdma: Don't report received completion events as error, Juan Quintela, 2023/10/11
- [PULL 54/65] migration/rdma: Silence qemu_rdma_reg_control(), Juan Quintela, 2023/10/11
- [PULL 57/65] migration/rdma: Silence qemu_rdma_register_and_get_keys(), Juan Quintela, 2023/10/11
- [PULL 56/65] migration/rdma: Silence qemu_rdma_block_for_wrid(), Juan Quintela, 2023/10/11
- [PULL 58/65] migration/rdma: Downgrade qemu_rdma_cleanup() errors to warnings, Juan Quintela, 2023/10/11