On Wed, Aug 20, 2025 at 08:02:14AM +1000, Richard Henderson wrote:
> On 8/20/25 06:27, Daniel P. Berrangé wrote:
> >   void qemu_log(const char *fmt, ...)
> >   {
> >       FILE *f;
> > -    g_autofree const char *timestr = NULL;
> > -
> >       /*
> > -     * Prepare the timestamp*outside* the logging
> > -     * lock so it better reflects when the message
> > -     * was emitted if we are delayed acquiring the
> > -     * mutex
> > +     * Prepare the context*outside* the logging
> > +     * lock so any timestamp better reflects when
> > +     * the message was emitted if we are delayed
> > +     * acquiring the mutex
> >        */
> > -    if (message_with_timestamp) {
> > -        g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
> > -        timestr = g_date_time_format_iso8601(dt);
> > -    }
> 
> Something that really ought to be handled better is that we currently use
> qemu_log to print pieces of a larger message.  E.g. looping over the general
> registers to print the whole cpu state.
> 
> (1) We don't want timestamps in the middle, and
> (2) we don't want unnecessary memory allocation in the middle.

Interestingly I found that for CPU_LOG_TB_CPU we don't use the qemu_log()
function at all. TCG calls qemu_log_try_lock() to acquire the raw FILE *
handle and writes directly to it, so we miss all prefix info entirely.
If other parts of QEMU that do big multi-line log dumps do the same,
then we're ok.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to