From: Dimitris Aragiorgis <dimara@arrikto.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: jtomko@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH] log: do not log if QEMU is daemonized but without -D
Date: Tue, 1 Mar 2016 16:03:05 +0200 [thread overview]
Message-ID: <20160301140305.GA10785@arr> (raw)
In-Reply-To: <1456833053-8896-1-git-send-email-pbonzini@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3346 bytes --]
Hi all,
* Paolo Bonzini <pbonzini@redhat.com> [2016-03-01 12:50:53 +0100]:
> Commit 96c33a4 ("log: Redirect stderr to logfile if deamonized",
> 2016-02-22) wanted to move stderr of a daemonized QEMU to the file
> specified with -D.
>
> However, if -D was not passed, the patch had the side effect of not
> redirecting stderr to /dev/null. This happened because qemu_logfile
> was set to stderr rather than the expected value of NULL. The fix
> is simply in the "if" condition of do_qemu_set_log; the "if" for
> closing the file is also changed to match.
>
Sorry, that was my bad.
I tested the proposed fix as well and it works. I would suggest to
add some sort of comments since the whole do_qemu_set_log() is hard
to parse in one pass. For example:
diff --git a/util/log.c b/util/log.c
index 8b921de..1d73be0 100644
--- a/util/log.c
+++ b/util/log.c
@@ -56,6 +56,10 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers)
#ifdef CONFIG_TRACE_LOG
qemu_loglevel |= LOG_TRACE;
#endif
+ /* Setup the logfile when:
+ * - The loglevel is set via -d option or CONFIG_TRACE_LOG, or
+ * - Both -daemonize and -D options are given
+ */
if (!qemu_logfile &&
(is_daemonized() ? logfilename != NULL : qemu_loglevel)) {
if (logfilename) {
@@ -91,6 +95,10 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers)
log_append = 1;
}
}
+ /* Close the already setup logfile when loglevel gets reset (e.g.
+ * via the log HMP command), unless both -daemonize and -D options
+ * are given.
+ */
if (qemu_logfile &&
(is_daemonized() ? logfilename == NULL : !qemu_loglevel)) {
qemu_log_close();
Thanks for this quick fix and sorry again for any trouble caused in the first
place.
dimara
> Reported-by: Jan Tomko <jtomko@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> util/log.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/util/log.c b/util/log.c
> index a7ddc7e..8b921de 100644
> --- a/util/log.c
> +++ b/util/log.c
> @@ -56,7 +56,8 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers)
> #ifdef CONFIG_TRACE_LOG
> qemu_loglevel |= LOG_TRACE;
> #endif
> - if ((qemu_loglevel || is_daemonized()) && !qemu_logfile) {
> + if (!qemu_logfile &&
> + (is_daemonized() ? logfilename != NULL : qemu_loglevel)) {
> if (logfilename) {
> qemu_logfile = fopen(logfilename, log_append ? "a" : "w");
> if (!qemu_logfile) {
> @@ -72,6 +73,7 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers)
> }
> } else {
> /* Default to stderr if no log file specified */
> + assert(!is_daemonized());
> qemu_logfile = stderr;
> }
> /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
> @@ -89,7 +91,8 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers)
> log_append = 1;
> }
> }
> - if (!qemu_loglevel && !is_daemonized() && qemu_logfile) {
> + if (qemu_logfile &&
> + (is_daemonized() ? logfilename == NULL : !qemu_loglevel)) {
> qemu_log_close();
> }
> }
> --
> 2.5.0
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
prev parent reply other threads:[~2016-03-01 14:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 11:50 [Qemu-devel] [PATCH] log: do not log if QEMU is daemonized but without -D Paolo Bonzini
2016-03-01 11:58 ` Cornelia Huck
2016-03-01 13:51 ` Gerd Hoffmann
2016-03-01 14:03 ` Dimitris Aragiorgis [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=20160301140305.GA10785@arr \
--to=dimara@arrikto.com \
--cc=jtomko@redhat.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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.