All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Dr. David Alan Gilbert" <dave@treblig.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>
Subject: [PATCH 15/21] util: capture warnings and errors in the data recorder
Date: Thu, 15 Oct 2026 12:20:38 +0100	[thread overview]
Message-ID: <20261015112044.1999748-16-berrange@redhat.com> (raw)
In-Reply-To: <20261015112044.1999748-1-berrange@redhat.com>

Any messages triggered at runtime for warn_report and error_report
are potentially interesting, so should be captured for the data
recorder. The most common expected scenario is use of any deprecated
features which are liable to trigger warn_report.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 MAINTAINERS          |  1 +
 stubs/meson.build    |  1 +
 stubs/monitor-puts.c |  9 +++++++++
 util/error-report.c  | 43 ++++++++++++++++++++++++-------------------
 4 files changed, 35 insertions(+), 19 deletions(-)
 create mode 100644 stubs/monitor-puts.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 54265d987cb..3a7cd827e66 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3566,6 +3566,7 @@ F: include/monitor/hmp-completion.h
 F: tests/qtest/test-hmp.c
 F: include/qemu/qemu-print.h
 F: util/qemu-print.c
+F: stubs/monitor-puts.c
 
 Network device backends
 M: Jason Wang <jasowangio@gmail.com>
diff --git a/stubs/meson.build b/stubs/meson.build
index 29b6644b254..52c733e32a9 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -9,6 +9,7 @@ stub_ss.add(files('is-daemonized.c'))
 stub_ss.add(files('monitor-core.c'))
 stub_ss.add(files('monitor-cur.c'))
 stub_ss.add(files('monitor-hmp.c'))
+stub_ss.add(files('monitor-puts.c'))
 stub_ss.add(files('qapi-event-emit.c'))
 stub_ss.add(files('replay-mode.c'))
 stub_ss.add(files('trace-control.c'))
diff --git a/stubs/monitor-puts.c b/stubs/monitor-puts.c
new file mode 100644
index 00000000000..bb9b726dd5e
--- /dev/null
+++ b/stubs/monitor-puts.c
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "qemu/osdep.h"
+#include "monitor/monitor.h"
+
+int monitor_puts(Monitor *mon, const char *str)
+{
+    g_assert_not_reached();
+}
diff --git a/util/error-report.c b/util/error-report.c
index 8932beebfb9..251d8b7d16e 100644
--- a/util/error-report.c
+++ b/util/error-report.c
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "monitor/hmp.h"
 #include "qemu/error-report.h"
+#include "qemu/tldr.h"
 
 /*
  * @report_type is the type of message: error, warning or
@@ -32,28 +33,32 @@ const char *error_guest_name;
 /*
  * Print to the @hmp monitor, else to stderr.
  */
-static int G_GNUC_PRINTF(2, 0)
-error_vprintf_hmp(MonitorHMP *hmp, const char *fmt, va_list ap)
+static int G_GNUC_PRINTF(3, 0)
+error_vprintf_hmp(MonitorHMP *hmp, bool tldr, const char *fmt, va_list ap)
 {
+    g_autofree char *str = g_strdup_vprintf(fmt, ap);
+    if (qtldr_msg_enabled(QTLDR_MSG_BUCKET_TYPE_ERROR) && tldr) {
+        qtldr_msg_record(QTLDR_MSG_BUCKET_TYPE_ERROR, str);
+    }
 #ifdef CONFIG_HMP
     if (hmp) {
-        return monitor_hmp_vprintf(hmp, fmt, ap);
+        return monitor_puts(MONITOR(hmp), str);
     }
 #endif
-    return vfprintf(stderr, fmt, ap);
+    return fwrite(str, 1, strlen(str), stderr);
 }
 
 /*
  * Print to the @hmp monitor, else to stderr.
  */
-static int G_GNUC_PRINTF(2, 3)
-error_printf_hmp(MonitorHMP *hmp, const char *fmt, ...)
+static int G_GNUC_PRINTF(3, 4)
+error_printf_hmp(MonitorHMP *hmp, bool tldr, const char *fmt, ...)
 {
     va_list ap;
     int ret;
 
     va_start(ap, fmt);
-    ret = error_vprintf_hmp(hmp, fmt, ap);
+    ret = error_vprintf_hmp(hmp, tldr, fmt, ap);
     va_end(ap);
     return ret;
 }
@@ -63,7 +68,7 @@ error_printf_hmp(MonitorHMP *hmp, const char *fmt, ...)
  */
 int error_vprintf(const char *fmt, va_list ap)
 {
-    return error_vprintf_hmp(monitor_cur_hmp(), fmt, ap);
+    return error_vprintf_hmp(monitor_cur_hmp(), true, fmt, ap);
 }
 
 /*
@@ -75,7 +80,7 @@ int error_printf(const char *fmt, ...)
     int ret;
 
     va_start(ap, fmt);
-    ret = error_vprintf_hmp(monitor_cur_hmp(), fmt, ap);
+    ret = error_vprintf_hmp(monitor_cur_hmp(), true, fmt, ap);
     va_end(ap);
     return ret;
 }
@@ -193,20 +198,20 @@ static void print_loc(MonitorHMP *hmp)
     case LOC_CMDLINE:
         argp = cur_loc->ptr;
         for (i = 0; i < cur_loc->num; i++) {
-            error_printf_hmp(hmp, "%s%s", sep, argp[i]);
+            error_printf_hmp(hmp, false, "%s%s", sep, argp[i]);
             sep = " ";
         }
-        error_printf_hmp(hmp, ": ");
+        error_printf_hmp(hmp, false, ": ");
         break;
     case LOC_FILE:
-        error_printf_hmp(hmp, "%s:", (const char *)cur_loc->ptr);
+        error_printf_hmp(hmp, false, "%s:", (const char *)cur_loc->ptr);
         if (cur_loc->num) {
-            error_printf_hmp(hmp, "%d:", cur_loc->num);
+            error_printf_hmp(hmp, false, "%d:", cur_loc->num);
         }
-        error_printf_hmp(hmp, " ");
+        error_printf_hmp(hmp, false, " ");
         break;
     default:
-        error_printf_hmp(hmp, "%s", sep);
+        error_printf_hmp(hmp, false, "%s", sep);
     }
 }
 
@@ -251,15 +256,15 @@ static void vreport(report_type type, const char *fmt, va_list ap)
     case REPORT_TYPE_ERROR:
         break;
     case REPORT_TYPE_WARNING:
-        error_printf_hmp(hmp, "warning: ");
+        error_printf_hmp(hmp, false, "warning: ");
         break;
     case REPORT_TYPE_INFO:
-        error_printf_hmp(hmp, "info: ");
+        error_printf_hmp(hmp, false, "info: ");
         break;
     }
 
-    error_vprintf_hmp(hmp, fmt, ap);
-    error_printf_hmp(hmp, "\n");
+    error_vprintf_hmp(hmp, true, fmt, ap);
+    error_printf_hmp(hmp, false, "\n");
 
     if (!hmp) {
         qemu_funlockfile(stderr);
-- 
2.56.0



  parent reply	other threads:[~2026-10-15 11:22 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 11:20 [PATCH 00/21] system: introduce a live data recorder facility Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 01/21] osdep: add 'ignore_value(x)' macro Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 02/21] system: move SIGBUS signal handling to signal.c Daniel P. Berrangé
2026-10-15 12:15   ` marcandre.lureau
2026-10-15 11:20 ` [PATCH 03/21] system: rename qemu_init_sigbus to qemu_init_crash_signals Daniel P. Berrangé
2026-10-15 12:15   ` marcandre.lureau
2026-10-15 11:20 ` [PATCH 04/21] system: run SIGBUS handler on alternate signal stack Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 05/21] util: expand alternate signal stack to all threads Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 06/21] osdep: provide dummy siginfo_t definition Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 07/21] util: introduce 'tldr', a system data recorder for crash handling Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 08/21] qapi: add 'tldr-dump' command for on-demand data recorder output Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 09/21] system: trigger TLDR crash dump on unhandled SIGBUS Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 10/21] system: simplify signal handler logic Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 11/21] main: allow SIGBUS in the main loop Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 12/21] system: enable SIGBUS handling on non-Linux platforms Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 13/21] system: enable crash dumps on SIGSEGV, SIGILL, SIGFPE and SIGABRT Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 14/21] util: introduce capture of textual messages in data recorder Daniel P. Berrangé
2026-10-15 11:20 ` Daniel P. Berrangé [this message]
2026-10-15 11:20 ` [PATCH 16/21] monitor: remove obsolete/redundant exports Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 17/21] monitor: capture monitor commands and events in data recorder Daniel P. Berrangé
2026-10-15 15:57   ` Dr. David Alan Gilbert
2026-10-15 16:11     ` Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 18/21] log: enable directing log messages to " Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 19/21] tests/qtest: add API to declare an expected crash signal Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 20/21] qtest: add 'crash' command to generate 'authentic' process crashes Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 21/21] tests/qtest: add test to validate data recorder on crashes Daniel P. Berrangé
2026-10-15 12:15 ` [PATCH 00/21] system: introduce a live data recorder facility marcandre.lureau
2026-10-15 12:32   ` Daniel P. Berrangé
2026-10-15 17:34 ` Pierrick Bouvier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261015112044.1999748-16-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dave@treblig.org \
    --cc=eblake@redhat.com \
    --cc=farosas@suse.de \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.