From patchwork Thu Feb 4 14:56:17 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: 61196 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp507737lbl; Thu, 4 Feb 2016 07:02:34 -0800 (PST) X-Received: by 10.140.106.97 with SMTP id d88mr9562495qgf.84.1454598154377; Thu, 04 Feb 2016 07:02:34 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s131si10925567qhs.77.2016.02.04.07.02.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 04 Feb 2016 07:02:34 -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]:42259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRLQX-0002Lu-Sq for patch@linaro.org; Thu, 04 Feb 2016 10:02:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRLKq-0001hQ-8S for qemu-devel@nongnu.org; Thu, 04 Feb 2016 09:56:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRLKp-0001Rx-8r for qemu-devel@nongnu.org; Thu, 04 Feb 2016 09:56:40 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:36493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRLKp-0001Rf-2W for qemu-devel@nongnu.org; Thu, 04 Feb 2016 09:56:39 -0500 Received: by mail-wm0-x22b.google.com with SMTP id p63so215700100wmp.1 for ; Thu, 04 Feb 2016 06:56:38 -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=crfcbXdT+9HuZUk4KIJGleiOOBE0KCl0SFw2H7x6+0k=; b=b4M3+2GHsBFeEmlpAZoJvRzuAFyp+Kr/xVDx7ozfNBdUQlBlyPiVqw97yVKMNxTQ0s HauJk0fiEBXJuvVWiRjG4/nu9xKPpanInmxDX0un2xM1URwNkL4MwiW0JeJmxl1ghO7u +qK8FTGd8K0mTQNj9gt3twlDvjFObKuBTnKTI= 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=crfcbXdT+9HuZUk4KIJGleiOOBE0KCl0SFw2H7x6+0k=; b=Bt/WVV12v8mRi8SD1xAD7JVd750n3XvdkROi+Jk5kJysm8JDrgZvAV79MN4al14R7B U76amJ68B+04dDqC9sNAdyTJoBUhceszOf6OvT5q5PCKwZorcPVW49r1KLdU/p7VQisn uAdWguOT5R5KX0sINNM/L5/gVC7cCFxNaYmKeJkSnt5leSnzKbboZrj3Jn44P/hv7XFq 9DasTpu/7qQbyUKpJ21s45fXi7+/iCuuCW2k1rmxMw1W1ikF/c68qkzPdqV5ZXgFaHLX AnDpsjusDrMoMZBOy+ylZyHUUal+CbTfLsTN+Ep7a+DlNwcF7YH3sZLbIZX+ixWc6NiG hOOQ== X-Gm-Message-State: AG10YORHDsGGfGjkWGvcRoJ0YEVchY2shqtDxX9gkb9BpGTb3/aCy+eAHxOiNia7vWwwJK5w X-Received: by 10.28.150.66 with SMTP id y63mr13921026wmd.17.1454597798368; Thu, 04 Feb 2016 06:56:38 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z127sm26656806wme.2.2016.02.04.06.56.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Feb 2016 06:56:34 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E55F93E0790; Thu, 4 Feb 2016 14:56:29 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 4 Feb 2016 14:56:17 +0000 Message-Id: <1454597781-18115-6-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454597781-18115-1-git-send-email-alex.bennee@linaro.org> References: <1454597781-18115-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::22b Cc: peter.maydell@linaro.org, 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 v5 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 --- qemu-log.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- 2.7.0 diff --git a/qemu-log.c b/qemu-log.c index 8c59063..2eebac0 100644 --- a/qemu-log.c +++ b/qemu-log.c @@ -70,11 +70,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); }