[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 53/65] migration/rdma: Silence qemu_rdma_connect()
|
From: |
Juan Quintela |
|
Subject: |
[PULL 53/65] migration/rdma: Silence qemu_rdma_connect() |
|
Date: |
Wed, 11 Oct 2023 11:21:51 +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_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>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20230928132019.2544702-47-armbru@redhat.com>
---
migration/rdma.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 3c7a407d25..8e1e8c4d47 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -2608,8 +2608,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;
}
@@ -2618,21 +2618,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
- [PULL 44/65] migration/rdma: Convert qemu_rdma_exchange_get_response() to Error, (continued)
- [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, 2023/10/11
- [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 <=
- [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
- [PULL 59/65] migration/rdma: Use error_report() & friends instead of stderr, Juan Quintela, 2023/10/11
- [PULL 62/65] migration: Introduce migrate_has_error(), Juan Quintela, 2023/10/11
- [PULL 64/65] migration: Remember num of ramblocks to sync during recovery, Juan Quintela, 2023/10/11
- [PULL 61/65] migration: Display error in query-migrate irrelevant of status, Juan Quintela, 2023/10/11