From nobody Wed Nov 5 13:56:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498060131106599.1174965889813; Wed, 21 Jun 2017 08:48:51 -0700 (PDT) Received: from localhost ([::1]:54768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhs7-0003pQ-TJ for importer@patchew.org; Wed, 21 Jun 2017 11:48:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlq-0006Gd-5T for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhlp-0002s4-CT for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:18 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:34180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhlp-0002rl-69 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:17 -0400 Received: by mail-wr0-x22b.google.com with SMTP id 77so140153625wrb.1 for ; Wed, 21 Jun 2017 08:42:17 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y89sm16343701wmh.13.2017.06.21.08.42.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 72A623E0F8B; Wed, 21 Jun 2017 16:42:51 +0100 (BST) 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=/v7qEn9OUH4Ho5RKpb1O3APGA9roAlKy9N6ZoVROiGI=; b=ZRHvQTappTkTBIiJgCGxdwP8ZJn4VTNAjpb32yNBiOmJgR/rFFZRm5NVsH3AMcumIX ahF5YEP5/qN0lgU6WaS4gXxo4JImLL+4xHA1/lc+iZlPpEVUTubE5Mc2UZUlyKovmJLQ f10sF6pV+CoXUvdH8BkqnoIRPBqD4af44S/gE= 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=/v7qEn9OUH4Ho5RKpb1O3APGA9roAlKy9N6ZoVROiGI=; b=N+pZRqtRVwIQvpdeipFhrzf1QRds9fpNWfY4ugLSPVHHbyg5s9tMJIN/gN9hQRLtx6 bcjv66+qggiTmphQhHiUf7g9pmdwwPHmYUdJAb9IJgcVptNOcRIli/sqgNOXJXk7vi+a 2rRq9SXaGlYdMU6EsiVOs0YRhBghSQ3IM7CO6AfGqI970A1GfHB7AM9b28egM0exhZle tIOwWKBK9f/QF4kSms9tXs9TpH/+Oy7owwFCaF8xq02uMo9vziKRdZlqbVzj2MzUSN7w QfFs+8e7bfwH0ixt8pTYMd/sVO7g63zCwn/29GgzOwg1NvcMQKFFjIfu6zPnbOKC/eJx VNtg== X-Gm-Message-State: AKS2vOzq0m4qZe90hk7B/HJ6rSjHRFR8f+tOYZF8Gdx1T15GN/FwgJrZ wSGTUa73xPuAxZ2F X-Received: by 10.28.52.15 with SMTP id b15mr1091003wma.123.1498059736035; Wed, 21 Jun 2017 08:42:16 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:41 +0100 Message-Id: <20170621154244.28309-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [RISU PATCH v6 07/10] 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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e --- v6 - use STDIN/OUT_FILENO instead of fileno(foo) - strcmp instead of strncmp --- risu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/risu.c b/risu.c index 93c274b..476475c 100644 --- a/risu.c +++ b/risu.c @@ -312,7 +312,11 @@ int main(int argc, char **argv) =20 if (ismaster) { if (trace) { - master_fd =3D open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + if (strcmp(trace_fn, "-")=3D=3D0) { + master_fd =3D STDOUT_FILENO; + } else { + master_fd =3D open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + } } else { fprintf(stderr, "master port %d\n", port); master_fd =3D master_connect(port); @@ -320,7 +324,11 @@ int main(int argc, char **argv) return master(); } else { if (trace) { - apprentice_fd =3D open(trace_fn, O_RDONLY); + if (strcmp(trace_fn, "-")=3D=3D0) { + apprentice_fd =3D STDIN_FILENO; + } else { + apprentice_fd =3D open(trace_fn, O_RDONLY); + } } else { fprintf(stderr, "apprentice host %s port %d\n", hostname, port= ); apprentice_fd =3D apprentice_connect(hostname, port); --=20 2.13.0