libguestfs/0001-lib-flatten-extra-output-when-external-command-fails.patch
Richard W.M. Jones f1a7701278 Capture and raise qemu-img stderr
resolves: RHEL-92239
Ignore btrfs snapshots of roots
resolves: RHEL-93109
2025-05-27 17:10:57 +01:00

57 lines
1.7 KiB
Diff

From 406588d4a00a42b49278669e34643a9ecfa7ecd3 Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Tue, 20 May 2025 13:33:26 -0400
Subject: [PATCH] lib: flatten `extra` output when external command fails
Otherwise string output looks quite awkward
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
lib/errors.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/errors.c b/lib/errors.c
index 148d8da27..c391a6d84 100644
--- a/lib/errors.c
+++ b/lib/errors.c
@@ -536,18 +536,25 @@ guestfs_int_external_command_failed (guestfs_h *g, int status,
{
const size_t len = 80 + strlen (cmd_name);
CLEANUP_FREE char *status_string = safe_malloc (g, len);
+ CLEANUP_FREE char *extra_clean = NULL;
guestfs_int_exit_status_to_string (status, cmd_name, status_string, len);
+ if (extra) {
+ extra_clean = guestfs_int_replace_string(extra, "\n", " ");
+ if (!extra_clean)
+ g->abort_cb ();
+ }
+
if (g->verbose) {
- if (!extra)
+ if (!extra_clean)
error (g, _("%s, see debug messages above"), status_string);
else
error (g, _("%s: %s: %s, see debug messages above"),
- cmd_name, extra, status_string);
+ cmd_name, extra_clean, status_string);
}
else {
- if (!extra)
+ if (!extra_clean)
error (g, _("%s.\n"
"To see full error messages you may need to enable debugging.\n"
DEBUG_ADVICE),
@@ -556,6 +563,6 @@ guestfs_int_external_command_failed (guestfs_h *g, int status,
error (g, _("%s: %s: %s.\n"
"To see full error messages you may need to enable debugging.\n"
DEBUG_ADVICE),
- cmd_name, extra, status_string);
+ cmd_name, extra_clean, status_string);
}
}
--
2.47.1