From patchwork Wed Jun 21 15:42:41 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: 106107 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1997143qgd; Wed, 21 Jun 2017 08:48:57 -0700 (PDT) X-Received: by 10.55.212.199 with SMTP id s68mr42499551qks.88.1498060137158; Wed, 21 Jun 2017 08:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498060137; cv=none; d=google.com; s=arc-20160816; b=PPfejPowlk6GbZD/YnjvbOCBB8xvWz+1QLXJxNIRLCh8Z1G5ZpNgWfYBZbCGgww6Im ayLRSq7cQRp3Ut77lbD6YIqDtIr1kwllOGfol19gDC4qbFelGFKgdzQjBMBVYWGfuyFv peGQTot5uaFji9qZMgU5S8IuqVu89OGGHAXyDCFkTM4Jv7jYGJEbGFghmQ3+EdEuFM+D JHhq1+GPVM/hVROYbwG/+I29CaMDTKlaTOTbgFn0iLVIarHVrzyZsutZD7gdzyiLba8P xtuMjokQvLkMSmOP+LrTEs/rFbj67U4XNxEdVvzOkTL5avqmUKd18l7IcpO7yoeM06bk 2jFA== 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=/v7qEn9OUH4Ho5RKpb1O3APGA9roAlKy9N6ZoVROiGI=; b=al82mFFRp/lYro27UcTCGEUhLv0CDSBFPoA7bCvyi8vIAQ0/nvOhiSLkSOEtrN5cNQ 5/QHW70VYz26fDLvAhDuhyUL7md/63+pPA5xGWEaRjrgNVUPu76iQVj0KXtMnV2BsHEO h5wiEsIY9ffYUNAUHc6QZQfwZ8/mm5ITwYuNo223uKINDL6WACHLcEhHwXOIyfrTuSou EaFHaIvUrPkQtSEY/eXpJRg75jAVaZF8o/IjiV8Lj3d9YHRSnfagNdqHn2zhmDzN3k/J i+YVfD2bYcuCJUxlbOgxtL5GJapqGyN58KuxtyppH48xpktcbqqVDeTUy5KiqSkEksL6 A0gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=ZRHvQTap; 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 r25si14956690qtb.66.2017.06.21.08.48.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:48:57 -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=ZRHvQTap; 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]:54768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhsE-0003pQ-Lo for patch@linaro.org; Wed, 21 Jun 2017 11:48:54 -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) 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) 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) From: =?utf-8?q?Alex_Benn=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 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_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 --- v6 - use STDIN/OUT_FILENO instead of fileno(foo) - strcmp instead of strncmp --- risu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.13.0 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) if (ismaster) { if (trace) { - master_fd = open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + if (strcmp(trace_fn, "-")==0) { + master_fd = STDOUT_FILENO; + } 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 (strcmp(trace_fn, "-")==0) { + apprentice_fd = STDIN_FILENO; + } 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);