[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 59/65] migration/rdma: Use error_report() & friends instead of std
From: |
Juan Quintela |
Subject: |
[PULL 59/65] migration/rdma: Use error_report() & friends instead of stderr |
Date: |
Wed, 11 Oct 2023 11:21:57 +0200 |
From: Markus Armbruster <armbru@redhat.com>
error_report() obeys -msg, reports the current error location if any,
and reports to the current monitor if any. Reporting to stderr
directly with fprintf() or perror() is wrong, because it loses all
this.
Fix the offenders. Bonus: resolves a FIXME about problematic use of
errno.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20230928132019.2544702-53-armbru@redhat.com>
---
migration/rdma.c | 44 +++++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 9d5b3b76eb..ab2ea85c45 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -877,12 +877,12 @@ static int qemu_rdma_broken_ipv6_kernel(struct
ibv_context *verbs, Error **errp)
if (roce_found) {
if (ib_found) {
- fprintf(stderr, "WARN: migrations may fail:"
- " IPv6 over RoCE / iWARP in linux"
- " is broken. But since you appear to have a"
- " mixed RoCE / IB environment, be sure to only"
- " migrate over the IB fabric until the kernel "
- " fixes the bug.\n");
+ warn_report("migrations may fail:"
+ " IPv6 over RoCE / iWARP in linux"
+ " is broken. But since you appear to have a"
+ " mixed RoCE / IB environment, be sure to only"
+ " migrate over the IB fabric until the kernel "
+ " fixes the bug.");
} else {
error_setg(errp, "RDMA ERROR: "
"You only have RoCE / iWARP devices in your systems"
@@ -1418,12 +1418,8 @@ static int qemu_rdma_unregister_waiting(RDMAContext
*rdma)
block->remote_keys[chunk] = 0;
if (ret != 0) {
- /*
- * FIXME perror() is problematic, bcause ibv_dereg_mr() is
- * not documented to set errno. Will go away later in
- * this series.
- */
- perror("unregistration chunk failed");
+ error_report("unregistration chunk failed: %s",
+ strerror(ret));
return -1;
}
rdma->total_registrations--;
@@ -3772,7 +3768,8 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
block->pmr[reg->key.chunk] = NULL;
if (ret != 0) {
- perror("rdma unregistration chunk failed");
+ error_report("rdma unregistration chunk failed: %s",
+ strerror(errno));
goto err;
}
@@ -3961,10 +3958,10 @@ static int qemu_rdma_registration_stop(QEMUFile *f,
*/
if (local->nb_blocks != nb_dest_blocks) {
- fprintf(stderr, "ram blocks mismatch (Number of blocks %d vs %d) "
- "Your QEMU command line parameters are probably "
- "not identical on both the source and destination.",
- local->nb_blocks, nb_dest_blocks);
+ error_report("ram blocks mismatch (Number of blocks %d vs %d)",
+ local->nb_blocks, nb_dest_blocks);
+ error_printf("Your QEMU command line parameters are probably "
+ "not identical on both the source and destination.");
rdma->errored = true;
return -1;
}
@@ -3977,10 +3974,11 @@ static int qemu_rdma_registration_stop(QEMUFile *f,
/* We require that the blocks are in the same order */
if (rdma->dest_blocks[i].length != local->block[i].length) {
- fprintf(stderr, "Block %s/%d has a different length %" PRIu64
- "vs %" PRIu64, local->block[i].block_name, i,
- local->block[i].length,
- rdma->dest_blocks[i].length);
+ error_report("Block %s/%d has a different length %" PRIu64
+ "vs %" PRIu64,
+ local->block[i].block_name, i,
+ local->block[i].length,
+ rdma->dest_blocks[i].length);
rdma->errored = true;
return -1;
}
@@ -4096,7 +4094,7 @@ static void rdma_accept_incoming_migration(void *opaque)
ret = qemu_rdma_accept(rdma);
if (ret < 0) {
- fprintf(stderr, "RDMA ERROR: Migration initialization failed\n");
+ error_report("RDMA ERROR: Migration initialization failed");
return;
}
@@ -4108,7 +4106,7 @@ static void rdma_accept_incoming_migration(void *opaque)
f = rdma_new_input(rdma);
if (f == NULL) {
- fprintf(stderr, "RDMA ERROR: could not open RDMA for input\n");
+ error_report("RDMA ERROR: could not open RDMA for input");
qemu_rdma_cleanup(rdma);
return;
}
--
2.41.0
- [PULL 45/65] migration/rdma: Convert qemu_rdma_reg_whole_ram_blocks() to Error, (continued)
- [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
- [PULL 59/65] migration/rdma: Use error_report() & friends instead of stderr,
Juan Quintela <=
- [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
- [PULL 60/65] migration/rdma: Replace flawed device detail dump by tracing, Juan Quintela, 2023/10/11
- [PULL 63/65] qemufile: Always return a verbose error, Juan Quintela, 2023/10/11
- [PULL 65/65] migration: Add migration_rp_wait|kick(), Juan Quintela, 2023/10/11
- Re: [PULL 00/65] Migration 20231011 patches, Stefan Hajnoczi, 2023/10/11