From: Paolo Bonzini <pbonzini@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>, "Greg Kurz" <groug@kaod.org>
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH v2 2/2] util/log: Always send errors to logfile when daemonized
Date: Thu, 20 Oct 2022 12:52:21 +0200 [thread overview]
Message-ID: <1b76bdd4-f5ca-cb0a-2593-b025d6575e9b@redhat.com> (raw)
In-Reply-To: <Y1Ebv28whPgwdaMW@redhat.com>
On 10/20/22 11:58, Daniel P. Berrangé wrote:
>
> 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.
(Aside: it's not just TCG logging. The default tracing backend is also
printing to -D).
> 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.
True, but it already does that if "-d" is specified, because "-d"
*intentionally* reopens stderr when -daemonize is specified. So I think
overall the idea of "make -D always open the destination when
daemonizing" is sound, the only weird thing is the interaction with "-d
tid" which is fixed if we just replace the fallback case from
log_thread_id() as in Wine's get_unix_tid() code. "-d tid" can just be
forbidden if the platform is not supported by get_unix_tid().
> 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.
I would gladly get rid of -daemonize, unfortunately it has many users.
Adding further complication to it is not beautiful, but overall I think
Greg's patch does make sense. In particular I would continue the
refactoring by moving
/*
* If per-thread, filename contains a single %d that should be
* converted.
*/
if (per_thread) {
fname = g_strdup_printf(filename, getpid());
} else {
fname = g_strdup(filename);
}
return fopen(fname, log_append ? "a" : "w");
to a new function that can be used in both qemu_log_trylock() and
qemu_set_log_internal(). (In fact this refactoring is a bugfix because
per-thread log files do not currently obey log_append).
Paolo
next prev parent reply other threads:[~2022-10-20 11:24 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é
2022-10-20 10:52 ` Paolo Bonzini [this message]
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=1b76bdd4-f5ca-cb0a-2593-b025d6575e9b@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=groug@kaod.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 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).