From patchwork Mon Aug 3 09:14:46 2015 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: 51855 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id 397D7229FD for ; Mon, 3 Aug 2015 09:20:47 +0000 (UTC) Received: by lbbyj8 with SMTP id yj8sf22692886lbb.3 for ; Mon, 03 Aug 2015 02:20:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding:cc :subject:precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=azxQZtlRzlPvW1G+LI78OCUqwENVH+FG0V+M2ArObDk=; b=JODj1y4oOiuqA0xY8wlhGcFwJognbygay9skq7C3SJWsiqurLe01F9aKa5WWstR98I 0q1Lcq/NXlUBQ0ejJzvIsqCq2hs98BDWak31pKH4Cc5nFEyXG6JNOcwEuaXAs/eUc/Qd VxkoIpwpbiHp9j3iBduSGXpsdWFg4PkjSIp3ujYsAM7+zZATU6OVa24F0fcuuOKupgLt VxmTQD0ULu7gJ3R4i+1BMIGJ6u9pVMykiqme60uhDQ0OERnjRiqTitwHTiOhKPpRgDEl NMsPLFOO0eOtAIvCqnizU5uZ5Oq8mUns//AJoYv+cz3AT9qohJ2kMOlXQO/nTSuece8X xP7Q== X-Gm-Message-State: ALoCoQnpI8rxho/sT9y4/aurEyPSdwH8yNoljN3goRckPg1sxIsFdTTSQaUGzfmeHrMRL/tWHuRL X-Received: by 10.112.98.42 with SMTP id ef10mr5316047lbb.18.1438593646144; Mon, 03 Aug 2015 02:20:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.3 with SMTP id r3ls74864lae.89.gmail; Mon, 03 Aug 2015 02:20:45 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr16111399lbb.56.1438593645927; Mon, 03 Aug 2015 02:20:45 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id f3si757590lag.4.2015.08.03.02.20.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 02:20:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbqc9 with SMTP id c9so49043424lbq.1 for ; Mon, 03 Aug 2015 02:20:45 -0700 (PDT) X-Received: by 10.112.120.134 with SMTP id lc6mr15861846lbb.86.1438593645834; Mon, 03 Aug 2015 02:20:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1755819lba; Mon, 3 Aug 2015 02:20:44 -0700 (PDT) X-Received: by 10.50.108.98 with SMTP id hj2mr19312494igb.52.1438593643082; Mon, 03 Aug 2015 02:20:43 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id pn5si5434597igb.7.2015.08.03.02.20.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Aug 2015 02:20:43 -0700 (PDT) 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; Received: from localhost ([::1]:58225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBvF-0006gl-Rq for patch@linaro.org; Mon, 03 Aug 2015 05:20:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBpu-0005Pq-Q5 for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMBpq-0003GZ-Gy for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:10 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:36862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBpq-0003FK-Br for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:06 -0400 Received: by wicgj17 with SMTP id gj17so95862723wic.1 for ; Mon, 03 Aug 2015 02:15:05 -0700 (PDT) X-Received: by 10.181.13.36 with SMTP id ev4mr32072115wid.65.1438593305874; Mon, 03 Aug 2015 02:15:05 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id gw7sm12524907wib.15.2015.08.03.02.15.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 02:15:04 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 98C133E0817; Mon, 3 Aug 2015 10:15:00 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Mon, 3 Aug 2015 10:14:46 +0100 Message-Id: <1438593291-27109-7-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438593291-27109-1-git-send-email-alex.bennee@linaro.org> References: <1438593291-27109-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] [fuzzy] X-Received-From: 209.85.212.172 Cc: qemu-trivial@nongnu.org, crosthwaitepeter@gmail.com, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH v4 06/11] 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 --- qemu-log.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/qemu-log.c b/qemu-log.c index 7036076..77ed7bc 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); }