From patchwork Mon Jun 19 10:46:52 2017 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: 105825 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp811285qgd; Mon, 19 Jun 2017 03:53:46 -0700 (PDT) X-Received: by 10.176.92.198 with SMTP id z6mr15082644uaf.27.1497869626385; Mon, 19 Jun 2017 03:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869626; cv=none; d=google.com; s=arc-20160816; b=KUizhyIdWlP/uHC7Qhm3hSJD6el+67rfgoD0t61t3GqTqUYmIzLdnObIl3LdYt9cQK Rm7vgUhmGm5b9/YsRlyu70XzLBP6byuGnlvCSvrK2/7nSq9GCkAv27r8afa+LNsNDb2e nuyAw6ENoq2rYhN6cvY7QjnyfNlUrO5VC/7G2lRTSOL0TIaMcHL7betAYpWSGnMocDLl ea/qvuRAnbfqkbnLbGo9SaCmm2BWHV4150AiYZT5s0oD/j+AQrDeqaCTq38W3JG5Kc+y c2cxFhAWLtaGp7+GbHFqczaY5IAC4sUIrAoewDSN+45gCaCHpSNNtwezEAE1bqYBuIRy NBSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=ysmko3BJIBdfWyUXjgI9a9ZqdVXmJ/oPPt98TGkAqoM=; b=DtLfHo4twFP6amuhkireC7NspMV0wd6V5e7eUz2UvrDQfUwb68vPF64DIarJxshLvm AOLtOWd60X8edXoyJjep2aYUEWibf5Mn/XWqp22xjJbXw4UBQ/LeCwEpLGvVZgzW5VUA qyKJ7YU8eS3N0E8K5eW6ePL5UWnct5KsV8YUgF+PVxYuAHKn7+IRkmG+kT2DgQ/me2n7 4YF9rsdZ5zhRmlzI482naB/zvAQiQ+VJHq+y4SRbkJN6A7R8znEj4AxkCurndzieDbc2 KZeYlBiQA0r4lSwnyf7t/3YzrJgaWW+MV/u+61c4D+U0Y0XHsv0Mdcj0sLaLFaAfZ4nv GZww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=NS/8LoUK; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v70si4076130vkv.226.2017.06.19.03.53.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:53:46 -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; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=NS/8LoUK; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuJW-0004xS-0P for patch@linaro.org; Mon, 19 Jun 2017 06:53:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCV-0007O8-E8 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCU-0004vZ-EM for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:31 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:35297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCU-0004v5-7I for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:30 -0400 Received: by mail-wr0-x22e.google.com with SMTP id y25so30274708wrd.2 for ; Mon, 19 Jun 2017 03:46:30 -0700 (PDT) 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-transfer-encoding; bh=ysmko3BJIBdfWyUXjgI9a9ZqdVXmJ/oPPt98TGkAqoM=; b=NS/8LoUKGRtjq1XYMmnLZ+vD3+WcDlajlqomSpO2Vh/SqvF9IYKXH3+aoZSbo7SXHC L08xYcHLnBMGM82exOTWsHP3TOAglHHPk0lmv43BXwuvnih/jvi+7RG7aVviQKxNTBOS 4d+SpMhDDVhXtVH/7tDlOFgdcMYmBQ0cELFEo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ysmko3BJIBdfWyUXjgI9a9ZqdVXmJ/oPPt98TGkAqoM=; b=aiIDSjHO1kD4vks7AdIr2h/aH0I4fcqmJ4g0PrACLUA736UCTGdawmSSaIOsL2qy/C zBvc+K41fWs1zrMliimfMTb380XZGYmQh4WxyBrYU4llpnObpH6EliA8dIuy+6nrATKP B38hDHXbCMAMD5ghLXFgQRI09h/vLfeFJ4k3Eq6bgfmcdYp6YBeqVinhrKnNyzwJZtON df2gJnLbxQ1Cuuju4pSgFa6kaDXzd4XT1S1SR6TiqMP6LzgcT2dEP/ow+5x3p1juKk0B N1ECmqwBCBooHgcCK3aoHqlLSnyc11TyEk1z5ga1/AOrDO30V1U7x0l5kLRKexqlwESB U0xg== X-Gm-Message-State: AKS2vOz65sCaGM3MLVbRgszJnoRFcwCsigTd+HtFLckVsEkqb2hDjtm6 lPNsz55mumXVX6is X-Received: by 10.223.165.13 with SMTP id i13mr12985815wrb.35.1497869189096; Mon, 19 Jun 2017 03:46:29 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a99sm16465094wrc.64.2017.06.19.03.46.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7C8393E0C03; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:52 +0100 Message-Id: <20170619104655.31104-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22e Subject: [Qemu-devel] [RISU PATCH v5 10/13] risu: handle trace through stdin/stdout X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Trace files can get quite large so it would be useful to be able to just capture the trace stream with stdin/stdout for processing in a pipe line. The sort of case where this is useful is for building static binaries where zlib support is missing for whatever reason. It can also be used in testing pipelines. Signed-off-by: Alex Bennée --- risu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.13.0 diff --git a/risu.c b/risu.c index 93c274b..e94b54b 100644 --- a/risu.c +++ b/risu.c @@ -312,7 +312,11 @@ int main(int argc, char **argv) if (ismaster) { if (trace) { - master_fd = open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + if (strncmp(trace_fn, "-", strlen(trace_fn))==0) { + master_fd = fileno(stdout); + } else { + master_fd = open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + } } else { fprintf(stderr, "master port %d\n", port); master_fd = master_connect(port); @@ -320,7 +324,11 @@ int main(int argc, char **argv) return master(); } else { if (trace) { - apprentice_fd = open(trace_fn, O_RDONLY); + if (strncmp(trace_fn, "-", strlen(trace_fn))==0) { + apprentice_fd = fileno(stdin); + } else { + apprentice_fd = open(trace_fn, O_RDONLY); + } } else { fprintf(stderr, "apprentice host %s port %d\n", hostname, port); apprentice_fd = apprentice_connect(hostname, port);