From patchwork Wed Mar 16 10:46:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8597591 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 36920C0553 for ; Wed, 16 Mar 2016 10:47:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A026320306 for ; Wed, 16 Mar 2016 10:47:19 +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 C13CA202FE for ; Wed, 16 Mar 2016 10:47:17 +0000 (UTC) Received: from localhost ([::1]:54898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ag8yz-0002ZA-79 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 16 Mar 2016 06:47:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ag8yp-0002Yq-Ce for qemu-devel@nongnu.org; Wed, 16 Mar 2016 06:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ag8yn-0001wb-Eh for qemu-devel@nongnu.org; Wed, 16 Mar 2016 06:47:07 -0400 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:38696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ag8yn-0001vc-7P for qemu-devel@nongnu.org; Wed, 16 Mar 2016 06:47:05 -0400 Received: by mail-wm0-x231.google.com with SMTP id l68so66044460wml.1 for ; Wed, 16 Mar 2016 03:47:05 -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=Q2JoVdeg2r7Ke0Jrio/PG3P4J/tLSU8R64SeZ0bdC1g=; b=XhlPITruy3wK/k2/6L4/TPHNl/vqv82k949iRPtSJUIaW/74cV8WmTdING09dz0437 9z69s6GAkoSlGOk0Wp0/cJputvlq/5L16dVHZ2jG+Luy3c0LvAF6X0f22qaUxO49d5m+ 7bXyYBQ9ijJXzhZJ+GnV7BREulp396UrGRGRiwWHo2btBf3daWpCKzMSe0NbVKhOF7JO TsLYv3ogriIc3M7YV5eI0t+VX8s+Z1s2mW1NMTxzNPmW3fxSNE/ykvQ5649+HU6HBfow brsqik5PKWbCe5/vdZoDqauXlDXp1VhvqZRrMyktu8AmzavVjwmzYkorCi3ug8ZY4apD 3DXA== 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=Q2JoVdeg2r7Ke0Jrio/PG3P4J/tLSU8R64SeZ0bdC1g=; b=i2vZ2ZvJMnAZCvl/pNBR1f7DLYVQRIKV6Vd9QBq/125dNm5dL0pDutEVCO5qmCMj2s ccUGXoTfGbeIBAEL7Z74kBoP4pFAM/n8tT67eZpGWLFLfAKb0r5RNR2nvrqmi4xX5Iph Xg0iZy1PPdaN0V37rFJGVo1TpRA2jG0MQ11ZBkxVrS5oDfoOY2/og6Q+2cygfxYbcI56 3dE4cgPMOfnNCp0Yax+gbi7eZ+qVZ1Eu64aGCS0gYFRon/7HTkelx/EDwhyOB6GKvqid VFLhhuYH+iom/v7u8ifr61i6MoVNmsakQeYhFXiefWUpnxJj980z8lWq/ILZOiAP9PE3 zRcg== X-Gm-Message-State: AD7BkJKrrVygcfbTcUZASQ98kvUXLBc33f1OBWtIsEYrr/NM32WV/uu0MJ/hWtHoXfw4tw== X-Received: by 10.28.128.83 with SMTP id b80mr3690861wmd.6.1458125224514; Wed, 16 Mar 2016 03:47:04 -0700 (PDT) Received: from 640k.lan (94-39-161-17.adsl-ull.clienti.tiscali.it. [94.39.161.17]) by smtp.gmail.com with ESMTPSA id wr2sm2418094wjc.49.2016.03.16.03.47.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Mar 2016 03:47:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 16 Mar 2016 11:46:12 +0100 Message-Id: <1458125219-131698-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1458125219-131698-1-git-send-email-pbonzini@redhat.com> References: <1458125219-131698-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::231 Subject: [Qemu-devel] [PATCH 02/49] log: do not use CONFIG_USER_ONLY X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org 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 --- bsd-user/main.c | 1 + include/qemu/log.h | 17 ++--------------- linux-user/main.c | 1 + util/log.c | 11 +++++++++-- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 287ec1d..c83b43f 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -848,6 +848,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 40c24fd..1e59720 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -99,21 +99,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); int qemu_str_to_log_mask(const char *str); diff --git a/linux-user/main.c b/linux-user/main.c index 2b1e755..63bef30 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3752,6 +3752,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 8b921de..9dc8158 100644 --- a/util/log.c +++ b/util/log.c @@ -49,8 +49,10 @@ void qemu_log_mask(int mask, 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 @@ -77,7 +79,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)); @@ -97,6 +99,11 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers) } } +void qemu_log_needs_buffers(void) +{ + log_uses_own_buffers = true; +} + void qemu_set_log_filename(const char *filename) { g_free(logfilename);