From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: Re: [PATCH 6/6] util: add '-msg format=FORMATSTR' argument
Date: Fri, 4 Dec 2026 09:23:36 +0000 [thread overview]
Message-ID: <axKGmEXyiKxbK3s2@redhat.com> (raw)
In-Reply-To: <axHlaaClj8rKE6v9@redhat.com>
On Thu, Dec 03, 2026 at 04:02:50PM -0600, Eric Blake wrote:
> On Thu, Dec 03, 2026 at 05:25:43PM +0000, Daniel P. Berrangé wrote:
> > Allow the prefix for error messages and log messages to be runtime
> > configurable by introducing the '-msg format=FORMATSTR' argument.
> > This accepts a QMessageFormat templated string, and if set, the
> > existing 'timestamp' and 'guest-name' options to -msg must not
> > be used.
> >
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> > qemu-options.hx | 72 ++++++++++++++++++++++++++++++++++++++++++++++---
> > system/vl.c | 35 ++++++++++++++++++++++--
> > 2 files changed, 102 insertions(+), 5 deletions(-)
> >
>
> > +++ b/qemu-options.hx
>
> > +``-msg [timestamp=on|off][,guest-name=on|off][,format=FORMATSTR]``
> > Control error message format.
> >
> > + The simple historical options are:
> > +
> > ``timestamp=on|off``
> > Prefix messages with a timestamp. Default is off.
> >
> > ``guest-name=on|off``
> > Prefix messages with guest name but only if -name guest option is set
> > otherwise the option is ignored. Default is off.
> > +
> > + These are mutually exclusive with the new more flexible
> > + format string option:
>
> Mutually exclusive, yet...
>
> > +
> > + ``format=FORMATSTR``
> > + Prefix log and error messages with a string constructed from FMTSTR.
> > +
> > + A ``FORMATSTR`` string is a concatenation of any of the following:
> ...
> > + The default built-in format is:
> > +
> > + ``"{progname}{?{progname}: }{location}{?{location}: }{levelalt}{?{levelalt}: }"``
> > +
> > + If ``timestamp=on`` and ``guest-name=on`` are given, then
> > + the above default format is further prefixed with:
> > +
> > + ``"{timestamp} {guestname} "``
>
> ...this could be implied to mean that they can still be used. Maybe
> word it along the lines of "The default built-in format, when
> FORMATSTR is not specified, is:".
Hmmm, yes, that is poorly worded currently, I'll fix it.
>
> > +++ b/system/vl.c
>
> > +static bool configure_msg(QemuOpts *opts)
> > {
> > + Error *local_err = NULL;
> > + const char *formatstr = qemu_opt_get(opts, "format");
> > message_with_timestamp = qemu_opt_get_bool(opts, "timestamp", false);
> > error_with_guestname = qemu_opt_get_bool(opts, "guest-name", false);
> > +
> > + if (formatstr && (message_with_timestamp || error_with_guestname)) {
> > + error_report("-msg 'format' is mutually exclusive with "
> > + "'timestamp' and 'guest-name'");
> > + return false;
> > + }
>
> At least you are diagnosing it up front, so it doesn't cause confusing
> output later.
>
> > +
> > + if (formatstr) {
>
> Two conditionals in a row gated by formatstr; is it worth moving 'if
> (message_with_timestamp || error_with_guestname)' inside the one 'if
> (formatstr)' block?
Yes.
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 :|
prev parent reply other threads:[~2026-12-04 9:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:25 [PATCH 0/6] util: configurable / flexible error/log message output format Daniel P. Berrangé
2026-12-03 17:25 ` [PATCH 1/6] util: pull Location struct and APIs into location.{c,h} Daniel P. Berrangé
2026-12-03 20:51 ` Eric Blake
2026-12-03 17:25 ` [PATCH 2/6] util: add helper to query if a location is set Daniel P. Berrangé
2026-12-03 20:51 ` Eric Blake
2026-12-03 17:25 ` [PATCH 3/6] util: introduce a configurable message format template Daniel P. Berrangé
2026-12-03 21:44 ` Eric Blake
2026-12-04 9:22 ` Daniel P. Berrangé
2026-12-04 0:32 ` Dr. David Alan Gilbert
2026-12-03 17:25 ` [PATCH 4/6] util: convert log code to support QMessageFormat Daniel P. Berrangé
2026-12-03 21:52 ` Eric Blake
2026-12-03 17:25 ` [PATCH 5/6] util: convert error report code to use QMessageFormat Daniel P. Berrangé
2026-12-03 21:55 ` Eric Blake
2026-12-03 17:25 ` [PATCH 6/6] util: add '-msg format=FORMATSTR' argument Daniel P. Berrangé
2026-12-03 22:02 ` Eric Blake
2026-12-04 9:23 ` Daniel P. Berrangé [this message]
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=axKGmEXyiKxbK3s2@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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.