qemu-log: Open file for logging when specified
RFC PATCH 1/1 qemu-log: Open file for logging when specified
qemu-log defaults to stderr when there is no '-D' option mentioned on command line. When '-D' option is specified, we also need to specify '-d' option for it to use the specified logfile. When using monitor to enable logging this is troublesome since there will be no '-d' option because of which monitor dumps the logs to stderr.
Fix this by opening the log file when '-D' is specified on the command line. Also fix an ancient comment which does not hold true since changing location and log level has now been streamlined.
--- vl.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
vl.c +5 -8
@@ -3845,17 +3845,14 @@ int main(int argc, char **argv, char **envp)exit (0 ); } -/* Open the logfile at this point, if necessary. We can't open the logfile -* when encountering either of the logging options (-d or -D) because the -* other one may be encountered later on the command line, changing the -* location or level of logging. +/* Open the logfile at this point and set the log mask if necessary. */ +if (log_file) { +qemu_set_log_filename (log_file); + } +if (log_mask) {int mask; -if (log_file) { -qemu_set_log_filename (log_file); - } - mask =qemu_str_to_log_mask (log_mask);if (!mask) {qemu_print_log_usage (stdout);
Signature · 1 line
1.9.1
Quoted 37 lines · Pranith Kumar
qemu-log defaults to stderr when there is no '-D' option mentioned on command line. When '-D' option is specified, we also need to specify '-d' option for it to use the specified logfile. When using monitor to enable logging this is troublesome since there will be no '-d' option because of which monitor dumps the logs to stderr.
Fix this by opening the log file when '-D' is specified on the command line. Also fix an ancient comment which does not hold true since changing location and log level has now been streamlined.
Signed-off-by Pranith Kumar <[email protected]>CC Paolo Bonzini <[email protected]>CC Luiz Capitulino <[email protected]>CC Markus Armbruster <[email protected]>CC Peter Maydell <[email protected]>--- vl.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)vl.c +4
-4@@ -3845,17 +3845,14 @@ int main(int argc, char **argv, char **envp)exit (0 ); } -/* Open the logfile at this point, if necessary. We can't open the logfile -* when encountering either of the logging options (-d or -D) because the -* other one may be encountered later on the command line, changing the -* location or level of logging. +/* Open the logfile at this point and set the log mask if necessary. */ +if (log_file) { +qemu_set_log_filename (log_file); + }
vl.c int main(int argc, char **argv, char **envp) · line 3858
Quoted 10 lines
vl.c +1
-4+if (log_mask) {int mask; -if (log_file) { -qemu_set_log_filename (log_file); - } - mask =qemu_str_to_log_mask (log_mask);if (!mask) {qemu_print_log_usage (stdout);
Good idea---also it is consistent with what user-mode emulation already does.
Paolo