From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2grz-0007Cq-Qv for qemu-devel@nongnu.org; Wed, 10 Jun 2015 10:20:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2gru-0004G4-SC for qemu-devel@nongnu.org; Wed, 10 Jun 2015 10:20:43 -0400 Received: from mail-yk0-x232.google.com ([2607:f8b0:4002:c07::232]:33648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2gru-0004F5-Nl for qemu-devel@nongnu.org; Wed, 10 Jun 2015 10:20:38 -0400 Received: by ykfr66 with SMTP id r66so23602141ykf.0 for ; Wed, 10 Jun 2015 07:20:38 -0700 (PDT) From: Pranith Kumar Date: Wed, 10 Jun 2015 10:20:24 -0400 Message-Id: <1433946024-18439-1-git-send-email-bobby.prani@gmail.com> Subject: [Qemu-devel] [RFC PATCH] qemu-log: Open file for logging when specified List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Paolo Bonzini Cc: Peter Maydell , Markus Armbruster , Luiz Capitulino 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 CC: Paolo Bonzini CC: Luiz Capitulino CC: Markus Armbruster CC: Peter Maydell --- vl.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/vl.c b/vl.c index d4b2d03..5f81ccc 100644 --- a/vl.c +++ b/vl.c @@ -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); -- 1.9.1