From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Greg Kurz <groug@kaod.org>
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v2 2/2] util/log: Always send errors to logfile when daemonized
Date: Thu, 20 Oct 2022 10:58:23 +0100 [thread overview]
Message-ID: <Y1Ebv28whPgwdaMW@redhat.com> (raw)
In-Reply-To: <20221020114937.3558737e@bahia>
On Thu, Oct 20, 2022 at 11:49:37AM +0200, Greg Kurz wrote:
> On Thu, 20 Oct 2022 12:21:27 +1000
> Richard Henderson <richard.henderson@linaro.org> wrote:
>
> > On 10/20/22 01:16, Greg Kurz wrote:
> >
> > I don't understand why daemonize changes -d tid at all.
> > If there's a bug there, please separate it out.
> >
> > I don't understand the is_main_log_thread checks.
> > Why is the main thread special?
> >
>
> The current code base either opens a per-thread file in
> qemu_log_trylock() when -d tid is enabled, or only a
> single global file in qemu_log_set_internal() in the
> opposite case.
>
> The goal of this patch is to go through the `In case we
> are a daemon redirect stderr to logfile` logic, so that
> other users of stderr, aka. error_report(), can benefit
> from it as well. Since this is only done for the global
> file, the logic was changed to : _main_ thread to always
> use the global file and other threads to use the per-thread
> file.
>
> I now realize how terrible a choice this is. It violates
> the current logic too much and brings new problems like
> "how to identify the main thread"...
snip
> > I would have thought that this was the only change required -- ignoring qemu_loglevel when
> > daemonized.
> >
>
> I was thinking the same at first, but this ended up in the
> global file being open with a filename containing a '%d'...
> I chose the direction of doing the g_strdup_printf() trick
> for the global file as well but then I had to make sure
> that qemu_log_trylock() wouldn't try later to open the same
> file, hence the _main_ thread check...
>
> The question is actually : where stderr should point to in
> the '-daemonize -D foo%d.log -d tid` case ?
I'm tending towards thinking the question is wrong, because
it is imposing semantics on -D that it was never designed to
address.
The '-d' option enables logging in QEMU, primary for things
related to TCG. By default that logging goes to stderr, but
it can be sent to 1 or mnay files, using -D. IOW, -D is NOT
about controlling where stderr/out is connected. It is
about where TCG logging goes.
Separately, IIUC, you found that when using -daemonize any
error_report() messages end up in the void, because stderr
is connected to /dev/null.
This patch is thus attempting to repurpose -D as a way to
say where error_report() messages end up with daemonized,
and this creates the complexity because -D was never
intended to be a mechanism to control stderr or error_report
output.
If we want to connect stdout/err to something when daemonized
then lets either have a dedicated option for that, or simply
tell apps not to use -daemonize and to take care of daemonzing
themselves, thus having full control over stdout/err. The latter
is what libvirt uses, because we actually want stderr/out on a
pipe, not a file, in order to enforce rollover.
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 :|
next prev parent reply other threads:[~2022-10-20 10:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 15:16 [PATCH v2 0/2] util/log: Always send errors to logfile when daemonized Greg Kurz
2022-10-19 15:16 ` [PATCH v2 1/2] util/log: Derive thread id from getpid() on hosts w/o gettid() syscall Greg Kurz
2022-10-19 15:57 ` Daniel P. Berrangé
2022-10-20 8:40 ` Greg Kurz
2022-10-20 10:39 ` Paolo Bonzini
2022-10-21 14:08 ` Greg Kurz
2022-10-19 15:16 ` [PATCH v2 2/2] util/log: Always send errors to logfile when daemonized Greg Kurz
2022-10-20 2:21 ` Richard Henderson
2022-10-20 9:49 ` Greg Kurz
2022-10-20 9:58 ` Daniel P. Berrangé [this message]
2022-10-20 10:52 ` Paolo Bonzini
2022-10-24 9:44 ` Alex Bennée
2022-10-25 8:52 ` Greg Kurz
2022-10-25 9:20 ` Paolo Bonzini
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=Y1Ebv28whPgwdaMW@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=groug@kaod.org \
--cc=pbonzini@redhat.com \
--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 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).