]> git.proxmox.com Git - mirror_qemu.git/commit - util/log.c
util/log: Make the per-thread flag immutable
authorGreg Kurz <groug@kaod.org>
Fri, 4 Nov 2022 12:00:58 +0000 (13:00 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 7 Nov 2022 21:00:02 +0000 (16:00 -0500)
commit479b350ebf08248eb7729a02a07ddfe7a7c65e44
tree034b87efc91cb0f2157375dd58c1ff7d5c61f564
parent622a84ef76e4fb91327651cc3294a589c341acb5
util/log: Make the per-thread flag immutable

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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20221104120059.678470-2-groug@kaod.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
util/log.c