From patchwork Wed May 13 18:09:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186684 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp684623ilb; Wed, 13 May 2020 11:12:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFJabZwcL80TgJLV86XeoVFPk2nDQ7LF69jR31k49669juNnla4pL6h48xElnEDUsIcFLf X-Received: by 2002:a37:c04:: with SMTP id 4mr892415qkm.137.1589393521108; Wed, 13 May 2020 11:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589393521; cv=none; d=google.com; s=arc-20160816; b=vBHFdwL77KsLFdEgi0SZU/lnv6mPMjS3NjQfvHS9EC4+x6uZhByRu7qnTA6sBCP6CQ OKxKcAENjRl5sSbr8CgfN+b2BlhrTzDywHwMxF3yLRrDlrKSV6Aq28fcnWXfCYYb9jr8 QTDrWpQZRr/LETf3MWtDPWG8VBMrAQDvoQgdhMHeQl5CwSqYPGyaA+rHXtxc4BSuOlxW dPu2NhR9wjDt7kKh7HZTdtiIj3Hjgoa0KLpRgZsQeHvLsl9AQ0fICCWedp0WG/N4DueO XkpNcsDYke/NLh+Efv0rInT74T5aBo7rGcWOFgJFFLcUU4gkTw5CSpGL7rlDHQnbCWpU p6FQ== 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=6WnKJJxVIg6V1eDs3yOOQwU7naceEXc9NpTs3O74BXg=; b=wsCYL2zT6UVhgaK3HUKcwDQ8V6nGZ3FyjWtx0uHbR4tg31dA98gOsSOGfvCWhUCTkq kEdwSGs/pryWKAd0+bpiZ/OJ48fWDIcXEkkROLQ5kruIK1jS84j8GzEXxFnm0YuwEWVz RaEGtn5fs8Bf/fmedfdeMPVjrhlZnbYh1lPPBGDn5mDm0tKAH7vxVftylGZO1kC5S1yK eZqILnwnAunlGrZf/BEwI8W3rI+LsVXJAKDK0BTaqvKBCZ76dcf+zfI0S6yQ8JEfnEzP 8ZXr8eVQTlXqeZHKwBG6H+Xg/lsMdZR8FhvdOVas+AIKDpjDDX69mqUuDDmhjM+uPtpM 6bpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfi2Mcyh; 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 c26si151330qve.168.2020.05.13.11.12.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 11:12:01 -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=nfi2Mcyh; 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]:60090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvrM-0005Sv-8l for patch@linaro.org; Wed, 13 May 2020 14:12:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvpT-0003mj-FA for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:03 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:41358) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvpR-0000L3-O5 for qemu-devel@nongnu.org; Wed, 13 May 2020 14:10:02 -0400 Received: by mail-pl1-x630.google.com with SMTP id u10so139814pls.8 for ; Wed, 13 May 2020 11:10:00 -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=6WnKJJxVIg6V1eDs3yOOQwU7naceEXc9NpTs3O74BXg=; b=nfi2McyhWp5KlLT7B06opOJr3FBtWlysLiXVLx64YHZNK5Zz5OuDvWRhL+PYRUJgrl Ye0EUEVdtFau36gY1+8+RpR5H/serJmfVatuu8ifL61DIl8mi1kzJP41Y9+X/WW0ulyL sqG5LV/EPGSKp+9zx7q5b5aUxVAMUdx+MK5drcN8MUMYvXSn0M6oVhFw8wGzZ7EzfxPS iWp3div9b23xgpNCy5y2ZIIprc4+2RomQw6NKNoLPzbsBylgXN9jv3lJx3JN9YXbaiIM teice8DetAKE2bClgZhTSzIpTtdEDEKY/yl42Bdx95EJ55or4yhr/QEyDeg6zR/bNum6 PutA== 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=6WnKJJxVIg6V1eDs3yOOQwU7naceEXc9NpTs3O74BXg=; b=lLzR9BDHroooZcw2fXKqT+OJnkOS6Dy4bh35g2RL394LuQgH0BjixT6nEByEdnjVIY xVEKPqKGqMN7WAmnO1yum1UrqfQhN5A21poeyGTOWHLvD7DPIzoAKT2Nn5teVuuswukj OZNVr5HC29Kno0Z60xg0grJl5gv9+RPeQItOEWWUP9uJ0+/fYjUFbjo1GuoSEkUGpJ61 Rit8pC6TmxhXz8bO266+ab2ijn7a/I0kIWTzOI+B5MIAguM7si1MqcSwR/eWQjYzRaYS uSOAN7elyyL9p5UIMw5VpWe1+ScVQFxEf9XabDZjS0/l9thkyP4TjJG/biUfQ9ujxmNY V36A== X-Gm-Message-State: AOAM530Wsst7NDB4phl9YLCJG3POiQJRPDBGqFxoa9E0qasvm8p2zYk+ 8oX0dfvzTBo/EIso3Bn9+lYQQOFfPqo= X-Received: by 2002:a17:90a:df03:: with SMTP id gp3mr5378232pjb.50.1589393399401; Wed, 13 May 2020 11:09:59 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id i185sm197361pfg.14.2020.05.13.11.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:09:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [RISU 3/9] Hoist trace file opening Date: Wed, 13 May 2020 11:09:47 -0700 Message-Id: <20200513180953.20376-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513180953.20376-1-richard.henderson@linaro.org> References: <20200513180953.20376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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" Signed-off-by: Richard Henderson --- risu.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell 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); }