From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [PATCH v3 35/49] error-report: switch to use monitor_cur_hmp()
Date: Mon, 24 Aug 2026 15:17:06 +0100 [thread overview]
Message-ID: <aoxSYsbavuGtwCUO@redhat.com> (raw)
In-Reply-To: <20260816-qemu-no-hmp-v3-35-e53fc35bc550@redhat.com>
On Sun, Aug 16, 2026 at 11:13:02PM +0400, Marc-André Lureau wrote:
> Instead of passing a Monitor pointer through error_vprintf_mon() and
> error_printf_mon(), call monitor_cur_hmp() directly. This removes the
> monitor parameter from the internal helpers and the manual
> object_dynamic_cast() in vreport().
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> util/error-report.c | 72 +++++++++++++++++++++++++----------------------------
> 1 file changed, 34 insertions(+), 38 deletions(-)
>
> diff --git a/util/error-report.c b/util/error-report.c
> index aaa15bc79827..70cbd174ffae 100644
> --- a/util/error-report.c
> +++ b/util/error-report.c
> @@ -30,34 +30,31 @@ bool error_with_guestname;
> const char *error_guest_name;
>
> /*
> - * Print to the current human monitor if we have one, else to stderr.
> + * Print to the current HMP monitor if we have one, else to stderr.
> */
> -static int G_GNUC_PRINTF(2, 0)
> -error_vprintf_mon(Monitor *cur_mon, const char *fmt, va_list ap)
> +static int G_GNUC_PRINTF(1, 0)
> +error_vprintf_mon(const char *fmt, va_list ap)
Please don't remove this 'cur_mon' parameter.
> {
> - /*
> - * This will return -1 if 'cur_mon' is NULL, or is QMP.
> - * IOW this will only print if in HMP, otherwise we
> - * fallback to stderr for QMP / no-monitor scenarios.
> - */
> - int ret = monitor_vprintf(cur_mon, fmt, ap);
> - if (ret == -1) {
> - ret = vfprintf(stderr, fmt, ap);
> + MonitorHMP *hmp = monitor_cur_hmp();
This calls qemu_mutex_lock/unlock, which have trace points.
As a result if you have 'log' tracing enabled, error messages
will get trace point output splattered on top.
We must fetch monitor_cur_hmp once only at the top of
vreport() and never query it again.
> +
> + if (hmp) {
> + return monitor_vprintf(MONITOR(hmp), fmt, ap);
> }
> - return ret;
> +
> + return vfprintf(stderr, fmt, ap);
> }
>
> /*
> - * Print to the current human monitor if we have one, else to stderr.
> + * Print to the current HMP monitor if we have one, else to stderr.
> */
> -static int G_GNUC_PRINTF(2, 3)
> -error_printf_mon(Monitor *cur_mon, const char *fmt, ...)
> +static int G_GNUC_PRINTF(1, 2)
> +error_printf_mon(const char *fmt, ...)
> {
> va_list ap;
> int ret;
>
> va_start(ap, fmt);
> - ret = error_vprintf_mon(cur_mon, fmt, ap);
> + ret = error_vprintf_mon(fmt, ap);
> va_end(ap);
> return ret;
> }
> @@ -67,7 +64,7 @@ error_printf_mon(Monitor *cur_mon, const char *fmt, ...)
> */
> int error_vprintf(const char *fmt, va_list ap)
> {
> - return error_vprintf_mon(monitor_cur(), fmt, ap);
> + return error_vprintf_mon(fmt, ap);
> }
>
> /*
> @@ -79,7 +76,7 @@ int error_printf(const char *fmt, ...)
> int ret;
>
> va_start(ap, fmt);
> - ret = error_vprintf_mon(monitor_cur(), fmt, ap);
> + ret = error_vprintf_mon(fmt, ap);
> va_end(ap);
> return ret;
> }
> @@ -183,13 +180,13 @@ void loc_set_file(const char *fname, int lno)
> * Print current location to current HMP monitor if we have one, else
> * to stderr.
> */
> -static void print_loc(Monitor *cur)
> +static void print_loc(MonitorHMP *hmp)
> {
> const char *sep = "";
> int i;
> const char *const *argp;
>
> - if (!cur && g_get_prgname()) {
> + if (!hmp && g_get_prgname()) {
> fprintf(stderr, "%s:", g_get_prgname());
> sep = " ";
> }
> @@ -197,20 +194,20 @@ static void print_loc(Monitor *cur)
> case LOC_CMDLINE:
> argp = cur_loc->ptr;
> for (i = 0; i < cur_loc->num; i++) {
> - error_printf_mon(cur, "%s%s", sep, argp[i]);
> + error_printf_mon("%s%s", sep, argp[i]);
> sep = " ";
> }
> - error_printf_mon(cur, ": ");
> + error_printf_mon(": ");
> break;
> case LOC_FILE:
> - error_printf_mon(cur, "%s:", (const char *)cur_loc->ptr);
> + error_printf_mon("%s:", (const char *)cur_loc->ptr);
> if (cur_loc->num) {
> - error_printf_mon(cur, "%d:", cur_loc->num);
> + error_printf_mon("%d:", cur_loc->num);
> }
> - error_printf_mon(cur, " ");
> + error_printf_mon(" ");
> break;
> default:
> - error_printf_mon(cur, "%s", sep);
> + error_printf_mon("%s", sep);
> }
> }
>
> @@ -233,45 +230,44 @@ static void vreport(report_type type, const char *fmt, va_list ap)
> {
> /*
> * When current monitor is QMP, messages must go to stderr
> - * and have prefixes added, so we cast to HMP, leaving 'cur'
> + * and have prefixes added, so we cast to HMP, leaving 'hmp'
> * as NULL in QMP case
> */
The comment talks about a cast hwich no longer exists here.
/*
* When current monitor is QMP, messages must go to stderr
* and have prefixes added, so only need MonitorHMP here
* not the parent Monitor.
*/
> - Monitor *cur = MONITOR(
> - object_dynamic_cast(OBJECT(monitor_cur()), TYPE_MONITOR_HMP));
> + MonitorHMP *hmp = monitor_cur_hmp();
> gchar *timestr;
>
> - if (!cur) {
> + if (!hmp) {
> qemu_flockfile(stderr);
> }
>
> - if (message_with_timestamp && !cur) {
> + if (message_with_timestamp && !hmp) {
> timestr = real_time_iso8601();
> fprintf(stderr, "%s ", timestr);
> g_free(timestr);
> }
>
> /* Only prepend guest name if -msg guest-name and -name guest=... are set */
> - if (error_with_guestname && error_guest_name && !cur) {
> + if (error_with_guestname && error_guest_name && !hmp) {
> fprintf(stderr, "%s ", error_guest_name);
> }
>
> - print_loc(cur);
> + print_loc(hmp);
>
> switch (type) {
> case REPORT_TYPE_ERROR:
> break;
> case REPORT_TYPE_WARNING:
> - error_printf_mon(cur, "warning: ");
> + error_printf_mon("warning: ");
> break;
> case REPORT_TYPE_INFO:
> - error_printf_mon(cur, "info: ");
> + error_printf_mon("info: ");
> break;
> }
>
> - error_vprintf_mon(cur, fmt, ap);
> - error_printf_mon(cur, "\n");
> + error_vprintf_mon(fmt, ap);
> + error_printf_mon("\n");
>
> - if (!cur) {
> + if (!hmp) {
> qemu_funlockfile(stderr);
> }
> }
>
> --
> 2.55.0.543.g5ebe2ebe4ea8
>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-08-24 14:17 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-16 19:12 [PATCH v3 00/49] Make HMP optional (and later standalone) Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 01/49] vl: fix -monitor none prefix matching Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 02/49] hmp: remove 'vcpu' argument from trace-event help Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 03/49] hmp: fix snapshot_blkdev argument type Marc-André Lureau
2026-08-17 3:51 ` Philippe Mathieu-Daudé
2026-08-16 19:12 ` [PATCH v3 04/49] target/i386: decouple cpu_x86_inject_mce() from Monitor Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 05/49] target/i386: return an error for invalid CPU in hmp_mce() Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 06/49] system: move gpa2hva() to system memory unit Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 07/49] system: decouple qmp_inject_nmi() from Monitor Marc-André Lureau
2026-08-17 3:53 ` Philippe Mathieu-Daudé
2026-08-17 8:04 ` Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 08/49] monitor: move HMP-only fields from Monitor to MonitorHMP Marc-André Lureau
2026-08-24 13:24 ` Daniel P. Berrangé
2026-08-24 21:30 ` Philippe Mathieu-Daudé
2026-08-16 19:12 ` [PATCH v3 09/49] tests/functional: use query-version QMP command instead of HMP Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 10/49] net/qapi: add x-query-usernet command Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 11/49] python, tests: switch usernet queries from HMP to QMP Marc-André Lureau
2026-08-17 7:30 ` Thomas Huth
2026-08-17 8:07 ` Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 12/49] tests/qtest/pnv: drop unnecessary -serial mon:stdio Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 13/49] tests/qtest/qmp-test: don't depend on human-monitor-command Marc-André Lureau
2026-08-17 3:55 ` Philippe Mathieu-Daudé
2026-08-17 8:11 ` Marc-André Lureau
2026-08-17 9:11 ` Philippe Mathieu-Daudé
2026-08-16 19:12 ` [PATCH v3 14/49] tests/qtest/numa-test: replace HMP "info numa" with QMP query-cpus-fast Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 15/49] tests/qtest/cdrom-test: replace HMP "info block" with QMP query-block Marc-André Lureau
2026-08-16 19:53 ` Denis V. Lunev
2026-08-16 19:12 ` [PATCH v3 16/49] tests/qtest/device-introspect-test: fix test without HMP Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 17/49] tests/qemu-iotests/205: fix race in assertExportNotFound Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 18/49] net: add x-query-network QMP command Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 19/49] tests/qtest/netdev-socket: replace HMP with x-query-network QMP Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 20/49] qemu-io: propagate errors through Error API instead of printf Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 21/49] block: add x-qemu-io QMP command Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 22/49] qtest: add qemu-io command to the qtest protocol Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 23/49] qtest/ide-test: convert to use qtest qemu-io command Marc-André Lureau
2026-08-16 19:54 ` Denis V. Lunev
2026-08-16 19:12 ` [PATCH v3 24/49] tests/qemu-iotests: add qmp_qemu_io() Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 25/49] tests/qemu-iotests: convert pause/resume_drive() to QMP Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 26/49] build-sys: add 'hmp' option Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 27/49] monitor: reject readline monitor when HMP is disabled Marc-André Lureau
2026-08-16 20:23 ` Dr. David Alan Gilbert
2026-08-24 13:26 ` Daniel P. Berrangé
2026-08-16 19:12 ` [PATCH v3 28/49] system: guard HMP initialization paths with CONFIG_HMP Marc-André Lureau
2026-08-24 13:27 ` Daniel P. Berrangé
2026-08-16 19:12 ` [PATCH v3 29/49] tests: skip HMP-dependent tests when HMP is disabled Marc-André Lureau
2026-08-16 19:12 ` [PATCH v3 30/49] monitor: isolate HMP declarations in hmp.h Marc-André Lureau
2026-08-16 20:21 ` Dr. David Alan Gilbert
2026-08-16 19:12 ` [PATCH v3 31/49] monitor: change HMPCommand cmd to take MonitorHMP Marc-André Lureau
2026-08-16 21:51 ` Dr. David Alan Gilbert
2026-08-17 18:08 ` Jason J. Herne
2026-08-24 13:30 ` Daniel P. Berrangé
2026-08-16 19:12 ` [PATCH v3 32/49] monitor: make hmp_handle_error() " Marc-André Lureau
2026-08-17 0:36 ` Dr. David Alan Gilbert
2026-08-24 13:33 ` Daniel P. Berrangé
2026-08-16 19:13 ` [PATCH v3 33/49] monitor: add monitor_cur_hmp() helper Marc-André Lureau
2026-08-17 0:49 ` Dr. David Alan Gilbert
2026-08-16 19:13 ` [PATCH v3 34/49] qemu-print: switch to use monitor_cur_hmp() Marc-André Lureau
2026-08-24 14:11 ` Daniel P. Berrangé
2026-08-16 19:13 ` [PATCH v3 35/49] error-report: " Marc-André Lureau
2026-08-24 14:17 ` Daniel P. Berrangé [this message]
2026-08-24 14:19 ` Daniel P. Berrangé
2026-08-16 19:13 ` [PATCH v3 36/49] monitor: tighten monitor_set_cpu()/get_cpu() Marc-André Lureau
2026-08-18 14:15 ` Dr. David Alan Gilbert
2026-08-16 19:13 ` [PATCH v3 37/49] monitor: tighten monitor_printf*() Marc-André Lureau
2026-08-17 18:09 ` Jason J. Herne
2026-08-19 14:29 ` Dr. David Alan Gilbert
2026-08-19 14:46 ` Marc-André Lureau
2026-08-22 13:32 ` Dr. David Alan Gilbert
2026-08-16 19:13 ` [PATCH v3 38/49] hexagon: make dump_mmu() take MonitorHMP Marc-André Lureau
2026-08-17 3:49 ` Philippe Mathieu-Daudé
2026-08-18 20:35 ` Brian Cain
2026-08-16 19:13 ` [PATCH v3 39/49] qdev-monitor: make print_dev() callback " Marc-André Lureau
2026-08-17 3:48 ` Philippe Mathieu-Daudé
2026-08-16 19:13 ` [PATCH v3 40/49] qapi: make HMP-specific schema entries conditional on CONFIG_HMP Marc-André Lureau
2026-08-19 14:14 ` Dr. David Alan Gilbert
2026-08-16 19:13 ` [PATCH v3 41/49] Guard HMP command implementations with CONFIG_HMP Marc-André Lureau
2026-08-17 18:11 ` Jason J. Herne
2026-08-16 19:13 ` [PATCH v3 42/49] target: guard MonitorDef tables " Marc-André Lureau
2026-08-17 3:47 ` Philippe Mathieu-Daudé
2026-08-20 14:38 ` Philippe Mathieu-Daudé
2026-08-20 19:24 ` Marc-André Lureau
2026-08-16 19:13 ` [PATCH v3 43/49] hw: guard BusClass::print_dev " Marc-André Lureau
2026-08-16 19:13 ` [PATCH v3 44/49] hexagon: condition HMP-specific code Marc-André Lureau
2026-08-17 3:46 ` Philippe Mathieu-Daudé
2026-08-18 20:34 ` Brian Cain
2026-08-16 19:13 ` [PATCH v3 45/49] build-sys: make HMP source files conditional on have_hmp Marc-André Lureau
2026-08-19 14:30 ` Dr. David Alan Gilbert
2026-08-16 19:13 ` [PATCH v3 46/49] stubs: split monitor-core stubs into separate compilation units Marc-André Lureau
2026-08-16 19:13 ` [PATCH v3 47/49] monitor: move monitor_hmp_print*() functions to hmp.c Marc-André Lureau
2026-08-19 14:16 ` Dr. David Alan Gilbert
2026-08-19 14:40 ` Marc-André Lureau
2026-08-16 19:13 ` [PATCH v3 48/49] monitor: move HMP-specific to monitor-hmp-internal.h Marc-André Lureau
2026-08-20 14:27 ` Dr. David Alan Gilbert
2026-08-16 19:13 ` [PATCH v3 49/49] gitlab: --disable-hmp in build-without-defaults Marc-André Lureau
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=aoxSYsbavuGtwCUO@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=philmd@mailo.com \
--cc=qemu-devel@nongnu.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.