From: Christophe Fergeau <cfergeau@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4] log: Make glib logging go through QEMU
Date: Mon, 14 Jan 2019 12:54:20 +0100 [thread overview]
Message-ID: <20190114115420.GR23773@natto.ory.fergeau.eu> (raw)
In-Reply-To: <20190104154034.GK30381@stefanha-x1.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2587 bytes --]
On Fri, Jan 04, 2019 at 03:40:34PM +0000, Stefan Hajnoczi wrote:
> On Thu, Jan 03, 2019 at 03:14:55PM +0100, Christophe Fergeau wrote:
> > Hey,
> >
> > On Thu, Jan 03, 2019 at 10:54:25AM +0000, Stefan Hajnoczi wrote:
> > > On Fri, Dec 14, 2018 at 11:56:42AM +0100, Christophe Fergeau wrote:
> > > > +static void qemu_log_func(const gchar *log_domain,
> > > > + GLogLevelFlags log_level,
> > > > + const gchar *message,
> > > > + gpointer user_data)
> > > > +{
> > > > + switch (log_level & G_LOG_LEVEL_MASK) {
> > > > + case G_LOG_LEVEL_DEBUG:
> > > > + /* Use same G_MESSAGES_DEBUG logic as glib to enable/disable debug
> > > > + * messages
> > > > + */
> > > > + if (qemu_glog_domains == NULL) {
> > > > + break;
> > > > + }
> > > > + if (strcmp(qemu_glog_domains, "all") != 0 &&
> > > > + (log_domain == NULL || !strstr(qemu_glog_domains, log_domain))) {
> > > > + break;
> > > > + }
> > > > + /* Fall through */
> > > > + case G_LOG_LEVEL_INFO:
> > > > + /* Fall through */
> > > > + case G_LOG_LEVEL_MESSAGE:
> > > > + info_report("%s: %s", log_domain, message);
> > >
> > > QEMU itself uses glib, so what happens if *_report() emit more log
> > > messages? Can this result in an infinite loop?
> >
> > If *_report try to output messages through the g_log API, glib will
> > catch it and will abort, so not an infinite loop, but not a
> > desirable outcome either.
> >
> > Some low-level logging functions which are going to dump the message
> > without glib (or using g_log_default_handler()) are needed.
> > The timestamping/prepending of 'error:', 'warning:' to the error message
> > is done right below *_report (in vreport) so this looked like a good
> > place for that.
>
> If you're confident that QEMU will never (indirectly) emit a glib log
> message from the *_report() code path, then I'm happy.
In these codepaths, I'm confident up to
void monitor_vfprintf(FILE *stream, const char *fmt, va_list ap)
{
if (cur_mon && !monitor_cur_is_qmp()) {
monitor_vprintf(cur_mon, fmt, ap);
} else {
vfprintf(stream, fmt, ap);
}
}
From there, it was not obvious to me whether the monitor_vprintf
codepath can be triggered from info/warn/error_report or not. If they
can, I'd feel less confident that monitor_vprintf will never indirectly
call glib log functions.
Christophe
>
> Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-01-14 12:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-14 10:56 [Qemu-devel] [PATCH v4] log: Make glib logging go through QEMU Christophe Fergeau
2019-01-03 10:54 ` Stefan Hajnoczi
2019-01-03 14:14 ` Christophe Fergeau
2019-01-04 15:40 ` Stefan Hajnoczi
2019-01-14 11:54 ` Christophe Fergeau [this message]
2019-01-15 14:09 ` Stefan Hajnoczi
2019-01-15 15:03 ` Christophe Fergeau
2019-01-16 13:56 ` Stefan Hajnoczi
2019-01-21 11:37 ` no-reply
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=20190114115420.GR23773@natto.ory.fergeau.eu \
--to=cfergeau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).