From patchwork Fri Mar 28 16:43:24 2014 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: 27358 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9523120545 for ; Fri, 28 Mar 2014 16:44:26 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id gq1sf18385592obb.7 for ; Fri, 28 Mar 2014 09:44:26 -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: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:content-type :content-transfer-encoding; bh=UxVsmX0s2ZL8h7aDYdJ3ATjQHMlE46584NzCRdQMWeQ=; b=JuLVS13Cfzb2g7t9HcC27zt3BEEUEn/gwHxE5gnkGJoyibkZuYe2oYUsREVIX5/yCF AV6iYEzR/gvBR2NN8dxiKBm+h3aF+1w9t5V7iUOLhFFtAoJrJdADoDkiS0tH8gTVQznj Av8T11mcJA/9rMf9B4kluFek5x1eYl5rZ8kOElNXPL/FMJLA0lSpS24HCzTP4if6p/fv FSuCNKZANRkK//sL5fcHGkEYFFa4bze61on3LAicHJkW61OwwX+g4zJ73pGGLPzPypev DKDVjvE3IheNO4tQLE8nluXEXo8pQb0M3+jIXOKt83DSH4P9u/OtHSDNkN7XqtJmBZbL l3QA== X-Gm-Message-State: ALoCoQmpVzFUUk2HvcrJ8vuYKImdj9W+Nex1nsUVofEyFYV9+wyQbnNt/jQdZgmhu3FSfY5e7kSh X-Received: by 10.50.47.6 with SMTP id z6mr4501784igm.4.1396025066153; Fri, 28 Mar 2014 09:44:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.181 with SMTP id h50ls1532594qgh.15.gmail; Fri, 28 Mar 2014 09:44:26 -0700 (PDT) X-Received: by 10.58.152.142 with SMTP id uy14mr7907669veb.4.1396025066059; Fri, 28 Mar 2014 09:44:26 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id sh5si1327699vdc.194.2014.03.28.09.44.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 09:44:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id oz11so5969406veb.33 for ; Fri, 28 Mar 2014 09:44:26 -0700 (PDT) X-Received: by 10.58.1.97 with SMTP id 1mr2269340vel.23.1396025065979; Fri, 28 Mar 2014 09:44:25 -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.220.12.8 with SMTP id v8csp23161vcv; Fri, 28 Mar 2014 09:44:25 -0700 (PDT) X-Received: by 10.140.41.80 with SMTP id y74mr2991588qgy.104.1396025065424; Fri, 28 Mar 2014 09:44:25 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r9si2798393qar.1.2014.03.28.09.44.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Mar 2014 09:44:25 -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]:34937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZtJ-0007jT-1P for patch@linaro.org; Fri, 28 Mar 2014 12:44:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZsU-00077B-FX for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTZsP-0002jd-D1 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:34 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:56333 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZsP-0002jQ-6A for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:29 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1WTZso-0004ll-6w; Fri, 28 Mar 2014 17:43:54 +0100 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 28 Mar 2014 16:43:24 +0000 Message-Id: <1396025007-27592-5-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1396025007-27592-1-git-send-email-alex.bennee@linaro.org> References: <1396025007-27592-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [Qemu-devel] [PATCH v2 4/7] 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=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 diff --git a/qemu-log.c b/qemu-log.c index 83e0cb4..4dd530c 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); }