On Mon, Aug 24, 2026 at 03:17:06PM +0100, Daniel P. Berrangé wrote:
> 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 <[email protected]>
> > ---
> >  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.

See my previous fix for this problem in:

  commit 2eb00abcfebc3fa0a7c2915d1d29fa8fe0b88379
  Author: Daniel P. Berrangé <[email protected]>
  Date:   Wed Sep 10 17:32:37 2025 +0100

    util: fix interleaving of error & trace output


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 :|


Reply via email to