#
f05142d5 |
| 04-Oct-2023 |
Fiona Ebner <f.ebner@proxmox.com> |
util/log: re-allow switching away from stderr log file
Commit 59bde21374 ("util/log: do not close and reopen log files when flags are turned off") prevented switching away from stderr on a subsequen
util/log: re-allow switching away from stderr log file
Commit 59bde21374 ("util/log: do not close and reopen log files when flags are turned off") prevented switching away from stderr on a subsequent invocation of qemu_set_log_internal(). This prevented switching away from stderr with the 'logfile' monitor command as well as an invocation like > ./qemu-system-x86_64 -trace 'qemu_mutex_lock,file=log' from opening the specified log file.
Fixes: 59bde21374 ("util/log: do not close and reopen log files when flags are turned off") Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Message-ID: <20231004124446.491481-1-f.ebner@proxmox.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
Revision tags: v8.0.0 |
|
#
b84694de |
| 10-Apr-2023 |
Ivan Klokov <ivan.klokov@syntacore.com> |
util/log: Add vector registers to log
Added QEMU option 'vpu' to log vector extension registers such as gpr\fpu.
Signed-off-by: Ivan Klokov <ivan.klokov@syntacore.com> Reviewed-by: Alistair Francis
util/log: Add vector registers to log
Added QEMU option 'vpu' to log vector extension registers such as gpr\fpu.
Signed-off-by: Ivan Klokov <ivan.klokov@syntacore.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20230410124451.15929-2-ivan.klokov@syntacore.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
show more ...
|
#
cb9291e5 |
| 19-Jan-2023 |
BALATON Zoltan <balaton@eik.bme.hu> |
log: Remove unneeded new line
The help text of the -d plugin option has a new line at the end which is not needed as one is added automatically. Fixing it removes the unexpected empty line in -d hel
log: Remove unneeded new line
The help text of the -d plugin option has a new line at the end which is not needed as one is added automatically. Fixing it removes the unexpected empty line in -d help output.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230119214033.600FB74645F@zero.eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
show more ...
|
Revision tags: v7.2.0 |
|
#
9b063b7e |
| 08-Nov-2022 |
Greg Kurz <groug@kaod.org> |
util/log: Always send errors to logfile when daemonized
When QEMU is started with `-daemonize`, all stdio descriptors get redirected to `/dev/null`. This basically means that anything printed with e
util/log: Always send errors to logfile when daemonized
When QEMU is started with `-daemonize`, all stdio descriptors get redirected to `/dev/null`. This basically means that anything printed with error_report() and friends is lost.
Current logging code allows to redirect to a file with `-D` but this requires to enable some logging item with `-d` as well to be functional.
Relax the check on the log flags when QEMU is daemonized, so that other users of stderr can benefit from the redirection, without the need to enable unwanted debug logs. Previous behaviour is retained for the non-daemonized case. The logic is unrolled as an `if` for better readability. The qemu_log_level and log_per_thread globals reflect the state we want to transition to at this point : use them instead of the intermediary locals for correctness.
qemu_set_log_internal() is adapted to open a per-thread log file when '-d tid' is passed. This is done by hijacking qemu_try_lock() which seems simpler that refactoring the code.
Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <20221108140032.1460307-3-groug@kaod.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
59bde213 |
| 08-Nov-2022 |
Paolo Bonzini <pbonzini@redhat.com> |
util/log: do not close and reopen log files when flags are turned off
log_append makes sure that if you turn off the logging (which clears log_flags and makes need_to_open_file false) the old log is
util/log: do not close and reopen log files when flags are turned off
log_append makes sure that if you turn off the logging (which clears log_flags and makes need_to_open_file false) the old log is not overwritten. The usecase is that if you remove or move the file QEMU will not keep writing to the old file. However, this is not always the desited behavior, in particular having log_append==1 after changing the file name makes little sense.
When qemu_set_log_internal is called from the logfile monitor command, filename must be non-NULL and therefore changed_name must be true. Therefore, the only case where the file is closed and need_to_open_file == false is indeed when log_flags becomes zero. In this case, just flush the file and do not bother closing it, thus faking the same append behavior as previously.
The behavioral change is that changing the logfile twice, for example log1 -> log2 -> log1, will cause log1 to be overwritten. This can simply be documented, since it is not a particularly surprising behavior.
Suggested-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Greg Kurz <groug@kaod.org> Message-Id: <20221025092119.236224-1-pbonzini@redhat.com> [groug: nullify global_file before actually closing the file] Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <20221108140032.1460307-2-groug@kaod.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
524fc737 |
| 04-Nov-2022 |
Greg Kurz <groug@kaod.org> |
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
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>
show more ...
|
#
479b350e |
| 04-Nov-2022 |
Greg Kurz <groug@kaod.org> |
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
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>
show more ...
|
#
eff3de52 |
| 21-Oct-2022 |
Greg Kurz <groug@kaod.org> |
util/log: Close per-thread log file on thread termination
When `-D ${logfile} -d tid` is passed, qemu_log_trylock() creates a dedicated log file for the current thread and opens it. The correspondin
util/log: Close per-thread log file on thread termination
When `-D ${logfile} -d tid` is passed, qemu_log_trylock() creates a dedicated log file for the current thread and opens it. The corresponding file descriptor is cached in a __thread variable. Nothing is done to close the corresponding file descriptor when the thread terminates though and the file descriptor is leaked.
The issue was found during code inspection and reproduced manually.
Fix that with an atexit notifier.
Fixes: 4e51069d6793 ("util/log: Support per-thread log files") Cc: richard.henderson@linaro.org Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <20221021105734.555797-1-groug@kaod.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
Revision tags: v7.0.0 |
|
#
4e51069d |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Support per-thread log files
Add a new log flag, tid, to turn this feature on. Require the log filename to be set, and to contain %d.
Do not allow tid to be turned off once it is on, nor
util/log: Support per-thread log files
Add a new log flag, tid, to turn this feature on. Require the log filename to be set, and to contain %d.
Do not allow tid to be turned off once it is on, nor let the filename be change thereafter. This avoids the need for signalling each thread to re-open on a name change.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-40-richard.henderson@linaro.org>
show more ...
|
#
30f5a73a |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Limit RCUCloseFILE to file closing
Use FILE* for global_file. We can perform an rcu_read on that just as easily as RCUCloseFILE*. This simplifies a couple of places, where previously we
util/log: Limit RCUCloseFILE to file closing
Use FILE* for global_file. We can perform an rcu_read on that just as easily as RCUCloseFILE*. This simplifies a couple of places, where previously we required taking the rcu_read_lock simply to avoid racing to dereference RCUCloseFile->fd.
Only allocate the RCUCloseFile prior to call_rcu.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-39-richard.henderson@linaro.org>
show more ...
|
#
d5f55fff |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Rename QemuLogFile to RCUCloseFILE
s/QemuLogFile/RCUCloseFILE/ s/qemu_logfile_free/rcu_close_file/
Emphasize that this is only a carrier for passing a pointer to call_rcu for closing, and
util/log: Rename QemuLogFile to RCUCloseFILE
s/QemuLogFile/RCUCloseFILE/ s/qemu_logfile_free/rcu_close_file/
Emphasize that this is only a carrier for passing a pointer to call_rcu for closing, and not the real logfile.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-38-richard.henderson@linaro.org>
show more ...
|
#
92b24cb7 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Combine two logfile closes
Merge the close from the changed_name block with the close from the !need_to_open_file block.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: R
util/log: Combine two logfile closes
Merge the close from the changed_name block with the close from the !need_to_open_file block.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-37-richard.henderson@linaro.org>
show more ...
|
#
beab3447 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Hoist the eval of is_daemonized in qemu_set_log_internal
Only call is_daemonized once. We require the result on all paths after this point.
Reviewed-by: Alex Bennée <alex.bennee@linaro.or
util/log: Hoist the eval of is_daemonized in qemu_set_log_internal
Only call is_daemonized once. We require the result on all paths after this point.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-36-richard.henderson@linaro.org>
show more ...
|
#
702979f7 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Rename qemu_logfile_mutex to global_mutex
Rename to emphasize this covers the file-scope global variables.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henders
util/log: Rename qemu_logfile_mutex to global_mutex
Rename to emphasize this covers the file-scope global variables.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-35-richard.henderson@linaro.org>
show more ...
|
#
8ae58d60 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Rename qemu_logfile to global_file
Rename to emphasize this is the file-scope global variable.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug
util/log: Rename qemu_logfile to global_file
Rename to emphasize this is the file-scope global variable.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-34-richard.henderson@linaro.org>
show more ...
|
#
42266464 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Rename logfilename to global_filename
Rename to emphasize this is the file-scope global variable.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4
util/log: Rename logfilename to global_filename
Rename to emphasize this is the file-scope global variable.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-33-richard.henderson@linaro.org>
show more ...
|
#
ec0d1849 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Remove qemu_log_close
The only real use is in cpu_abort, where we have just flushed the file via qemu_log_unlock, and are just about to force-crash the application via abort. We do not re
util/log: Remove qemu_log_close
The only real use is in cpu_abort, where we have just flushed the file via qemu_log_unlock, and are just about to force-crash the application via abort. We do not really need to close the FILE before the abort.
The two uses in test-logging.c can be handled with qemu_set_log_filename_flags.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-32-richard.henderson@linaro.org>
show more ...
|
#
144539d3 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Introduce qemu_set_log_filename_flags
Provide a function to set both filename and flags at the same time. This is the common case at startup.
Signed-off-by: Richard Henderson <richard.he
util/log: Introduce qemu_set_log_filename_flags
Provide a function to set both filename and flags at the same time. This is the common case at startup.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-28-richard.henderson@linaro.org>
show more ...
|
#
7fc493f8 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
include/qemu/log: Move entire implementation out-of-line
Move QemuLogFile, qemu_logfile, and all inline functions into qemu/log.c. No need to expose these implementation details in the api.
Reviewe
include/qemu/log: Move entire implementation out-of-line
Move QemuLogFile, qemu_logfile, and all inline functions into qemu/log.c. No need to expose these implementation details in the api.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-26-richard.henderson@linaro.org>
show more ...
|
#
fb6efecf |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Drop call to setvbuf
Now that the log buffer is flushed after every qemu_log_unlock, which includes every call to qemu_log, we do not need to force line buffering (or unbuffering for windo
util/log: Drop call to setvbuf
Now that the log buffer is flushed after every qemu_log_unlock, which includes every call to qemu_log, we do not need to force line buffering (or unbuffering for windows). Block buffer the entire loggable unit.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-21-richard.henderson@linaro.org>
show more ...
|
#
90f37362 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Remove qemu_log_flush
All uses flush output immediately before or after qemu_log_unlock. Instead of a separate call, move the flush into qemu_log_unlock.
Reviewed-by: Alex Bennée <alex.be
util/log: Remove qemu_log_flush
All uses flush output immediately before or after qemu_log_unlock. Instead of a separate call, move the flush into qemu_log_unlock.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-20-richard.henderson@linaro.org>
show more ...
|
#
3c06a417 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Drop return value from qemu_log
The only user of this feature, tcg_dump_ops, has been converted to use fprintf directly.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: R
util/log: Drop return value from qemu_log
The only user of this feature, tcg_dump_ops, has been converted to use fprintf directly.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-18-richard.henderson@linaro.org>
show more ...
|
#
095e9855 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Use qemu_log_trylock/unlock in qemu_log
Avoid using QemuLogFile and RCU directly.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@lin
util/log: Use qemu_log_trylock/unlock in qemu_log
Avoid using QemuLogFile and RCU directly.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-17-richard.henderson@linaro.org>
show more ...
|
#
c60f599b |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Rename qemu_log_lock to qemu_log_trylock
This function can fail, which makes it more like ftrylockfile or pthread_mutex_trylock than flockfile or pthread_mutex_lock, so rename it.
To clos
util/log: Rename qemu_log_lock to qemu_log_trylock
This function can fail, which makes it more like ftrylockfile or pthread_mutex_trylock than flockfile or pthread_mutex_lock, so rename it.
To closer match the other trylock functions, release rcu_read_lock along the failure path, so that qemu_log_unlock need not be called on failure.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-8-richard.henderson@linaro.org>
show more ...
|
#
c59fe6e5 |
| 17-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
util/log: Move qemu_log_lock, qemu_log_unlock out of line
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <ri
util/log: Move qemu_log_lock, qemu_log_unlock out of line
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-7-richard.henderson@linaro.org>
show more ...
|