From patchwork Tue May 19 02:53:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186907 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3447017ilb; Mon, 18 May 2020 19:55:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+VlBElWi6gS8pS5Zo5RYflhZI09NYnyKJQkmBvpchwDUPAl3Rmd+0nbB+pSkcGv6lAKEJ X-Received: by 2002:ac8:4d96:: with SMTP id a22mr14735747qtw.10.1589856951692; Mon, 18 May 2020 19:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589856951; cv=none; d=google.com; s=arc-20160816; b=zEzcASykJ4Cx1yjKHWS8C1kiOhmO6egcG2m5Wltg+siZx2Bw8Lp/t/LHa6GJ3RaZLq um5justr0xu48s2WtHYJblJNLD4dKvCIPi2nPbBYJSc8wwIFGiZkAT3UNR+gh0oVP6wq Gt+VyqlhrEsyPgV0Knq4GfYTa+1i4tQFqSC+RxxMnvQ7j9HcWlV/RrHiBx3k7WqEifnB uVgdp9qVAKs3igC2arxHKOtAltsIXlBwLYXOISBNgbWvym64J4lN0Pg0LCKGWSU7tTrG xmd5B8w+f45uojF+Cvr1T7E6qv2/iCLQtMlrb709ShfMIhZC1DPd6cg8fcEfM5Flg4d8 ogqw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=l8CNEpbNSwxuY2Dqho2U2FL6h85cata1jdT1yHJcAt8=; b=SnG9usxUm2o9pqFjKp+6hl8ew4oGKuwLyNN+L7kS1AZFAvexoEktPmNGOCQQ6rC294 HD6wb5FAyXnrQjNOCUBiu0mZ2pwaw2Ra5+lZ8eX6mw8S0wxeaS61SeMSiUHWd2IxT8vx UPZf31TdXGmAQK1EPUnuesvsoL/y1PAJRMxDR6cDBZ+TlYzZo/PVm8OrDMP9bQujYxSO PuzD96TMnfC+A1PdhLNUIBselEx0A8e5J8dSA5yH9sgkrhAuxjEypSJ2N3xwDkm8sV4U deMdmSY0sXn2LLr333c0KXPTQ7+AfF22lllNF2h0YE6iZDKelTvRlBxSnU7r1dsrWb5v q/lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QDzPjGjL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d5si6604441qkf.76.2020.05.18.19.55.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 19:55:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QDzPjGjL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasQ3-0000CE-8Z for patch@linaro.org; Mon, 18 May 2020 22:55:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasOK-00059U-CB for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:04 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:50920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasOJ-0002Om-Hg for qemu-devel@nongnu.org; Mon, 18 May 2020 22:54:04 -0400 Received: by mail-pj1-x1030.google.com with SMTP id nu7so706497pjb.0 for ; Mon, 18 May 2020 19:54:03 -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=l8CNEpbNSwxuY2Dqho2U2FL6h85cata1jdT1yHJcAt8=; b=QDzPjGjL4SM/hI5CHVYRhL25SSqtD7Z6l1jBJfKKHP5eMfGT0+Jf/9mX4vk5p8IL5R Re+sn4zVEOD4gtWMrIblWf+pUc+ddMXvSDlK8ktO7tCy3+fXmHpw9/X7WHTQKxJtPVgU +rIGkvC55aMVO3Ccy9QELodleKol4Yb1p6ztHScA/zZ9JCDUqxhsyxSklqPvIU2QTnbf s79nJ9CYr1BSXWb7covF+V0HGDo4e5AvMddeBaHW7ozm1lUG1zMujhszqx4BLBc/T+W7 s+F1qP/H78fLh5g9KvSSfI4hoVhfa2Ty2Zzas1/eDUCDuEd3MjmgPV71RpSlYHsyz7YE q1NQ== 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=l8CNEpbNSwxuY2Dqho2U2FL6h85cata1jdT1yHJcAt8=; b=qImDlZV72BHZT4cY8sc4o8fJ1XtpAKetak8BKOyTjkBa3FT1qWd1B0yJ+lTCj3DGcv PJ9tDJMqUFUp3nAyTEuw3ZkpgHj1oX+Ns9s2GirueDMcBLBPnHfgpyJ9auj3TI3oVnsB wT9pbKTT5ubTO1eaFA/S3UhfAdCQZmJJU/dAiXllCdayB4QkhiT1bYsX/i97h98sDziI DaxUHKffJQT01Rmh8Zyh1Sx6yQeZWi9HOVrFb8hksCi5nfc8f+JJzBvldRBM3EkGwXvs w34to5W+sJIutp6V0KW74anWk3RXIvoimtBTlkh+VqX35Xb2hFU0TM/hNMzuJDxf3PNF Is7g== X-Gm-Message-State: AOAM5308ANTc9yd66ClVQbLRvaGFXUr1bwwG8OU9W5biAk8IZ+3q/zzH RCPl2Qh2ld/k50xn35xSgPiAVFZBxXk= X-Received: by 2002:a17:90b:789:: with SMTP id l9mr2564325pjz.111.1589856841627; Mon, 18 May 2020 19:54:01 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id a2sm8772418pgh.57.2020.05.18.19.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 19:54:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU v2 03/17] Hoist trace file opening Date: Mon, 18 May 2020 19:53:41 -0700 Message-Id: <20200519025355.4420-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519025355.4420-1-richard.henderson@linaro.org> References: <20200519025355.4420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will want to share this code with --dump. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.c b/risu.c index 059348f..1c66885 100644 --- a/risu.c +++ b/risu.c @@ -363,6 +363,21 @@ int main(int argc, char **argv) } } + if (trace) { + if (strcmp(trace_fn, "-") == 0) { + comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; + } else { + if (ismaster) { + comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); + } else { + comm_fd = open(trace_fn, O_RDONLY); + } +#ifdef HAVE_ZLIB + gz_trace_file = gzdopen(comm_fd, ismaster ? "wb9" : "rb"); +#endif + } + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); @@ -373,31 +388,13 @@ int main(int argc, char **argv) load_image(imgfile); if (ismaster) { - if (trace) { - if (strcmp(trace_fn, "-") == 0) { - comm_fd = STDOUT_FILENO; - } else { - comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); -#ifdef HAVE_ZLIB - gz_trace_file = gzdopen(comm_fd, "wb9"); -#endif - } - } else { + if (!trace) { fprintf(stderr, "master port %d\n", port); comm_fd = master_connect(port); } return master(); } else { - if (trace) { - if (strcmp(trace_fn, "-") == 0) { - comm_fd = STDIN_FILENO; - } else { - comm_fd = open(trace_fn, O_RDONLY); -#ifdef HAVE_ZLIB - gz_trace_file = gzdopen(comm_fd, "rb"); -#endif - } - } else { + if (!trace) { fprintf(stderr, "apprentice host %s port %d\n", hostname, port); comm_fd = apprentice_connect(hostname, port); }