From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Greg Kurz" <groug@kaod.org>
Subject: [PATCH 1/2] util/log: Make the per-thread flag immutable
Date: Fri, 4 Nov 2022 13:00:58 +0100 [thread overview]
Message-ID: <20221104120059.678470-2-groug@kaod.org> (raw)
In-Reply-To: <20221104120059.678470-1-groug@kaod.org>
Per-thread logging was implemented under the assumption that once
enabled, it is not possible to switch back to single file logging.
This isn't enforced though and it is possible to go through the
global file opening sequence in per-thread mode. The code isn't
ready for this and produces unexpected results as detailed below.
Start QEMU in system emulation mode with `-D ./qemu.log.%d -d tid`
and then change the log level from the monitor to something that
doesn't have tid, e.g. `log cpu_reset`. The value of log_flags
is zero and per_thread is set to false : the rest of the code
then assumes it is running in the global log case and opens a
file named `qemu.log.%d`, which is obviously not an expected
behavior.
Enforce the immutability of the flag early in qemu_set_log_internal()
so that its value is correct for all subsequent users.
Fixes: 4e51069d6793 ("util/log: Support per-thread log files")
Cc: richard.henderson@linaro.org
Signed-off-by: Greg Kurz <groug@kaod.org>
---
util/log.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/util/log.c b/util/log.c
index 39866bdaf2fa..b7d2b6e09cfe 100644
--- a/util/log.c
+++ b/util/log.c
@@ -206,6 +206,11 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name,
QEMU_LOCK_GUARD(&global_mutex);
logfile = global_file;
+ /* The per-thread flag is immutable. */
+ if (log_per_thread) {
+ log_flags |= LOG_PER_THREAD;
+ }
+
per_thread = log_flags & LOG_PER_THREAD;
if (changed_name) {
--
2.38.1
next prev parent reply other threads:[~2022-11-04 12:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 12:00 [PATCH 0/2] util/log: Make the per-thread flag immutable Greg Kurz
2022-11-04 12:00 ` Greg Kurz [this message]
2022-11-04 12:00 ` [PATCH 2/2] util/log: Ignore per-thread flag if global file already there Greg Kurz
2022-11-04 22:37 ` [PATCH 0/2] util/log: Make the per-thread flag immutable Richard Henderson
2022-11-07 12:34 ` Greg Kurz
2022-11-07 21:01 ` Stefan Hajnoczi
2022-11-07 23:44 ` Stefan Hajnoczi
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=20221104120059.678470-2-groug@kaod.org \
--to=groug@kaod.org \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.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).