summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorGreg Kurz2022-11-04 13:00:59 +0100
committerStefan Hajnoczi2022-11-07 22:00:02 +0100
commit524fc737431d240f9d9f10aaf381003092868bac (patch)
tree080d204640463f8116bf50233a308cc5f337b66e /util
parentutil/log: Make the per-thread flag immutable (diff)
downloadqemu-524fc737431d240f9d9f10aaf381003092868bac.tar.gz
qemu-524fc737431d240f9d9f10aaf381003092868bac.tar.xz
qemu-524fc737431d240f9d9f10aaf381003092868bac.zip
util/log: Ignore per-thread flag if global file already there
If QEMU is started with `-D qemu.log.%d` without any `-d` option, doing `log all` in the monitor fails with: Filename template with '%d' required for 'tid' It is confusing since '%d' was actually passed. This happens because QEMU caches the log file name with %d converted to getpid() since `tid` wasn't required. This name isn't suitable for a subsequent enablement of per-thread logs. There's little cause to change the behavior as `-d tid` is mostly used at user-only startup. Drop the per-thread from the requested flags in this case : `log all` will thus enable everything except `tid` instead of failing. This is preferable over forcing the user to enable each log item individually. With this patch, `tid` is now truely immutable : it can only be set or unset from the command line and never changed afterwards. 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-3-groug@kaod.org Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/log.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/log.c b/util/log.c
index b7d2b6e09c..c2198badf2 100644
--- a/util/log.c
+++ b/util/log.c
@@ -209,6 +209,10 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name,
/* The per-thread flag is immutable. */
if (log_per_thread) {
log_flags |= LOG_PER_THREAD;
+ } else {
+ if (global_filename) {
+ log_flags &= ~LOG_PER_THREAD;
+ }
}
per_thread = log_flags & LOG_PER_THREAD;