When QEMU is started with `--daemonize -D ${logfile} -d ${some_log_item}`, error logs from error_report() and friends go to ${logfile}, but if QEMU is started with `-daemonize -D ${logfile}` and no `-d`, the file isn't even created and all logs go to /dev/null.
This inconsistency is quite confusing for users and gives the impression that QEMU doesn't log errors at all. It seems much saner to always create the log file when `-D` was passed and to be able to report errors. It was spotted by the kata-containers project, which happens to do just that `--daemonize -D` without `-d` trick. It is possible that they will stop doing so and catch errors through QEMU's stderr at some point, but I'm posting the patches anyway. v2: - new log_thread_id() implementation for hosts without gettid() syscall - avoid conflict between global log file and per-thread logfile - style improvements Greg Kurz (2): util/log: Derive thread id from getpid() on hosts w/o gettid() syscall util/log: Always send errors to logfile when daemonized util/log.c | 56 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 14 deletions(-) -- 2.37.3