From patchwork Thu Jul 31 13:06:29 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: 34643 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B081D20792 for ; Thu, 31 Jul 2014 13:23:55 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf13762539ieb.2 for ; Thu, 31 Jul 2014 06:23:55 -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=wIcZmj92po6CjwRnGEhEbGOI5l8Xbvk2Z7mwp1Z6wFc=; b=R11KecBiFCAxb7KWHuMxsqxBfc6Or0lXP9AQfV5WqdW7TBjYIH+w+Ynj1ix04Badd7 wkzVmGYdYNbF/YfaZZRN5MNajKSmAuh2D9gr15UAkgEUiQvrKsCK/t/0NAPdczWfwqV3 2KCmia22IZ4TxT8y031lDAlsbhcsFhvgy4lgz1aiZaafhAo0ziUrUutpitDhelcL3Lj8 jQum/cl4BJRoHtTgvHsM85sFNaS3QA2UYcze6Qg+O/3cPDWuCtDkiI06eRXGqxsiucvJ EDLL9XdOyW23/6F9QsaHQCHAMHz82r7lch9n+bZwTyFBwgiQ3zwcrpU5LY1dgJDAxZtZ kbQg== X-Gm-Message-State: ALoCoQnlWyieJjoXLOZm9LkGyLMMIZZ7JmQhqe4eGELilm98s9LJMJn1qPOLxuyqvo8RGej13JzF X-Received: by 10.182.18.8 with SMTP id s8mr1480290obd.21.1406813035187; Thu, 31 Jul 2014 06:23:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.17.53 with SMTP id 50ls939882qgc.21.gmail; Thu, 31 Jul 2014 06:23:55 -0700 (PDT) X-Received: by 10.52.82.166 with SMTP id j6mr1701569vdy.87.1406813035078; Thu, 31 Jul 2014 06:23:55 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id ci13si4341589vec.13.2014.07.31.06.23.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 31 Jul 2014 06:23:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so4117850vcb.8 for ; Thu, 31 Jul 2014 06:23:55 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr12659746vca.45.1406813034986; Thu, 31 Jul 2014 06:23:54 -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.221.37.5 with SMTP id tc5csp18027vcb; Thu, 31 Jul 2014 06:23:54 -0700 (PDT) X-Received: by 10.224.38.134 with SMTP id b6mr18520632qae.28.1406813034495; Thu, 31 Jul 2014 06:23:54 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m3si9699907qac.53.2014.07.31.06.23.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 31 Jul 2014 06:23:54 -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]:56648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCqKo-0003hq-23 for patch@linaro.org; Thu, 31 Jul 2014 09:23:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCq4H-00006Z-3H for qemu-devel@nongnu.org; Thu, 31 Jul 2014 09:06:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCq48-0001Ev-KQ for qemu-devel@nongnu.org; Thu, 31 Jul 2014 09:06:49 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:50101 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCq48-0001Ef-89 for qemu-devel@nongnu.org; Thu, 31 Jul 2014 09:06:40 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1XCqDz-0002HE-2G; Thu, 31 Jul 2014 15:16:51 +0200 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 31 Jul 2014 14:06:29 +0100 Message-Id: <1406811992-6766-7-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.0.3 In-Reply-To: <1406811992-6766-1-git-send-email-alex.bennee@linaro.org> References: <1406811992-6766-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?= , l@dorileo.org Subject: [Qemu-devel] [PATCH v3 6/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 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.220.177 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 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); }