From patchwork Fri Jul 8 15:46:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588564 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp806842mab; Fri, 8 Jul 2022 09:20:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vn8ZpJNAPAJs/N6GCdTEan6eMTywgDDFINwr6BgSXfizkM7BM43dD15m7lEI+RXZ5rogof X-Received: by 2002:a05:622a:1441:b0:31d:2a48:250 with SMTP id v1-20020a05622a144100b0031d2a480250mr3779660qtx.98.1657297239146; Fri, 08 Jul 2022 09:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297239; cv=none; d=google.com; s=arc-20160816; b=KwyJVZW5On/KRRtgml2uleaJV98TkWH+Sb1vjNIY0hMffgEecuQm8OiErxJKY5wYfD YKHjJFyTjFsIsSDhTyBwdfF7dR41n3laWg2/Lvmx0rL1KUCs2hQ4cud8Z14I2eLMLXWw Zja6V4fuMFe1+u7KptNMJh1U+fcX7xVIO/wnvhDIozovYqXEdiNXUvuqG/mFy202mwjr NYyEj0PcahqiYIveVRpdGGZpzRJ2iUnBgKSz5sPGs3/RQeBjxL3g3bohp29zkSETV98n QLrcTgSxF0VTJFDynAm/tdaGxjFvJCZNCTXYqjm2YQKlNWBhmEtKCvTd0W1hgUqT7RBu Ep1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=X3HkBOy76gPUx/AerMnT/Pi7Lr8ImXW6FCDVZLVLx8A=; b=clO33w1aTNIXh4Ul1IORFEhQRHqOxEZ6XPvEx7IfV4Hzv06HsByOGe4gE5ggBtjRlU eWvaftU/aqm9rtx0dXHAzLS2tKC3sl3CyPEPnEtvv3jf9t6g4C8IR+P0CJVZEO/zjhJW 1/jCBc0yTk3UZT7OJw1klIbGXhxeUCwhj5z5y+QY6DPXLumz+GNXCHXq/rsGBH/OwyM4 gswFauLGCwrF4YNGjOXoLrWF0mHjo3Dy48AIwpnxgqcBAegEAOWdsL8pvWyhU2pyo3B5 vgoPyrVxvkjNL4wK73TwtwfZBr5qrNzhXjd5/GdqbSYl4dCj4Qklw0jPv4bsJgEK2azd KDsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SxdaRVYR; 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 v7-20020a05622a014700b0031bc8f772dcsi24370445qtw.702.2022.07.08.09.20.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:20:39 -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=SxdaRVYR; 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]:33976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qic-0003sY-P3 for patch@linaro.org; Fri, 08 Jul 2022 12:20:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCN-00049N-7a for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:19 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:33516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCL-0002P4-Hi for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:18 -0400 Received: by mail-pj1-x1036.google.com with SMTP id j1-20020a17090aeb0100b001ef777a7befso1886999pjz.0 for ; Fri, 08 Jul 2022 08:47: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=X3HkBOy76gPUx/AerMnT/Pi7Lr8ImXW6FCDVZLVLx8A=; b=SxdaRVYRJDPH3zg3QYyQIu17dr/IVBcHr5XUHILGbaLIQeYPWWgY+954kvq/VXxQiN Jw/KmgOemd78xk8dMQSinK5JUeBmDvrtLd3N3LOo1Vwhm0gqkdKRvaaFspYV1/5LilqS 9MTTRuLtyCmJdgPIwtNvjy8ca8Hwf0tydMm1zVPJq/EAJVPbf4FM5OTdb3HDhp1fA5Pp IQjZNzJVOm2u92lYvJe3YF+/hgYEqP9+NID9iI8ItveucyWvXTbBzHeBDP6Jr+kMNcqI Y/gJovEEwgzDZbsKoeRKzz73ZtfMcQ38u6QbVkw0g/Y0x3nxNFvsIRoRbD9LTpZ+qxRB iNfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X3HkBOy76gPUx/AerMnT/Pi7Lr8ImXW6FCDVZLVLx8A=; b=E+YS8uf/uVG9bovpZK08NODums+not2tIjm4kW5n/0GzV021399pgOscrW/XAUZZ/B EH8q5gUD4NE1pSDUY9yZA5b8v1kw6Nes/qoUVAHj7KdFyxk5DSAB5Aaan6wBHl6enCfz tdD/lyY2aDUEy/IUNA/uBq4WmNbxmIdGQLUdKRNb+UOmHwyn3aClPJOtCV/r8jLtDbfH 591/9Pvt+/m4Cr3HzUgQtYf3MqpWJfaogj6KGuRZj2rjI3cUVVocygR5MM5K7GqcAuN/ 7vgDTzb/UdOc8Ag+Y8Ufmk70YwknyPn4jK8usZKfPyOyjPtFAKTz4N1ZDYJMFN2+J0cx Heeg== X-Gm-Message-State: AJIora+uGF+uNrsag5DqmGD9UzT0eugZKAZvLYxMIdyND5wMfPd35uru XWqXAfIKVC0RopjGlk9rW4ocnd7mby6rFBtM X-Received: by 2002:a17:90a:3e09:b0:1ef:8399:398b with SMTP id j9-20020a17090a3e0900b001ef8399398bmr482263pjc.39.1657295236189; Fri, 08 Jul 2022 08:47:16 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [RISU PATCH v4 03/29] Hoist trace file and socket opening Date: Fri, 8 Jul 2022 21:16:34 +0530 Message-Id: <20220708154700.18682-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will want to share this code with --dump. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v3: Hoist socket connecting as well as trace file opening. --- risu.c | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/risu.c b/risu.c index 059348f..2f6a677 100644 --- a/risu.c +++ b/risu.c @@ -363,6 +363,29 @@ 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 + } + } else { + if (ismaster) { + fprintf(stderr, "master port %d\n", port); + comm_fd = master_connect(port); + } else { + fprintf(stderr, "apprentice host %s port %d\n", hostname, port); + comm_fd = apprentice_connect(hostname, port); + } + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n"); @@ -373,34 +396,8 @@ 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 { - 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 { - fprintf(stderr, "apprentice host %s port %d\n", hostname, port); - comm_fd = apprentice_connect(hostname, port); - } return apprentice(); } }