[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 46/53] migration/rdma: Silence qemu_rdma_connect()
From: |
Markus Armbruster |
Subject: |
[PATCH v2 46/53] migration/rdma: Silence qemu_rdma_connect() |
Date: |
Thu, 28 Sep 2023 15:20:12 +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_connect() violates this principle: it calls error_report()
and perror(). I elected not to investigate how callers handle the
error, i.e. precise impact is not known.
Clean this up: replace perror() by changing error_setg() to
error_setg_errno(), and drop error_report(). I believe the callers'
error reports suffice then. If they don't, we need to convert to
Error instead.
Bonus: resolves a FIXME about problematic use of errno.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
---
migration/rdma.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 5e21dfca53..b85d5e60cb 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -2591,8 +2591,8 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool
return_path,
ret = rdma_connect(rdma->cm_id, &conn_param);
if (ret < 0) {
- perror("rdma_connect");
- error_setg(errp, "RDMA ERROR: connecting to destination!");
+ error_setg_errno(errp, errno,
+ "RDMA ERROR: connecting to destination!");
goto err_rdma_source_connect;
}
@@ -2601,21 +2601,15 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool
return_path,
} else {
ret = rdma_get_cm_event(rdma->channel, &cm_event);
if (ret < 0) {
- error_setg(errp, "RDMA ERROR: failed to get cm event");
+ error_setg_errno(errp, errno,
+ "RDMA ERROR: failed to get cm event");
}
}
if (ret < 0) {
- /*
- * FIXME perror() is wrong, because
- * qemu_get_cm_event_timeout() can fail without setting errno.
- * Will go away later in this series.
- */
- perror("rdma_get_cm_event after rdma_connect");
goto err_rdma_source_connect;
}
if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) {
- error_report("rdma_get_cm_event != EVENT_ESTABLISHED after
rdma_connect");
error_setg(errp, "RDMA ERROR: connecting to destination!");
rdma_ack_cm_event(cm_event);
goto err_rdma_source_connect;
--
2.41.0
- [PATCH v2 26/53] migration/rdma: Dumb down remaining int error values to -1, (continued)
- [PATCH v2 26/53] migration/rdma: Dumb down remaining int error values to -1, Markus Armbruster, 2023/09/28
- [PATCH v2 02/53] migration/rdma: Clean up qemu_rdma_data_init()'s return type, Markus Armbruster, 2023/09/28
- [PATCH v2 28/53] migration/rdma: Drop superfluous assignments to @ret, Markus Armbruster, 2023/09/28
- [PATCH v2 15/53] migration/rdma: Use bool for two RDMAContext flags, Markus Armbruster, 2023/09/28
- [PATCH v2 36/53] migration/rdma: Convert qemu_rdma_exchange_send() to Error, Markus Armbruster, 2023/09/28
- [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 <=
- [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, 2023/09/28
- [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