From nobody Tue Feb 10 19:49:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1650222598; cv=none; d=zohomail.com; s=zohoarc; b=AmOoZPQjVdc0Gk6OYGDViNe249pIuuqZDN/knIOSpE08Monwy02sgL2JX9Ac0uBG1HLEP4KHWRfcxxetnrPpQ9u/1MVuF2zOGW/MVpTtbRdhBoei3SHPI5XNWgJaIhJleFSGf9G6Qxa4biUvZlpWMsAEo4N3X6Xlfuv6LMASXWw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650222598; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MFS05VM+1nmIS90ffHb9z5k4YW8IB7HF8idrdJvOqhE=; b=nzDo0L6X1eBpujxpS6iWKLhWBCLMggeh5U/YeVJmU41S7NeFmutj2dGEIGGUhJHkAebNaiU8r9n5EpiFgtte0/NkFYGEG+I/z4BNVvr/cDVo1DA732E/gZ8mA/a4JUVYpBlqmGkC43Iobh2F8h11X4m2HjFGHLSOzH/Ts+l+BM8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650222598694184.26963613000328; Sun, 17 Apr 2022 12:09:58 -0700 (PDT) Received: from localhost ([::1]:45898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngAHV-0004gk-Ky for importer@patchew.org; Sun, 17 Apr 2022 15:09:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ng9fY-0000U4-Sk for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:49 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:45835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ng9fW-0001oU-E8 for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:44 -0400 Received: by mail-pj1-x102d.google.com with SMTP id n33-20020a17090a5aa400b001d28f5ee3f9so785720pji.4 for ; Sun, 17 Apr 2022 11:30:41 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id on10-20020a17090b1d0a00b001d08a7d569csm8154011pjb.56.2022.04.17.11.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 11:30:40 -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=MFS05VM+1nmIS90ffHb9z5k4YW8IB7HF8idrdJvOqhE=; b=yJG2L9DL/hSy/pDCG7gUd9iaqRZjHV8pMMOiyIj4y8L9ilHJLGqKCidTFTqbl6YPmx HPYCbcwcuK3UwESKx4SqtSH5LV49+IKF8TFo+boRCl7kMvlP1AJq3L7xi3zSeN2XD4Eo vExwFNFF7RYOq1aVlv780G0yFaitiuyuz6EB9ZmRbnWvS2nd5oSSbzk8kP0dDHKbNqJN Dn68ZU/xNdvnEzl8+mAMCBrS6HjRR3DBzC2OSkrdvMhh+51MvvxPQz9x6LqFetwodq7I +lLyMDyWKMQmHrvcQtEGbhEn1ySLv9fv9+xiEWmBzIbHQsk35chWJc1/WCK6DpIs1XQW tNEQ== 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=MFS05VM+1nmIS90ffHb9z5k4YW8IB7HF8idrdJvOqhE=; b=NhRYnvpF4BYk1LiYkUFVQEgn1kRnUdYLPVs19b12lnCMgp6sJCYeTw6MPzPNhcu5n5 1H3nd1Gai3ncmovQ/cWZUG6LuIxN2e8wBmmCmK/xyxtKtmFxeaqGXVrKQGJTlWEH7cwb JlX/FF0N1TuOF84jWutDU7bHO2nq3qVZ8SpsUf4MIp37fKGdD6gIDPOS0/ahIth0QqDQ WiwkAXfm3WpUTpDaKlKBELtEdR5uaYjWdsMk7pExEVWUJsLN6qT+UTdNdixd1kSe9cr8 MUEw1H+pS1YsMcn/3lRCjoa4yM2FDdVWiDenF3d2/RLdQbnZZ0lCqCj81nBoJWE0FN27 cdsA== X-Gm-Message-State: AOAM533k82w7A9IE14KlGnglWJ+og4ThQ/G6eNQBRCxz5q9lx8/p/DcM HJY1RoNxUpG6wQKMol2d1ATEH6dKiUvfGQ== X-Google-Smtp-Source: ABdhPJwlAS1Yus0eFwwYWE3LbjnkVABl5/PC08Zii9JIbevzIklP5FMDNZPTk1XKCqJ4GdYxppy/IA== X-Received: by 2002:a17:903:2343:b0:158:d9e2:8049 with SMTP id c3-20020a170903234300b00158d9e28049mr7565243plh.3.1650220240365; Sun, 17 Apr 2022 11:30:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/39] tests/unit: Do not reference QemuLogFile directly Date: Sun, 17 Apr 2022 11:30:03 -0700 Message-Id: <20220417183019.755276-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220417183019.755276-1-richard.henderson@linaro.org> References: <20220417183019.755276-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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=ham 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1650222599642100001 Use qemu_log_lock/unlock instead of the raw rcu_read. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- tests/unit/test-logging.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index 54d7e8e33b..dcb8ac70df 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -110,12 +110,10 @@ static void test_parse_path(gconstpointer data) =20 static void test_logfile_write(gconstpointer data) { - QemuLogFile *logfile; - QemuLogFile *logfile2; + FILE *logfile0, *logfile1; gchar const *dir =3D data; - g_autofree gchar *file_path =3D NULL; + g_autofree gchar *file_path0 =3D NULL; g_autofree gchar *file_path1 =3D NULL; - FILE *orig_fd; =20 /* * Before starting test, set log flags, to ensure the file gets @@ -124,29 +122,28 @@ static void test_logfile_write(gconstpointer data) * this is needed. */ qemu_set_log(CPU_LOG_TB_OUT_ASM, &error_abort); - file_path =3D g_build_filename(dir, "qemu_test_log_write0.log", NULL); + file_path0 =3D g_build_filename(dir, "qemu_test_log_write0.log", NULL); file_path1 =3D g_build_filename(dir, "qemu_test_log_write1.log", NULL); =20 /* * Test that even if an open file handle is changed, * our handle remains valid due to RCU. */ - qemu_set_log_filename(file_path, &error_abort); - rcu_read_lock(); - logfile =3D qatomic_rcu_read(&qemu_logfile); - orig_fd =3D logfile->fd; - g_assert(logfile && logfile->fd); - fprintf(logfile->fd, "%s 1st write to file\n", __func__); - fflush(logfile->fd); + qemu_set_log_filename(file_path0, &error_abort); + logfile0 =3D qemu_log_trylock(); + g_assert(logfile0); + fprintf(logfile0, "%s 1st write to file\n", __func__); + fflush(logfile0); =20 /* Change the logfile and ensure that the handle is still valid. */ qemu_set_log_filename(file_path1, &error_abort); - logfile2 =3D qatomic_rcu_read(&qemu_logfile); - g_assert(logfile->fd =3D=3D orig_fd); - g_assert(logfile2->fd !=3D logfile->fd); - fprintf(logfile->fd, "%s 2nd write to file\n", __func__); - fflush(logfile->fd); - rcu_read_unlock(); + logfile1 =3D qemu_log_trylock(); + g_assert(logfile1); + g_assert(logfile0 !=3D logfile1); + fprintf(logfile0, "%s 2nd write to file\n", __func__); + fflush(logfile0); + qemu_log_unlock(logfile0); + qemu_log_unlock(logfile1); } =20 static void test_logfile_lock(gconstpointer data) --=20 2.25.1