From patchwork Thu Feb 11 10:41:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 61722 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp111956lbl; Thu, 11 Feb 2016 02:44:16 -0800 (PST) X-Received: by 10.140.85.19 with SMTP id m19mr45652939qgd.106.1455187456160; Thu, 11 Feb 2016 02:44:16 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a126si8913738qkb.100.2016.02.11.02.44.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 11 Feb 2016 02:44:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dkim=fail header.i=@linaro.org Received: from localhost ([::1]:48534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTojP-0004ji-Mc for patch@linaro.org; Thu, 11 Feb 2016 05:44:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTogm-0000Ip-9k for qemu-devel@nongnu.org; Thu, 11 Feb 2016 05:41:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTogl-0004qs-B3 for qemu-devel@nongnu.org; Thu, 11 Feb 2016 05:41:32 -0500 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:38428) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTogl-0004qm-4p for qemu-devel@nongnu.org; Thu, 11 Feb 2016 05:41:31 -0500 Received: by mail-wm0-x234.google.com with SMTP id p63so62362519wmp.1 for ; Thu, 11 Feb 2016 02:41:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=vYDXKn1tYgWIXM8+I/4kk/GywLJTmqob8pU+nbVm4BI=; b=QB6Z91DrPlHeyQYAHG+Q0Kmc+5zy42yfGGyhTTk7HYgXEc6WTZM1xcC+Xy4pQkqjhb a9UmHSkNlMUeyAFYVXufyYMobOputd6VPgO8IyibqvBqBA2wWJ8vLyP5HFXd4yGJIEJc niuzJKciSpnY3VFtTQgKFkRkFEuba4oelAfSc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=vYDXKn1tYgWIXM8+I/4kk/GywLJTmqob8pU+nbVm4BI=; b=iea9Li5SihHhv0t3amX7PEmCkDjQbhXV2fhbSme4KVmGbM9qNA6m1iQiMgDQPrtdzX CUratIpxsrDkpwaSuBAukkS7jBBiKb/XOSfmSyS3bvNYRyjgFqDLSrcf/LnjJPuuM0sN O8iNdeEIZ7IP/oxXtIFOM3LrJmF2r0bt/yA0GpaxtP9o9zmCAPa6i82e1ydArQ7Vy209 +kSis1A0fDRduXuoQvgstLJlOo09aou/+nVkWnwIEh5EchwUDkX+eisQgDM0/miBcCrC 99n7yFelJ7t7/4FWPUQacUBRIaYaf7ovR0WIu1eGHNM4LV3p9CkX2HSuRA8G66IzPyfI gZ1w== X-Gm-Message-State: AG10YOS5uDQp514o8PBM0MTfwas7zCyegIulmOBWe7l74pyBzCTS7E10Jd7nr1cQRBkm71SF X-Received: by 10.194.9.98 with SMTP id y2mr46026453wja.105.1455187290514; Thu, 11 Feb 2016 02:41:30 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id av3sm6940652wjc.44.2016.02.11.02.41.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 02:41:29 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id ED08B3E020C; Thu, 11 Feb 2016 10:41:22 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 11 Feb 2016 10:41:01 +0000 Message-Id: <1455187265-26631-6-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1455187265-26631-1-git-send-email-alex.bennee@linaro.org> References: <1455187265-26631-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 Cc: dgilbert@redhat.com, crosthwaitepeter@gmail.com, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH v6 5/9] qemu-log: support simple pid substitution in logfile 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When debugging stuff that occurs over several forks it would be useful not to keep overwriting the one logfile you've set-up. This allows a simple %d to be included once in the logfile parameter which is substituted with getpid(). Signed-off-by: Alex Bennée Reviewed-by: Leandro Dorileo Reviewed-by: Aurelien Jarno --- v5 - add another r-b --- util/log.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- 2.7.0 diff --git a/util/log.c b/util/log.c index c89b226..3988b5d 100644 --- a/util/log.c +++ b/util/log.c @@ -75,11 +75,24 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers) qemu_log_close(); } } - +/* + * Allow the user to include %d in their logfile which will be + * substituted with the current PID. This is useful for debugging many + * nested linux-user tasks but will result in lots of logs. + */ void qemu_set_log_filename(const char *filename) { g_free(logfilename); - logfilename = g_strdup(filename); + if (g_strrstr(filename, "%d")) { + /* if we are going to format this we'd better validate first */ + if (g_regex_match_simple("^[^%]+%d[^%]+$", filename, 0, 0)) { + logfilename = g_strdup_printf(filename, getpid()); + } else { + g_error("Bad logfile format: %s", filename); + } + } else { + logfilename = g_strdup(filename); + } qemu_log_close(); qemu_set_log(qemu_loglevel); }