[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 44/53] migration/rdma: Convert qemu_rdma_alloc_pd_cq() to Erro
From: |
Markus Armbruster |
Subject: |
[PATCH v2 44/53] migration/rdma: Convert qemu_rdma_alloc_pd_cq() to Error |
Date: |
Thu, 28 Sep 2023 15:20:10 +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_source_init() violates this principle: it calls
error_report() via qemu_rdma_alloc_pd_cq(). I elected not to
investigate how callers handle the error, i.e. precise impact is not
known.
Clean this up by converting qemu_rdma_alloc_pd_cq() to Error.
The conversion loses a piece of advice on one of two failure paths:
Your mlock() limits may be too low. Please check $ ulimit -a # and search
for 'ulimit -l' in the output
Not worth retaining.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
---
migration/rdma.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 336a960006..44d8202ad0 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -1052,19 +1052,19 @@ err_resolve_create_id:
/*
* Create protection domain and completion queues
*/
-static int qemu_rdma_alloc_pd_cq(RDMAContext *rdma)
+static int qemu_rdma_alloc_pd_cq(RDMAContext *rdma, Error **errp)
{
/* allocate pd */
rdma->pd = ibv_alloc_pd(rdma->verbs);
if (!rdma->pd) {
- error_report("failed to allocate protection domain");
+ error_setg(errp, "failed to allocate protection domain");
return -1;
}
/* create receive completion channel */
rdma->recv_comp_channel = ibv_create_comp_channel(rdma->verbs);
if (!rdma->recv_comp_channel) {
- error_report("failed to allocate receive completion channel");
+ error_setg(errp, "failed to allocate receive completion channel");
goto err_alloc_pd_cq;
}
@@ -1074,21 +1074,21 @@ static int qemu_rdma_alloc_pd_cq(RDMAContext *rdma)
rdma->recv_cq = ibv_create_cq(rdma->verbs, (RDMA_SIGNALED_SEND_MAX * 3),
NULL, rdma->recv_comp_channel, 0);
if (!rdma->recv_cq) {
- error_report("failed to allocate receive completion queue");
+ error_setg(errp, "failed to allocate receive completion queue");
goto err_alloc_pd_cq;
}
/* create send completion channel */
rdma->send_comp_channel = ibv_create_comp_channel(rdma->verbs);
if (!rdma->send_comp_channel) {
- error_report("failed to allocate send completion channel");
+ error_setg(errp, "failed to allocate send completion channel");
goto err_alloc_pd_cq;
}
rdma->send_cq = ibv_create_cq(rdma->verbs, (RDMA_SIGNALED_SEND_MAX * 3),
NULL, rdma->send_comp_channel, 0);
if (!rdma->send_cq) {
- error_report("failed to allocate send completion queue");
+ error_setg(errp, "failed to allocate send completion queue");
goto err_alloc_pd_cq;
}
@@ -2486,12 +2486,8 @@ static int qemu_rdma_source_init(RDMAContext *rdma, bool
pin_all, Error **errp)
goto err_rdma_source_init;
}
- ret = qemu_rdma_alloc_pd_cq(rdma);
+ ret = qemu_rdma_alloc_pd_cq(rdma, errp);
if (ret < 0) {
- error_setg(errp, "RDMA ERROR: "
- "rdma migration: error allocating pd and cq! Your mlock()"
- " limits may be too low. Please check $ ulimit -a # and "
- "search for 'ulimit -l' in the output");
goto err_rdma_source_init;
}
@@ -3477,9 +3473,9 @@ static int qemu_rdma_accept(RDMAContext *rdma)
qemu_rdma_dump_id("dest_init", verbs);
- ret = qemu_rdma_alloc_pd_cq(rdma);
+ ret = qemu_rdma_alloc_pd_cq(rdma, &err);
if (ret < 0) {
- error_report("rdma migration: error allocating pd and cq!");
+ error_report_err(err);
goto err_rdma_dest_wait;
}
--
2.41.0
- Re: [PATCH v2 52/53] migration/rdma: Use error_report() & friends instead of stderr, (continued)
- [PATCH v2 22/53] migration/rdma: Drop dead qemu_rdma_data_init() code for !@host_port, Markus Armbruster, 2023/09/28
- [PATCH v2 45/53] migration/rdma: Silence qemu_rdma_resolve_host(), Markus Armbruster, 2023/09/28
- [PATCH v2 40/53] migration/rdma: Convert qemu_rdma_write_one() to Error, Markus Armbruster, 2023/09/28
- [PATCH v2 50/53] migration/rdma: Silence qemu_rdma_register_and_get_keys(), Markus Armbruster, 2023/09/28
- [PATCH v2 27/53] migration/rdma: Replace int error_state by bool errored, Markus Armbruster, 2023/09/28
- [PATCH v2 16/53] migration/rdma: Fix or document problematic uses of errno, Markus Armbruster, 2023/09/28
- [PATCH v2 14/53] migration/rdma: Make qemu_rdma_buffer_mergeable() return bool, Markus Armbruster, 2023/09/28
- [PATCH v2 44/53] migration/rdma: Convert qemu_rdma_alloc_pd_cq() to Error,
Markus Armbruster <=
- [PATCH v2 48/53] migration/rdma: Don't report received completion events as error, Markus Armbruster, 2023/09/28
- [PATCH v2 37/53] migration/rdma: Convert qemu_rdma_exchange_get_response() to Error, Markus Armbruster, 2023/09/28
- [PATCH v2 51/53] migration/rdma: Downgrade qemu_rdma_cleanup() errors to warnings, Markus Armbruster, 2023/09/28
- [PATCH v2 53/53] migration/rdma: Replace flawed device detail dump by tracing, Markus Armbruster, 2023/09/28
- [PATCH v2 49/53] migration/rdma: Silence qemu_rdma_block_for_wrid(), Markus Armbruster, 2023/09/28
- [PATCH v2 47/53] migration/rdma: Silence qemu_rdma_reg_control(), Markus Armbruster, 2023/09/28