From patchwork Sun Mar 20 17:11:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553197 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp883855mag; Sun, 20 Mar 2022 10:32:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlaTNJ0VInJ/fj98GI8VxmgPjs8BzitM4L4McMhy6Qqoshaer8JIGpQmmyeene1CrpbqMU X-Received: by 2002:ac8:5907:0:b0:2e1:ef6f:9535 with SMTP id 7-20020ac85907000000b002e1ef6f9535mr12437861qty.49.1647797578799; Sun, 20 Mar 2022 10:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797578; cv=none; d=google.com; s=arc-20160816; b=yoD+L36yBOhrAJq2+30aXogPqB/mts/5NQwYc4o0mluOOPMkQ7QIzw+i+/sPLJIt8L l1qlxJ+gz7thni0G+4zSARHehxmtsVsp5LMbfAmOfz8EZFAOZm3PhtcmCCIi9qCqt63z OOchrPsDtUn2dRbg1bmFzytuKh8Vzb3CUHeIQGDu4HT3wyuNrudLTwcoXdE8kaWi7P4h YO0I7EsRhsMJ2UTpmoRWo3dGzU6V4R7m80jG1VMEfRqHCU3sbCD32/kXFjmaN+H1hfMz zWhtxLA3xiNMlD1IJQ6jT61nuuF/J3F0vEkyUhzeAMhssdSexcxQv0xkBWFA4yifyJBY w6aQ== 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=fetZSTEnCJcUQDWQ/liPaUY34R68y2pAl1CfXvkPMCQ=; b=mXrDbPvGE3IBRGzcayziBoHfq7E1kAmKYXhahlg70CJ4iyqWQncVj9TJEkGFZdghi5 L3z5RLAFF6V1AbSNuq1CbeXolqn2fu4qzsNI1GNovXimTz7Sm8HOfpvCWsGTeUzAlhDr aUKwcN9/cUGhMNhuDQzi/6B8rUx4WwD/v6A3rb7nhg7zRovBYIkHCWfZOeFCnIjZnaNV qV792+VV0IR/vrvY9stLI8byDp3MOuxuNTIDyQj6M8brOWDFXVYj6V+BClD8/CqpiD5a wmGZpkDTARIUORF5I9inndm4N2inTYew6GGi+tftkA1uwNVdz2FuaEKuOArGfrW1IrnW IyRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mmq+r8KG; 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 d4-20020a0caa04000000b00440e46a7becsi1265778qvb.138.2022.03.20.10.32.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:32:58 -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=mmq+r8KG; 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]:40186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzQI-0003qD-DF for patch@linaro.org; Sun, 20 Mar 2022 13:32:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz65-0000Ki-3q for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:05 -0400 Received: from [2607:f8b0:4864:20::631] (port=40458 helo=mail-pl1-x631.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz63-0003VG-Gt for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:04 -0400 Received: by mail-pl1-x631.google.com with SMTP id h5so10883713plf.7 for ; Sun, 20 Mar 2022 10:12: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=fetZSTEnCJcUQDWQ/liPaUY34R68y2pAl1CfXvkPMCQ=; b=mmq+r8KGF/9AV6RJGtJlDlPDXpN2T7lt6xZOBChHZSXFDVTcBX0tD2mZcotEMj1R4+ jCZdqCIWMuwRI1no6sqZQyINZnCfzs/FNsvxH6XD/E4Ci1Iusv5hK5mD6qTltT6aP9Ue z95QGIvQCyvzUYg6ntASdg1Lp3/2QYSwidpTkQ+6ybfptRxRuAJSyCvmgziloQbVtlfF g14B0hVzBXUElNsjThdO2eaz3NHK+iR39Mb9IAX9F/PLdF90hRTfePm46L6cjzdRGARu Ta+YuLBQJsIHsqZGU0PKkVkvEfUCdkncYknFJf8SJFnC+oUd2ZlbZXh/jgBXg0ASu6R1 7Euw== 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=fetZSTEnCJcUQDWQ/liPaUY34R68y2pAl1CfXvkPMCQ=; b=txJZ/59q+aCG7HoKkTR+zqge8pGg2SarJzak1E+ZJP8Wdkq/AAmpFJsXvTX5gT08Wl JtnUj92/rQ3mqEHdmQNQEIHnjMPlw6lTspfy9flw+TUvOz7aHIqUjq00+O/+q9yXF7Zj tMbftq2oe3EmjMdW7Gy5is7bbFQJ4gRmTeUOBdgEYThLEoGPIA92OZf2KF8Gq1sXwruL YFQwMK1b19WXYVGrcXutpvBY8lj6Zp85/F5fnddg1x8oqkjK2zLPOzyeA+aL0LfExO+Q ylV99pZNoWK+eB3paft8wldS4F1R8PJOXE/to46etkVGOvUoQz1f5zvXXUxbGvJk6ksl wC+g== X-Gm-Message-State: AOAM531lDVxGbNJ3KsTmh91Zq7aydZFet+9/14AyH0IlcijAIHf8Pahh vN8heVpLMNkK8FBagItb0m2nU6TlYRB67w== X-Received: by 2002:a17:902:c408:b0:154:4bee:c418 with SMTP id k8-20020a170902c40800b001544beec418mr3229702plk.75.1647796322264; Sun, 20 Mar 2022 10:12:02 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id q12-20020a17090aa00c00b001bc6f1baaaesm17149697pjp.39.2022.03.20.10.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 28/36] util/log: Remove qemu_log_close Date: Sun, 20 Mar 2022 10:11:27 -0700 Message-Id: <20220320171135.2704502-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220320171135.2704502-1-richard.henderson@linaro.org> References: <20220320171135.2704502-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::631 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The only real use is in cpu_abort, where we have just flushed the file via qemu_log_unlock, and are just about to force-crash the application via abort. We do not really need to close the FILE before the abort. The two uses in test-logging.c can be handled with qemu_set_log_filename_flags. Signed-off-by: Richard Henderson --- include/qemu/log.h | 3 --- cpu.c | 1 - tests/unit/test-logging.c | 4 ++-- util/log.c | 17 +---------------- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index ef247776cf..783faec309 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -92,7 +92,4 @@ int qemu_str_to_log_mask(const char *str); */ void qemu_print_log_usage(FILE *f); -/* Close the log file */ -void qemu_log_close(void); - #endif diff --git a/cpu.c b/cpu.c index 054f21b307..3eb324c1c9 100644 --- a/cpu.c +++ b/cpu.c @@ -406,7 +406,6 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) fprintf(logfile, "\n"); cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP); qemu_log_unlock(logfile); - qemu_log_close(); } va_end(ap2); va_end(ap); diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index 7016710a74..4e649e44c5 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -170,7 +170,7 @@ static void test_logfile_lock(gconstpointer data) * Initiate a close file and make sure our handle remains * valid since we still have the logfile lock. */ - qemu_log_close(); + qemu_set_log_filename_flags(NULL, 0, &error_abort); fprintf(logfile, "%s 2nd write to file\n", __func__); fflush(logfile); qemu_log_unlock(logfile); @@ -208,7 +208,7 @@ int main(int argc, char **argv) tmp_path, test_logfile_lock); rc = g_test_run(); - qemu_log_close(); + qemu_set_log_filename_flags(NULL, 0, &error_abort); drain_call_rcu(); rmdir_full(tmp_path); diff --git a/util/log.c b/util/log.c index 46a0d38d41..691d6d7930 100644 --- a/util/log.c +++ b/util/log.c @@ -207,7 +207,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, if (is_daemonized()) { dup2(fileno(fd), STDERR_FILENO); fclose(fd); - /* This will skip closing logfile in qemu_log_close() */ + /* This will skip closing logfile in qemu_logfile_free. */ fd = stderr; } } else { @@ -330,21 +330,6 @@ out: g_strfreev(ranges); } -/* Close the log file */ -void qemu_log_close(void) -{ - QemuLogFile *logfile; - - qemu_mutex_lock(&qemu_logfile_mutex); - logfile = qemu_logfile; - - if (logfile) { - qatomic_rcu_set(&qemu_logfile, NULL); - call_rcu(logfile, qemu_logfile_free, rcu); - } - qemu_mutex_unlock(&qemu_logfile_mutex); -} - const QEMULogItem qemu_log_items[] = { { CPU_LOG_TB_OUT_ASM, "out_asm", "show generated host assembly code for each compiled TB" },