From patchwork Fri Apr 8 20:28:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8785571 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 294E6C0553 for ; Fri, 8 Apr 2016 20:29:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6CA92202DD for ; Fri, 8 Apr 2016 20:29:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B72892024D for ; Fri, 8 Apr 2016 20:29:34 +0000 (UTC) Received: from localhost ([::1]:58037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aod26-0003TY-0w for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Apr 2016 16:29:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aod1r-0003Q8-5P for qemu-devel@nongnu.org; Fri, 08 Apr 2016 16:29:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aod1p-00020W-Iv for qemu-devel@nongnu.org; Fri, 08 Apr 2016 16:29:19 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aod1p-00020Q-BU for qemu-devel@nongnu.org; Fri, 08 Apr 2016 16:29:17 -0400 Received: by mail-wm0-x242.google.com with SMTP id a140so6837184wma.2 for ; Fri, 08 Apr 2016 13:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=5DN1oyNKvniNb7o0xcGWRqanav1QAbxd95CNDe8dQro=; b=iuhmjsvg9/Yf9GlIsT5pfp4iymGaACD83QJkN7lurlpAbc3lkqKx583YRpAQ3Ei6lj Y3yXg/gOp+WLKEyKaQsBbXcoZYumMDTUSODdZiM45FFFNdJ0C9AeZxSRPBY3fApDWbwt bc9Xt4T0bfUVluPAQWhwhi0y3bd2jIMYfADvSsRlbh6MNxc+HvOYj8MIpVqc3xlAjS86 rJantJS54AtftyRZK2aiVt5PXkwpIKsKvgs3dDy+D9tAS4Mw+iBQrcaTSctKpJxt07Nx hADsQpN4j5aEYxLMLzrPVSJ4FCejTbvJcI1j7InPr5FQXu9aNoIKmvfdWN75crY3D6jJ LtWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=5DN1oyNKvniNb7o0xcGWRqanav1QAbxd95CNDe8dQro=; b=Vn3IOtSPmEGd5qYQGXwz6Ndh6/eskiUNhOKLZTHB0U7D/P1O+dNvV9KNrKAW1Z6CFZ QFgA/3P26FQXtamcuz2do2HXItbvyQXJvbamAAhMXifvpt5TpvWAtAZdL91D/zlreGsG +1430JJXqVQEtv5MLbkfgsBcZGUSKn9a/bf2piVxRgLkxz9betR0QBG1EXrWWtFWDDOJ u+ag59u9qKtEBtbU9FBeU9iTGuKq2hpKWTQsZC4dZbM0j/Zxf16m0pe90+2CUE2Xd62R IMvm1KQXzG0LVwlHfL+9vyihWcVjIla+XzQCwAGiL0cVcMQswg8TJjI4IXcSP2i1gxL5 8JEQ== X-Gm-Message-State: AD7BkJK3GPhclIDHxwwtb9zWMbLHvNrfr1RfI2Qzbh3fcoiO+awyaXMawGr0/RlEeJ2aVw== X-Received: by 10.28.172.194 with SMTP id v185mr5628456wme.21.1460147356744; Fri, 08 Apr 2016 13:29:16 -0700 (PDT) Received: from 640k.lan (94-39-141-76.adsl-ull.clienti.tiscali.it. [94.39.141.76]) by smtp.gmail.com with ESMTPSA id w10sm3849168wjz.9.2016.04.08.13.29.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Apr 2016 13:29:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 8 Apr 2016 22:28:23 +0200 Message-Id: <1460147350-7601-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1460147350-7601-1-git-send-email-pbonzini@redhat.com> References: <1460147350-7601-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH 03/50] log: do not use CONFIG_USER_ONLY X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This decouples logging further from config-target.h Signed-off-by: Paolo Bonzini Reviewed-by: Alex Bennée --- bsd-user/main.c | 1 + include/qemu/log.h | 17 ++--------------- linux-user/main.c | 1 + util/log.c | 12 ++++++++++-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 27854c1..058eaca 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -849,6 +849,7 @@ int main(int argc, char **argv) } /* init debug */ + qemu_log_needs_buffers(); qemu_set_log_filename(log_file); if (log_mask) { int mask; diff --git a/include/qemu/log.h b/include/qemu/log.h index c52f136..234fa81 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -104,21 +104,8 @@ typedef struct QEMULogItem { extern const QEMULogItem qemu_log_items[]; -/* This is the function that actually does the work of - * changing the log level; it should only be accessed via - * the qemu_set_log() wrapper. - */ -void do_qemu_set_log(int log_flags, bool use_own_buffers); - -static inline void qemu_set_log(int log_flags) -{ -#ifdef CONFIG_USER_ONLY - do_qemu_set_log(log_flags, true); -#else - do_qemu_set_log(log_flags, false); -#endif -} - +void qemu_set_log(int log_flags); +void qemu_log_needs_buffers(void); void qemu_set_log_filename(const char *filename); void qemu_set_dfilter_ranges(const char *ranges); bool qemu_log_in_addr_range(uint64_t addr); diff --git a/linux-user/main.c b/linux-user/main.c index 5f3ec97..2b7fa9c 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3760,6 +3760,7 @@ static void handle_arg_log(const char *arg) qemu_print_log_usage(stdout); exit(EXIT_FAILURE); } + qemu_log_needs_buffers(); qemu_set_log(mask); } diff --git a/util/log.c b/util/log.c index 1857730..5ad72c1 100644 --- a/util/log.c +++ b/util/log.c @@ -42,8 +42,10 @@ void qemu_log(const char *fmt, ...) va_end(ap); } +static bool log_uses_own_buffers; + /* enable or disable low levels log */ -void do_qemu_set_log(int log_flags, bool use_own_buffers) +void qemu_set_log(int log_flags) { qemu_loglevel = log_flags; #ifdef CONFIG_TRACE_LOG @@ -70,7 +72,7 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers) qemu_logfile = stderr; } /* must avoid mmap() usage of glibc by setting a buffer "by hand" */ - if (use_own_buffers) { + if (log_uses_own_buffers) { static char logfile_buf[4096]; setvbuf(qemu_logfile, logfile_buf, _IOLBF, sizeof(logfile_buf)); @@ -89,6 +91,12 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers) qemu_log_close(); } } + +void qemu_log_needs_buffers(void) +{ + log_uses_own_buffers = true; +} + /* * Allow the user to include %d in their logfile which will be * substituted with the current PID. This is useful for debugging many