From patchwork Sun Mar 20 17:11:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553178 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp874127mag; Sun, 20 Mar 2022 10:14:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3v+au0YL+r9syQ1FduOsd1T9drRaXlKW2w2SCotoJG/nbflDxPnioBh2BtW6XW9HLgpbf X-Received: by 2002:a0c:e6c5:0:b0:42c:d5f:7e4c with SMTP id l5-20020a0ce6c5000000b0042c0d5f7e4cmr13539256qvn.93.1647796442102; Sun, 20 Mar 2022 10:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796442; cv=none; d=google.com; s=arc-20160816; b=AXG1MLvp3r/rw9BJ1S3aao/rt57TpzYRRgLv9zv+fSwiaaD44fBTFo/et02fqL6ybb v9dhFpcjvz7SyqLD3yzgnqOPWol42jr0UwxdJHoQeR5T7FvxPtZgX2zNf1Pc2ZbnVZzh ZgKswYYnI1TuA9TgEcSm9zJUcgN0XKF4jUrzaKSfGKiURYImxCSnbJwF5RyloB2/SEiV B1ILD6ZyFRbhMj9DFW2fwM+TEYtiWPKIrNEvtI0jCWOIJrcG38HL2ZjFtRm76yPfpEXO LB4ci5jNMsmsGQWb8DwxvIJFZzk7CnqbOOO7BSB+0uZCt5QIQueuSYnjhEmQz99sbir/ YuLQ== 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=0QkXC8NBloa4lQ1dJr9n5F8IaX751sw3OjPlQ3q4G5M=; b=ggD21vnG67EWAttO8lrjb7MoWy6DRI3VzDEZUOwWUbph1vOX7fMz2cfP/bXrMj3H/I Fyc5YGQPJThdbCMlHPo5ShkFqYyvY1GkigxDZbM3Vk/R9LRklSk548mLNoiEgeIQ3T2f Y9Ym25rH6t4WBXa5nipS5hvlT54TTCuVt0TOIE8G35w1ta7DxO83n4zyG9fDSTyLStsv wvkMZV8aVLBFTpDmWhba8rtDzrt5CtlX9Et4x6V8IbQBydN7tO5hls43+3gvi+zSyj/G yBvVlsZCoECiD7/Z87pCOnm6o7bjE9jo3oWm/GqnOXbTI2dFsJwZ4WubNF494aSjhyBt WGRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IUNtxrAr; 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 d22-20020a0cb2d6000000b00440e46a7c85si1278664qvf.291.2022.03.20.10.14.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:14:02 -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=IUNtxrAr; 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]:53562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVz7x-0008Lj-Nw for patch@linaro.org; Sun, 20 Mar 2022 13:14:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5h-0008Jb-NB for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:41 -0400 Received: from [2607:f8b0:4864:20::1034] (port=56074 helo=mail-pj1-x1034.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5f-0003Pm-Fm for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:41 -0400 Received: by mail-pj1-x1034.google.com with SMTP id e3so11256262pjm.5 for ; Sun, 20 Mar 2022 10:11:39 -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=0QkXC8NBloa4lQ1dJr9n5F8IaX751sw3OjPlQ3q4G5M=; b=IUNtxrArwdd6X13tTr7XaTLoskrITi858kDgSZzVI20oFinaGMzllLB2rOu8mpn/zY bRY/7/NOH75+hAFWcDESbPg5Yw3yNH4+s7vF6scnuqPQvD6o35QOLVxZm2e7rFb0Jyu3 mLtHN05YkIeIMnPXhUW2epT9gpkJqOF0kkmBXDwriBfYkGunPU8kvbafstue+/mBwJN/ eE985p9ir0ha8241XV1TC7EMaFCQwIbAJW6eWNRiCS7XrGZC768ViEkbER/8IS7xDWfw TxVcjWDnicy5JzgmTJEnRmgkXnL3D+tMwtB2uJIrlPkPgjorQ5cr4nsey11X1zbeq0bu NVNA== 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=0QkXC8NBloa4lQ1dJr9n5F8IaX751sw3OjPlQ3q4G5M=; b=JjsFbG+WWVNGyqm7HHkTdEJ0HJF2pQ3IG66qPYZ0WKribnnlBbSsdmIx8Xp1s03Nr4 jL1QRxSSaeEOT/zPYvKVLKNMGvQC6KtBfjHOgBXSoQoevyJhLDi3cyUHayheIwdSNrfF 53fR/QMDyf8eO4/PoGGskPGjQriAVTWY8RYzBksea/U4l/ePzVhnhGgvyWnhTJi09uGK CE0qqsGG3vuuZDgealu0kY4+j9FIIqfbjvsmS9rOL9CzwKAwgvPX2V/+dpNQNUjCa8zp Tv+xyeluPk381OMtI2CGM4jwcLQ3mS08d7gdmuQhNsRgVdh1eWGqAQIrz5iChUZzI7On 1cSA== X-Gm-Message-State: AOAM53097cAzovaia8ORc00UBWOrEYdPAStAD94kCnPvfcLUPlUZxhYt NbYezKL738BZ72Q5ZCG4e3VKwFUb+SM6lw== X-Received: by 2002:a17:90b:1642:b0:1c6:c6d0:fbfa with SMTP id il2-20020a17090b164200b001c6c6d0fbfamr11556396pjb.218.1647796297552; Sun, 20 Mar 2022 10:11:37 -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.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 01/36] util/log: Drop manual log buffering Date: Sun, 20 Mar 2022 10:11:00 -0700 Message-Id: <20220320171135.2704502-2-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::1034 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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" This buffering was introduced during the Paleozoic: 9fa3e853531. There has never been an explanation as to why we may not allow glibc to allocate the file buffer itself. We certainly have many other uses of mmap and malloc during user-only startup, so presumably whatever the issue was, it has been fixed during the preceeding 18 years. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/qemu/log.h | 1 - bsd-user/main.c | 1 - linux-user/main.c | 1 - util/log.c | 21 ++++----------------- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 9b80660207..08b0cd0bb3 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -148,7 +148,6 @@ typedef struct QEMULogItem { extern const QEMULogItem qemu_log_items[]; void qemu_set_log(int log_flags); -void qemu_log_needs_buffers(void); void qemu_set_log_filename(const char *filename, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); bool qemu_log_in_addr_range(uint64_t addr); diff --git a/bsd-user/main.c b/bsd-user/main.c index 88d347d05e..08f43af235 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -405,7 +405,6 @@ int main(int argc, char **argv) } /* init debug */ - qemu_log_needs_buffers(); qemu_set_log_filename(log_file, &error_fatal); if (log_mask) { int mask; diff --git a/linux-user/main.c b/linux-user/main.c index fbc9bcfd5f..2b06350688 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -679,7 +679,6 @@ int main(int argc, char **argv, char **envp) log_mask = last_log_mask | (enable_strace ? LOG_STRACE : 0); if (log_mask) { - qemu_log_needs_buffers(); qemu_set_log(log_mask); } diff --git a/util/log.c b/util/log.c index 2ee1500bee..ffa66a267e 100644 --- a/util/log.c +++ b/util/log.c @@ -72,8 +72,6 @@ static void qemu_logfile_free(QemuLogFile *logfile) g_free(logfile); } -static bool log_uses_own_buffers; - /* enable or disable low levels log */ void qemu_set_log(int log_flags) { @@ -121,29 +119,18 @@ void qemu_set_log(int log_flags) assert(!is_daemonized()); logfile->fd = stderr; } - /* must avoid mmap() usage of glibc by setting a buffer "by hand" */ - if (log_uses_own_buffers) { - static char logfile_buf[4096]; - setvbuf(logfile->fd, logfile_buf, _IOLBF, sizeof(logfile_buf)); - } else { #if defined(_WIN32) - /* Win32 doesn't support line-buffering, so use unbuffered output. */ - setvbuf(logfile->fd, NULL, _IONBF, 0); + /* Win32 doesn't support line-buffering, so use unbuffered output. */ + setvbuf(logfile->fd, NULL, _IONBF, 0); #else - setvbuf(logfile->fd, NULL, _IOLBF, 0); + setvbuf(logfile->fd, NULL, _IOLBF, 0); #endif - log_append = 1; - } + log_append = 1; qatomic_rcu_set(&qemu_logfile, logfile); } } -void qemu_log_needs_buffers(void) -{ - log_uses_own_buffers = true; -} - /* * Allow the user to include %d in their logfile which will be * substituted with the current PID. This is useful for debugging many From patchwork Sun Mar 20 17:11:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553177 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp874126mag; Sun, 20 Mar 2022 10:14:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDA4mvEu6LUUWRuXFnLR7JbRNxmQh7nPZ5K7l0ik9Jm+JpUx+0x/doshaDeku+mZ3H2fox X-Received: by 2002:a37:9e16:0:b0:67c:e9ad:8e1d with SMTP id h22-20020a379e16000000b0067ce9ad8e1dmr10580358qke.505.1647796442018; Sun, 20 Mar 2022 10:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796442; cv=none; d=google.com; s=arc-20160816; b=HGGey1kUh9X6MfFGTxb0kHqu2NG83Byi9i4oyRgKBcYmA3Q8ftA5aIK4iKK7fMrIr4 pO0nub9u8Kc5Zlw77RLC7FqBksTyHrMO58gvFq8aH43kGdSbhECqdNIRhB+gWdE8tNXg Ejzr1PgTsRg+6FT/lHfqfzaQBttVT2pqAdi8SB6uTSMBLxUVjFy1MyMnBcAdsXSRVrjb YIgLPSmV00SZojUBME2xDs6K7elZ8qZ11Dw7J07Xgf1ngAF2VehJhVTvzlSnTkQMc7K6 +JqkALDaN7TpivAlxHH2HDQPNpsyF2iiWX1GUHmhnHJeRcdMpbsYUIEyFw7uwJ+1WfNr jA2w== 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=M/ctxNkdA4F57t1BuSuDblrpi1g8LEQZufq5SItlXL0=; b=QGslL5J2PkAMmwK4b9+fcCv9j7VtquCBBbSGLesUuEqKpp6oLPmSCphuWe/QXVR5Qn bzmouibufsOh8Z3ji0hP0/iLz5xfpWlbd7jZF/TEmz6UD4ag+t6ok2qRBhIniXfggvhF mFPxGdKSyaCYvbYZlj0d+FyzFxA8/ieB++zQjnNCJpdmZhd/3ItaeXRV+FISjEiU7xFi uXnQsf4oUyEH7NGQityckld1gik52CANhVZRod/o3ZDDuSm5OODnT4snX46Mc3HZlBc/ FR/+PBZ843Rfcx4BNEJOkwfdGDlrbCRBpFye4xBEUBFs3hJig8k/DP0Ym5WkrTASDLve sZ7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FTL3isca; 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=fail (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 q7-20020a05622a04c700b002e1fbf3bf6dsi1493079qtx.350.2022.03.20.10.14.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:14:02 -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=fail header.i=@linaro.org header.s=google header.b=FTL3isca; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVz7x-0008Nc-K3 for patch@linaro.org; Sun, 20 Mar 2022 13:14:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5h-0008Jc-QD for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:41 -0400 Received: from [2607:f8b0:4864:20::534] (port=43649 helo=mail-pg1-x534.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5g-0003Ps-D5 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:41 -0400 Received: by mail-pg1-x534.google.com with SMTP id c2so8730734pga.10 for ; Sun, 20 Mar 2022 10:11:39 -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=M/ctxNkdA4F57t1BuSuDblrpi1g8LEQZufq5SItlXL0=; b=FTL3iscay29zfTO59XP5jdSUPfXHxDQfZdKkj6nIakoCG6zEs5DElh8MOkziyJq+z+ u3/XHQHMEbSpO/TZALlN7aNtXR/wev8yeUJh2MIKMlZCkgmMddDPWKIbSQ96vGD5ciSN jcFvzzbP8I5/goeybHnwWnvhvw5zqKF+vDRomZD7ptJy//NGXAk50VtvoiNesuCv06eb Xa8A2eUjyjcbmySFZOD89TGzcGMEfKNi0d7ApYeXPrYu4Vd4Bt6PETp0b0C5kRJcHqWU r/MFxBpBqZqDKno8nLWgWCRhLhlRs3FOt9bW14omwJunqYMwwNqhc3JBnyAuAo2ZxAoY OQvw== 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=M/ctxNkdA4F57t1BuSuDblrpi1g8LEQZufq5SItlXL0=; b=TsEenF28HVEsiXGB2gnJHWjqAyaSPSck0A4dXwWL4eMS6xu4juC3HcVTAHfAHma2dh NZtZGYQPFL1COlFcGTiPKdoWSsXtlob9LHeRwBeFjyGGN/gwS/mu5UrAtintTQuQC3Np vmveODr7bQsI7O0qNVS3cxK+oMWvGcFKbSx/t35tM63UV8LAbLkKkQDi22uAWCZIRIxZ LoC3HLQCvKhe9ccjxUWfMBKRvSrMT0oGv90KUYEaDzm1bM0hS3FCe4cRu3/aAS/ekNt8 QuRalT0jyvwgjeaL9hykxYE7moPCwQ6M81MRaEY8qT3xEvql0VXI2dHfBb+Z19H7KNBT Cgdw== X-Gm-Message-State: AOAM530XSphRyv3tEv0XvXwgTK+esC2SGlo046vf4p27fOpAeCduhBeN hfS9o87VK4pKka8jqGDywWXc9eZh91CBbA== X-Received: by 2002:a05:6a00:1799:b0:4f7:37cd:d03e with SMTP id s25-20020a056a00179900b004f737cdd03emr19951563pfg.10.1647796298588; Sun, 20 Mar 2022 10:11:38 -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.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 02/36] target/hexagon: Remove qemu_set_log in hexagon_translate_init Date: Sun, 20 Mar 2022 10:11:01 -0700 Message-Id: <20220320171135.2704502-3-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::534 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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: Taylor Simpson , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This code appears to be trying to make sure there is a logfile. But that's already true -- the logfile will either be set by -D, or will be stderr. In either case, not appropriate here. Cc: Taylor Simpson Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- target/hexagon/translate.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index b6f541ecb2..98f1452cad 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -874,12 +874,6 @@ void hexagon_translate_init(void) opcode_init(); - if (HEX_DEBUG) { - if (!qemu_logfile) { - qemu_set_log(qemu_loglevel); - } - } - for (i = 0; i < TOTAL_PER_THREAD_REGS; i++) { hex_gpr[i] = tcg_global_mem_new(cpu_env, offsetof(CPUHexagonState, gpr[i]), From patchwork Sun Mar 20 17:11:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553181 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp876472mag; Sun, 20 Mar 2022 10:18:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNEmef8OqEJGqSiGgK4oq1LNUBELXzW1/mTwJqo7PzKjqe/cc0hIekFZyhqxf/4wNF5X/z X-Received: by 2002:ac8:5e4d:0:b0:2e1:b9df:f0cd with SMTP id i13-20020ac85e4d000000b002e1b9dff0cdmr13865786qtx.421.1647796703942; Sun, 20 Mar 2022 10:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796703; cv=none; d=google.com; s=arc-20160816; b=uQTcA7CW9fKyIKuEhdqxjreo/1d89GGPcCuDC1jYMjGmEIBzxZKiAct1b8QnOatv+i 2PY8uzuPI7fP83p0kJ6UYq1PVwRV5e9jPpGvqxrQOA1KbfxPkrV9+A/EDISdoCDLVozt JplFTr8a/3SMmFtAsD4VtjSm6yYXfcpGZpVq+arrwrg0Rcy7MPMZxjmVq9WhDPn+Ff1D BjZGLNx+PhTMIr3IcR0vdAORpH2xR46hMu+lsqo4ORQKJHkhPWj/UgeLtGKfn81NmaxJ Snz87C7CCiD6DcmwQFNb9Lz69Z9PDvtZUl7VnSZ27I3ezzwdeDbPl0YO+SycPsDtMDix kCWw== 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=b2ya2A1S2MCUsCKLp1XEUHbTLCi7pkZD7YHsJk5p0As=; b=ye+l1uYUj78O8iSvWDyY+QakW2qxldrdpRrm17La/nkJea9Y9AxReao+nRv6qfq3PG b48jvcrbQF9KxTDQ5QQnrCW18Qm9I0f7t+roeQi/LdwKTJbaBijnXqP1eLZGWn/lbXL9 cgDj/AJcZOOSFlqjBWij1sLg0rqbnnlJmQxIcZbcy+sjEpHzFw/w5c2dgsacyxrWGdk9 OT3IeoAsPPzEv8a2IZ8euPabX7QHQnKpbbaNPAP5aneMWUWkmIee8UWq4zsnKTQ5FYsd Yf1UNcsrJIESPO7SQN6vc+u6Wa8kGZD4YqCC9pThQCvZo97EkmLfL6GaNE8SNSDKEmXW opEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iUwwjRQM; 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 x8-20020a0ce788000000b00440e46a7d90si1299479qvn.558.2022.03.20.10.18.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:18:23 -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=iUwwjRQM; 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]:34064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzCB-0005zP-Gw for patch@linaro.org; Sun, 20 Mar 2022 13:18:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5j-0008Ju-0y for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:45 -0400 Received: from [2607:f8b0:4864:20::1030] (port=45828 helo=mail-pj1-x1030.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5h-0003Q6-9U for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:42 -0400 Received: by mail-pj1-x1030.google.com with SMTP id m11-20020a17090a7f8b00b001beef6143a8so12524633pjl.4 for ; Sun, 20 Mar 2022 10:11: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=b2ya2A1S2MCUsCKLp1XEUHbTLCi7pkZD7YHsJk5p0As=; b=iUwwjRQMsUrAZcnFxnhCZ+NMvTBPzOZQl/4LKpTwXCriBx3VVeBB/NBnpW+KS9BBpE CsbOgtX7zzjGFwYw0G8PnQLUO6fPOlZFGFRg1OHrLxcf9Y620M8tba5Udm3WS3bQwHoe lAJpfa8/Y/03sGoqBvjKPbHPGtYcdZMUpgt+m8i2QF6HQ+Lspp6uFTWcxw1Veo/t52d+ IBBrpMZoTZm2obIKQkcpmIs/P/9e8BTfhecR9oy2lX7aZM2HpiPjRm77pYHexQ9PnMCn /ZG0sPf3l5ThlP8rPXi6/Expp5apAt3UMRt7KphL4hLGvuW85df0Zn+Lc3ggkUQwpvUR wcXw== 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=b2ya2A1S2MCUsCKLp1XEUHbTLCi7pkZD7YHsJk5p0As=; b=MkOXPmISuEFhTANOotMsB0eHYWRQTqnI2ejeJFaVQlA1Lz6+ZniOHBGhZFtwmXZqNG fdTSWQ5i/1e4y4EgX7110cJXP/0OCnAlbXqfJLiNbBGGoWxrYV0OBRWhwmESL8je16/H 2HrhYkaHEH84C5asgyS8Eo5lTmOP1w3BX/m4OVmoJjmSVs3JQ/TgLb1L90zh7SeDGV8s elUHl9jp2qJTqLslmYjeiVw2qoXAG7M59R3uNHm4DXWogTcfkVlB0qv4BdxhOVS6qU/M bVlo6laJKOkEN7V+KfBOwfctwK9mTpNTzmNVvMa1OTYKXb/tULNy5m0wyqPUGYZb9Hkf axXw== X-Gm-Message-State: AOAM532DIXAjPz32giZxwjBAooZlq7rpihQ7rpJLjYW1pvdhhCbJ7YYv lh7jRTflvrbVXjN1nlL+TkYx28oJN98jYg== X-Received: by 2002:a17:90b:4b4b:b0:1be:fd9a:c279 with SMTP id mi11-20020a17090b4b4b00b001befd9ac279mr32567083pjb.83.1647796299913; Sun, 20 Mar 2022 10:11:39 -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.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 03/36] util/log: Pass Error pointer to qemu_set_log Date: Sun, 20 Mar 2022 10:11:02 -0700 Message-Id: <20220320171135.2704502-4-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::1030 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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" Do not force exit within qemu_set_log. Pass an Error value back up the stack as per usual. Signed-off-by: Richard Henderson --- include/qemu/log.h | 2 +- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- monitor/misc.c | 7 ++++++- qemu-img.c | 2 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- scsi/qemu-pr-helper.c | 2 +- softmmu/vl.c | 4 ++-- storage-daemon/qemu-storage-daemon.c | 2 +- tests/unit/test-logging.c | 2 +- util/log.c | 10 +++++----- 12 files changed, 22 insertions(+), 17 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 08b0cd0bb3..64f28785ae 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -147,7 +147,7 @@ typedef struct QEMULogItem { extern const QEMULogItem qemu_log_items[]; -void qemu_set_log(int log_flags); +void qemu_set_log(int log_flags, Error **errp); void qemu_set_log_filename(const char *filename, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); bool qemu_log_in_addr_range(uint64_t addr); diff --git a/bsd-user/main.c b/bsd-user/main.c index 08f43af235..0c8aa1ae90 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -414,7 +414,7 @@ int main(int argc, char **argv) qemu_print_log_usage(stdout); exit(1); } - qemu_set_log(mask); + qemu_set_log(mask, &error_fatal); } if (optind >= argc) { diff --git a/linux-user/main.c b/linux-user/main.c index 2b06350688..6aed4929ab 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -679,7 +679,7 @@ int main(int argc, char **argv, char **envp) log_mask = last_log_mask | (enable_strace ? LOG_STRACE : 0); if (log_mask) { - qemu_set_log(log_mask); + qemu_set_log(log_mask, &error_fatal); } if (!trace_init_backends()) { diff --git a/monitor/misc.c b/monitor/misc.c index b1839cb8ee..8e8b8e18c7 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -429,6 +429,7 @@ static void hmp_log(Monitor *mon, const QDict *qdict) { int mask; const char *items = qdict_get_str(qdict, "items"); + Error *err = NULL; if (!strcmp(items, "none")) { mask = 0; @@ -439,7 +440,11 @@ static void hmp_log(Monitor *mon, const QDict *qdict) return; } } - qemu_set_log(mask); + + qemu_set_log(mask, &err); + if (err) { + error_report_err(err); + } } static void hmp_singlestep(Monitor *mon, const QDict *qdict) diff --git a/qemu-img.c b/qemu-img.c index 5dffb3e616..498f6d3646 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5442,7 +5442,7 @@ int main(int argc, char **argv) exit(1); } trace_init_file(); - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); /* find the command */ for (cmd = img_cmds; cmd->name != NULL; cmd++) { diff --git a/qemu-io.c b/qemu-io.c index 3924639b92..49957a980e 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -634,7 +634,7 @@ int main(int argc, char **argv) exit(1); } trace_init_file(); - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); /* initialize commands */ qemuio_add_command(&quit_cmd); diff --git a/qemu-nbd.c b/qemu-nbd.c index 713e7557a9..bf9c5fedce 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -804,7 +804,7 @@ int main(int argc, char **argv) exit(1); } trace_init_file(); - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); socket_activation = check_socket_activation(); if (socket_activation == 0) { diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index f281daeced..1f2a84c534 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -1001,7 +1001,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } trace_init_file(); - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); #ifdef CONFIG_MPATH dm_init(); diff --git a/softmmu/vl.c b/softmmu/vl.c index 0b81f61535..73296015af 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2569,9 +2569,9 @@ static void qemu_process_early_options(void) qemu_print_log_usage(stdout); exit(1); } - qemu_set_log(mask); + qemu_set_log(mask, &error_fatal); } else { - qemu_set_log(0); + qemu_set_log(0, &error_fatal); } qemu_add_default_firmwarepath(); diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c index dd18b2cde8..cdaf69f764 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -392,7 +392,7 @@ int main(int argc, char *argv[]) if (!trace_init_backends()) { return EXIT_FAILURE; } - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); qemu_init_main_loop(&error_fatal); process_options(argc, argv, false); diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index ccb819f193..93c6d666e8 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -123,7 +123,7 @@ static void test_logfile_write(gconstpointer data) * In cases where a logging backend other than log is used, * this is needed. */ - qemu_set_log(CPU_LOG_TB_OUT_ASM); + qemu_set_log(CPU_LOG_TB_OUT_ASM, &error_abort); file_path = g_build_filename(dir, "qemu_test_log_write0.log", NULL); file_path1 = g_build_filename(dir, "qemu_test_log_write1.log", NULL); diff --git a/util/log.c b/util/log.c index ffa66a267e..00773ab717 100644 --- a/util/log.c +++ b/util/log.c @@ -73,7 +73,7 @@ static void qemu_logfile_free(QemuLogFile *logfile) } /* enable or disable low levels log */ -void qemu_set_log(int log_flags) +void qemu_set_log(int log_flags, Error **errp) { bool need_to_open_file = false; QemuLogFile *logfile; @@ -103,9 +103,9 @@ void qemu_set_log(int log_flags) if (logfilename) { logfile->fd = fopen(logfilename, log_append ? "a" : "w"); if (!logfile->fd) { - g_free(logfile); - perror(logfilename); - _exit(1); + error_setg_errno(errp, errno, "Error opening logfile %s", + logfilename); + return; } /* In case we are a daemon redirect stderr to logfile */ if (is_daemonized()) { @@ -159,7 +159,7 @@ void qemu_set_log_filename(const char *filename, Error **errp) } qemu_log_close(); - qemu_set_log(qemu_loglevel); + qemu_set_log(qemu_loglevel, errp); } /* Returns true if addr is in our debug filter or no filter defined From patchwork Sun Mar 20 17:11:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553180 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp876432mag; Sun, 20 Mar 2022 10:18:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9D4AHAN0YN3oxk1vrMzVxN3cdb8P6fMa/yKm1zEWJSd3XYTcOe20Y31qXAccHITXVEpIk X-Received: by 2002:a37:acc:0:b0:67d:320e:7eb with SMTP id 195-20020a370acc000000b0067d320e07ebmr10622420qkk.513.1647796700523; Sun, 20 Mar 2022 10:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796700; cv=none; d=google.com; s=arc-20160816; b=dKqHhmo4pTFUdz2QM5VyP6Y90qt9HUGBtekXTBU3SAEUaoA1RodyR1iKhHGzRkfPHS YU/9JBfkQ/Ms9XR7x8iO8cyC2IIFErCNjxiavUeuNWwInTEx+XzDqECik+xZP6QIFp4m hqSahZPVASMISUrE5lLplUCBKse2yQegotYXcY6mx7eHkkw2eK1NUOu2og3DjaHdEy2w cbNR+W9u8jKU2ModCDTDwia5r3ugcaj+jTPpzTNKr+93XTJ3Sb0TNf4WK3Q04QlgDgMB pefTUp+R5cHJnesD1DF+YeJe6vBqELfKVghKky+77E8LRCebBg89DCGWNjYbkZSYHtxu YE+Q== 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=3tVjuQw+/CoLqgI+CPACWtQapf8H6hrbx2q6SrEHdT0=; b=OqoDMZ885Ihc0mC35hlzzxd2QKhzQccYVvQ/3EVbOKZpC+bQqtwAA4nHVnexNvRO6H vZTJO6Cnb+nSXde8LprsDkO+/Icw+VdO3f53j2FiGTJ68nN61H066ehurzoprpSMET/v GWhwcEnQ0ZYihb+Q1h8oKTDe9ZkiEsq7GAwiqcHgAP0eAuQKJh75xY4UAQmaVMDNgBy+ hAmZOgjOxfYymBrb89aFEaRovoXx6bJ/VPaBI1JKfgUiapi68w/IRX/Bh7KeZqX4jGVI JRxFR+x88LfjmPkzDw/UuJfdL88fxOT9q2kaU2/cX64J8Kpc58859/sEMmsuK6ntl9rm PQDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v2I1qxEx; 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 16-20020ac85650000000b002e204f39698si1286218qtt.572.2022.03.20.10.18.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:18:20 -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=v2I1qxEx; 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]:33812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzC8-0005p5-2L for patch@linaro.org; Sun, 20 Mar 2022 13:18:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5j-0008Jw-VI for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:45 -0400 Received: from [2607:f8b0:4864:20::42f] (port=33474 helo=mail-pf1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5i-0003QJ-3K for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:43 -0400 Received: by mail-pf1-x42f.google.com with SMTP id s42so13739822pfg.0 for ; Sun, 20 Mar 2022 10:11:41 -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=3tVjuQw+/CoLqgI+CPACWtQapf8H6hrbx2q6SrEHdT0=; b=v2I1qxEx1BDTBGsmT1JLooy8xjBo8HT1b9xXdVwScsORoy0NiawfCSJRgX1kliul+V MFS2gL9pkuvuKBHt8jZqV3PY6toKQU567K2FmgnrJ3Yu4f6ZwcS8N0fseVp9g0bOTvGR 0dUNbELk93KpmzydSiJDVo5i7O8vHeN3VqdfvrN/OrUqYbQ3B9V8KbadkCpxVl0Jz6ns rsciYjcmBfQoTLXyHlNFGU9nLw4v3/EhPVw23wK9SU3LI9aoke91uF4COcDDFQMRBazJ 8bQIcnWSjtqYkAJI4lwXFH06nRP6GvrV8i2PdJ7WIfj3vPlSVC/2nMqSx2e0ExzoiB5J gdSQ== 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=3tVjuQw+/CoLqgI+CPACWtQapf8H6hrbx2q6SrEHdT0=; b=4Kp+jhznXqICPDRLH6NNFP33Vnvse9LUf04Jy2fMGyabt+YBAF+46zwB86G6USV0dC bKat/3v2MGJVuyA0brVMVvhpsHevlMFydi3hYZX2qCkFiRXZxKdywHSaV5/mLHGbQGTP 8R1F+DVcope6ua7MFaFZhS0Sk/1ruTG4WslJvAdwLBrK56d5Fm6bUA0kI0fCHTmApiq6 5PXOrsREKzAEK214tQ6pqFAaBHRqKRDbxLRrGp31l0+aPZH9Cw6ykhtQjHPRnBpCFL7a CNmiYLXNyqi4ZzIZIxK6Zw8q4LYdZI0TF/QNFVsZ6+xQUgHpN7npddGNEGSFAmdTUDxj U3/w== X-Gm-Message-State: AOAM532hT6If40DWe7VAV5P5w/bBHpS+xlpdzqX82ZzRM+Am44qaCl8g TA6TGyhY5l8GwcdUBMZf1nmSCUtJDtY9uw== X-Received: by 2002:a05:6a00:1944:b0:4fa:952b:48cd with SMTP id s4-20020a056a00194400b004fa952b48cdmr3031902pfk.10.1647796300839; Sun, 20 Mar 2022 10:11:40 -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.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 04/36] os-posix: Use qemu_log_enabled Date: Sun, 20 Mar 2022 10:11:03 -0700 Message-Id: <20220320171135.2704502-5-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::42f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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" Do not reference qemu_logfile directly; use the predicate provided by qemu/log.h. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- os-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os-posix.c b/os-posix.c index 24692c8593..20d31fc518 100644 --- a/os-posix.c +++ b/os-posix.c @@ -292,7 +292,7 @@ void os_setup_post(void) dup2(fd, 0); dup2(fd, 1); /* In case -D is given do not redirect stderr to /dev/null */ - if (!qemu_logfile) { + if (!qemu_log_enabled()) { dup2(fd, 2); } From patchwork Sun Mar 20 17:11:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553182 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp876478mag; Sun, 20 Mar 2022 10:18:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfaKLrWiGCtB1vDSXc+GZ0jYJ9B/2E+rgnOcY4eM6O5bwyIZSFnfijptA8u892qDAo64m6 X-Received: by 2002:ac8:7c46:0:b0:2e1:d6c2:2b15 with SMTP id o6-20020ac87c46000000b002e1d6c22b15mr13843073qtv.405.1647796705542; Sun, 20 Mar 2022 10:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796705; cv=none; d=google.com; s=arc-20160816; b=ym8v1SAx/lqvOAnC+mRn0ObEZzVohCP2ZUy9tdWyZxceLfcPstbJdvnvyA33RnxyXU dMCTdELZmRuxiIaUBdOLcdFtHIHSXq7Y10JnGOzKuU1NdR3ddVINSRITw22gV8znmBBz 08nemwyI17j8WsIlCwPkHgtqYfxdb7vQy0LyIo3LNDzHtBUL0rdVWSsG4jRfhVVnZKkQ 95wx3NXVioKaVxIyvq/lcT+jHS5gC376pMwnoZNYhlosASnIX03j4/UgQ1YE22gAXrIB cTTPTaT567j96JvFbnfxuLAJnqkLMlYkUj1Ppu1LfMSRe217qZUwHjwYRBndHP4KVt0e 8E4w== 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=4kTl/W0nqOk5wuB3SJo0d0RYWr70TQFHqQ4WUsLcxUk=; b=rNq6S7kfjH7PCti/AZBaYOV0QLC3eEz8OpWiQ19bHMiYwAitgSBMD+gSUu2gi+UMkM +/XGWfSWywQUrwLPr5Uh4qnT7QRucNFN8bt1foSIWmRa7oaePcr9mQsuJ4xnT7hxCSwj 1Xet0yHlcxjG5U5zKslxt+FWsHunRiiMARrgrRpXyL+NtEOPCPmw1EL9Ynjk/9IaGz5k 7DFLoVy7s7Rr56oaJXyS9Q9l/R5aWb8fFmdp922H/OibzCwZysUNOc4rnnc8USiRbpvJ pYLUmRXW0cDNugoMQLqbz5SViTNr9BU1PfNdx3ED5wsBTWb4hJBNyVZHpz4It3II76sN WLfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M3P3Yk0M; 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 h7-20020a05620a244700b0067e4be2381esi1514199qkn.99.2022.03.20.10.18.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:18:25 -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=M3P3Yk0M; 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]:34192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzCD-00064A-4d for patch@linaro.org; Sun, 20 Mar 2022 13:18:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5l-0008KQ-Sj for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:45 -0400 Received: from [2607:f8b0:4864:20::633] (port=46965 helo=mail-pl1-x633.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5i-0003QZ-Tk for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:44 -0400 Received: by mail-pl1-x633.google.com with SMTP id w4so10855992ply.13 for ; Sun, 20 Mar 2022 10:11:42 -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=4kTl/W0nqOk5wuB3SJo0d0RYWr70TQFHqQ4WUsLcxUk=; b=M3P3Yk0MiS+YZPPtSqOjllT5zVJ1uK+JS/97MRHfoad8QVLnOlZS+TiqNPBVsZU270 kGjYNAJSbNVGFiHnefpkbrJTeud6AB14jZrOofJ2XvCQX+0D+g9kdL3xrwWMiSBV9YH1 j6I2YqypQff3+qxR/KqvIKNaE4yrq6tezk0etgGmgCX3wL5n5H3HcZLbqXLGzcPAX3I0 gZ+pi1Br5VOCpUxxgu8KscoxRZNzlbF23XtQOCDyd709dByOnR6jWqA3hnf46kkdMtXg ms1IBTk8UI0CV6cj835JIVPw4uIA/+Cczb2KIU1e7l6JMYd9gdbLqqkbR7jrtxpurmI1 y0Mg== 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=4kTl/W0nqOk5wuB3SJo0d0RYWr70TQFHqQ4WUsLcxUk=; b=MkIJn2t/FqXhDQEJv32ThzGEWPo9TdvugAD3+UoX8RaeEwv07Zz5JNFVkDupszZiTa t9+3RXfX2Zh/sqH8augFFn0YpjUUrcLsNb/1UGPLfuDGRZ55aOgQtrgTtp4E2mkBDwb2 RCq7OkrxgNaMpQ3Q/d+7MI4iCXyv0asNx2cyILJPIi617SGr8sInv6flelF+5gDQ+5Z8 kDlp3cg7mAz20wX2249t1+Fnq8SdLlUKGER1kDQ7Mk1TrSpuLIJH9dSw+LEi2vzSuC5i JsAj1OdGQAp+/mde+Q4pW3w5Uh5nzwaQ0oKK22sn+xnCxrUQvU4PZ8CJjTDLeO6LuXVi cX4Q== X-Gm-Message-State: AOAM530GI9fwbnCGERsNQ1Kb/pRyaCgBK1nV3sYeY9pmNh5c/M8jyNd6 r7LnUNtuI4QLrzqFLibrnKwl/k7mqLUCXw== X-Received: by 2002:a17:903:228f:b0:154:5350:be02 with SMTP id b15-20020a170903228f00b001545350be02mr2168616plh.53.1647796301670; Sun, 20 Mar 2022 10:11: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 q12-20020a17090aa00c00b001bc6f1baaaesm17149697pjp.39.2022.03.20.10.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 05/36] util/log: Move qemu_log_lock, qemu_log_unlock out of line Date: Sun, 20 Mar 2022 10:11:04 -0700 Message-Id: <20220320171135.2704502-6-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::633 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- include/qemu/log.h | 28 +++------------------------- util/log.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 64f28785ae..10e284291c 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -65,32 +65,10 @@ static inline bool qemu_log_separate(void) /* LOG_STRACE is used for user-mode strace logging. */ #define LOG_STRACE (1 << 19) -/* Lock output for a series of related logs. Since this is not needed - * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we - * assume that qemu_loglevel_mask has already been tested, and that - * qemu_loglevel is never set when qemu_logfile is unset. - */ +/* Lock/unlock output. */ -static inline FILE *qemu_log_lock(void) -{ - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - qemu_flockfile(logfile->fd); - return logfile->fd; - } else { - return NULL; - } -} - -static inline void qemu_log_unlock(FILE *fd) -{ - if (fd) { - qemu_funlockfile(fd); - } - rcu_read_unlock(); -} +FILE *qemu_log_lock(void); +void qemu_log_unlock(FILE *fd); /* Logging functions: */ diff --git a/util/log.c b/util/log.c index 00773ab717..248db6211e 100644 --- a/util/log.c +++ b/util/log.c @@ -34,6 +34,29 @@ int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; +/* Lock/unlock output. */ + +FILE *qemu_log_lock(void) +{ + QemuLogFile *logfile; + rcu_read_lock(); + logfile = qatomic_rcu_read(&qemu_logfile); + if (logfile) { + qemu_flockfile(logfile->fd); + return logfile->fd; + } else { + return NULL; + } +} + +void qemu_log_unlock(FILE *fd) +{ + if (fd) { + qemu_funlockfile(fd); + } + rcu_read_unlock(); +} + /* Return the number of characters emitted. */ int qemu_log(const char *fmt, ...) { From patchwork Sun Mar 20 17:11:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553186 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp878678mag; Sun, 20 Mar 2022 10:22:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx717Na2gBF5OoHBSSpBwzXvbWcBL8vR6UVM6GSu4lWIFCfZfJVGRcOx91oI81BHdcqxubq X-Received: by 2002:ac8:4258:0:b0:2e0:6772:cf88 with SMTP id r24-20020ac84258000000b002e06772cf88mr13458118qtm.157.1647796943671; Sun, 20 Mar 2022 10:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796943; cv=none; d=google.com; s=arc-20160816; b=LikSyUrKerfpLzvr9KklJuUURsjFAs2AC4vo6oBy50cmbpjPpdtCj1WPSH5FOOdPzB OM/1s1IylU24gGIg6Q1Nh+wWyxc1ITeJO5iRrRHwqiZh4V4nbriVxzBNuGfs4W4ufvtf rlrUSKc/CSbSN5b2gKZFlOR7tYECOzvGGs6p9GIRqSC0cu/HUy+sVwk8st6nEoLnt2Cp iPSTrc70ZAp9llmbMxKAwnbc9/NyMMUCehfEwwn2wdt62KbDouDCDQxRsPVM4/eCOw3Q Kj8Q7N85VfW1xtFbVwstTxZZ/GNo/DZSTznUWFCRKdLUWyMjSELotaeSZ1XA6KXiuDyV cqnw== 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=AiGXKmM5Cv0Fdfz4VnJTiU6gz9cUezs0SPdSZR5WJXA=; b=zX/rbt8tRtlYWKt6BmApzrkc1kvcC7btifOyN0OdGyWF9OdTNWplBnImz1EKhnR/ED L/ZniK/LoH0oCuzRIKjBIcxWltPTuRTsdUBlKdPvRBkWxfPFQtsDibCLGe6568vuCwyn afZ/B3p4zFY1JUWd9Eyiu7LC3bhZkCqODR98P4BBweiDWb9oc/K0zU5pJ1ypFyxWxPep aq6XeGvv2zz0m/OzZ8sKwfSes4WVE9SN2kihIQtCYdU0/93AdSb8kiUh3bbAgG9I0BeJ edFPGK/yDz8IkUZS6a2r/Zf2NzkE01h154sbRDGLaO3jiLg0Vy3iQd5zXKsZckUzHTxV nRdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F160S3K/"; 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 r9-20020a0cf809000000b00440e46a7da3si1241432qvn.577.2022.03.20.10.22.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:22:23 -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="F160S3K/"; 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]:42766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzG3-0003Pw-7j for patch@linaro.org; Sun, 20 Mar 2022 13:22:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5l-0008KR-TL for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:45 -0400 Received: from [2607:f8b0:4864:20::52b] (port=33514 helo=mail-pg1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5j-0003Qe-O4 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:44 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 6so8741555pgg.0 for ; Sun, 20 Mar 2022 10:11:43 -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=AiGXKmM5Cv0Fdfz4VnJTiU6gz9cUezs0SPdSZR5WJXA=; b=F160S3K/J48W+34HwvHGEi2w7IO1lXA6+C3AXYSIsvRVDt4Dx1nheHumuqD6Xh46fw pYnCdMRDC62bytTuEtjsMV5GIBiuqVVvNXtGb/6kL2BJwCGbfQW3BsbgzARHIvvOe0JN dQ6FE+6FelVt2t6SqrwAF89fYD9sfEJn9nLrurOrCzEsgtZMh6nfhRvScvwiKI9lWexz PrIVlu3XwtKdQxCj2qviGUDXKM1UQjNl+rnCwlDpqFaN3Nqr/KgiDQUIP3+1NwZmE6Bc dcUDSMGwhlGx2VLQRXGs7c06P+TcaOqK8/kBjtyY1aBgY4aevPWIXfmIVHqoXxf/POD5 yd6A== 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=AiGXKmM5Cv0Fdfz4VnJTiU6gz9cUezs0SPdSZR5WJXA=; b=SXZgwq0XDnfZa1USwuHl1pY6uRJ7dj+H0SH7qbsJB94sLXVb1vxYQ8Anprq9p9kXrm WgrwE0jB99Murdg6RKm/gr+sfNdESMk0KIe/C39zE5XOpOmA/EegkJ42ThGEl6ut9+Ip v9iccHyDMqoeKG/T2+vRf4orjgzzNuUhXshWgniI5wWHPNgKJ443kv7aeyWnqIEGG1Bm piDKjmcKsP8dA8mfwk5HJODSRISTN6vc8LZO/+zTWXcQDkXzZvRIJ+MALbthth9nmKMx CMY+2ZZwO03ROgf0v6R21xiOTAARFMtGOhikU2cRR9cxsb6d5y5bxd6nrOZGqm4Tz8Vp wTIA== X-Gm-Message-State: AOAM530iG4buz8S6qU2ECZML32lIOxZnGl/n9MNL0O0nG/LG90Vhpljy RmXgB+BklmxIIpii6PwEPQCnsSHcNqMHSA== X-Received: by 2002:a05:6a00:814:b0:4f7:4c6:1227 with SMTP id m20-20020a056a00081400b004f704c61227mr20241967pfk.54.1647796302389; Sun, 20 Mar 2022 10:11:42 -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.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 06/36] util/log: Treat qemu_log_lock like trylock Date: Sun, 20 Mar 2022 10:11:05 -0700 Message-Id: <20220320171135.2704502-7-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::52b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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" Do not require qemu_log_unlock to be called when qemu_log_lock returns NULL. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- util/log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/log.c b/util/log.c index 248db6211e..b1651d8122 100644 --- a/util/log.c +++ b/util/log.c @@ -39,12 +39,14 @@ static GArray *debug_regions; FILE *qemu_log_lock(void) { QemuLogFile *logfile; + rcu_read_lock(); logfile = qatomic_rcu_read(&qemu_logfile); if (logfile) { qemu_flockfile(logfile->fd); return logfile->fd; } else { + rcu_read_unlock(); return NULL; } } @@ -53,8 +55,8 @@ void qemu_log_unlock(FILE *fd) { if (fd) { qemu_funlockfile(fd); + rcu_read_unlock(); } - rcu_read_unlock(); } /* Return the number of characters emitted. */ From patchwork Sun Mar 20 17:11:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553184 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp878470mag; Sun, 20 Mar 2022 10:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw374YongKiGJV4cYahzuhPSvgD0MSbZmuPWbtYiCxsYd+4PTSpmkmZJOaxGdtuEgt8dGUc X-Received: by 2002:a05:622a:1788:b0:2e1:cdb8:41f8 with SMTP id s8-20020a05622a178800b002e1cdb841f8mr13814230qtk.499.1647796922906; Sun, 20 Mar 2022 10:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796922; cv=none; d=google.com; s=arc-20160816; b=dGsegDNV2DTMLFGeOdMUcgGVazBf5pRF4XaK3mN/dODJEAtPwUG6mZv8GWxBYZeOe6 DQkCz9BTbi5U9C1cPxwGJ49R/8NlUIqUUjKepR03TkuY+dNcl2JN/IM4RAdptqHndRGw AC7UhlfHV4m4uAvc/ORGqFlVtxskcHJ6XUFp/qJ+SeLGCR8V34l7WgJ9nx9tCRutsBk/ TEOh7OZfMjJvEpB5yr+4JkZDYWZh5zpWavHb1OHMjyvTNA1cnR1AazV46jwxtxUuAeqQ dwRmSmgdoKxP0eU0o88sF8zK/vU9b9k4mH//uN62/CWjn5SQOGN1vx1XRcEtf2wSWwxs kMww== 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=J1dSl4TTW2l9haojZKtDE3xV0KCAHP/jmJTof7woW9Y=; b=WVGC9pOx6pvaoxGo5OczxxP7EKayxhp0k5PSuWtcGcgqQ4aF+1nAGd2OLEEuxWuRh4 AqnR8GCfgBKVkrPst/j/oCoHAb9DNdTzONcD7tO8lJ1mQIkkvBEo9jKNie+Lb13hHMzc 1E1KIqCiqDWr7z8LTVcCKHAczJVWKhR80+4X9QICaK9uMvSPLQRsnCYkNOPNifHrHJCn /TGJTuRm6AaJlDlgdHLQMqo9UeSsg0Ouyx8svmJkiu4IflETxA5CYm/g73zn2FxhBqBl +Ixn9MqFJDlZKEqWo7vOMRWHMMOvC8fbb/IWAzUPy6h8YNpn0fjSI5gprW4F4fzGqGCN wN3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G3Zx6dmW; 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 w23-20020a05620a129700b0067e4be239f5si1244557qki.570.2022.03.20.10.22.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:22:02 -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=G3Zx6dmW; 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]:42320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzFi-00035u-Dw for patch@linaro.org; Sun, 20 Mar 2022 13:22:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5n-0008Lk-IF for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:47 -0400 Received: from [2607:f8b0:4864:20::532] (port=35759 helo=mail-pg1-x532.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5l-0003Qn-K0 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:46 -0400 Received: by mail-pg1-x532.google.com with SMTP id e6so8737180pgn.2 for ; Sun, 20 Mar 2022 10:11:44 -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=J1dSl4TTW2l9haojZKtDE3xV0KCAHP/jmJTof7woW9Y=; b=G3Zx6dmWTDj3rdH7H5Zzsiei+VsMlRBdn5ump6JYSnDHw7m/W6ssIub/PxMwr20Zud yhJbqbnvQXxy0GyosxouG3qihWKYvoBPDMZPar/MGV2KJpty9jJUMzQbSVhuk7WL8jHW SIYRI+bc6qjcszOSKGah1fKXvwL9oEy5CUaYFg+MkSqhopNKoMsmKkmJFSbx+g5dhKZq o+0S0PehzgYmtYeSpvUuOpF/a8b4i6f2KDczyj1hE5Pa8BVmMVdxU7/PZ4N3u4AKZ1oc QVfCsgilgH9C+dDh9pC1cBaJ6OdYh8AhKjy1tEXwSAegoyCqCZuBtPRniVPQLqDj+yM8 9KEg== 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=J1dSl4TTW2l9haojZKtDE3xV0KCAHP/jmJTof7woW9Y=; b=qh5MvREFmkFuUrt80a6DH+8IOcnjfXctbm0PpX8VRQRrido/RkeUGVwliNxe/fWS3S ZIQ9BNn2Bv+qJ8AcvrJkocB71dA2VQ6mJnWmxOj3ni14wTZCX2QOG/tfyIA94Y4MpTzU 8ty//Iv7LzgUYf7KyyQYXXLCIqDojQnxBQGsQebI5XmWz+CVNQgO0pb1Rg8xBM5U8o1/ cOs+ppyZ/39/gh8UAqA2ckOdCAvjKLZvKWrbcf6QOu1WJr7AwblJwSNF4x8/8e+N6NLR hg64NNRed+UOJwmdw6JrE2/hlfQ1i6WtQBBm+Sj+5f27tvKucxarUPxrP6vzBNxdJsyT 4QOg== X-Gm-Message-State: AOAM532IDG/ifR0wyeYJGMkCjUMEZDuqPiZjqYBJ9f2c8zIii37iTDfD dk+pmX2yU1FcgTge3f5+bCHVU2LZWGAQYA== X-Received: by 2002:a63:4766:0:b0:382:6cc2:c0d3 with SMTP id w38-20020a634766000000b003826cc2c0d3mr3234343pgk.6.1647796303299; Sun, 20 Mar 2022 10:11:43 -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.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 07/36] hw/xen: Split out xen_pv_output_msg Date: Sun, 20 Mar 2022 10:11:06 -0700 Message-Id: <20220320171135.2704502-8-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::532 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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" Do not replicate the individual logging statements. Use qemu_log_lock/unlock instead of qemu_log directly. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- hw/xen/xen_pvdev.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index 8ab458922a..355bbda60d 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -196,34 +196,38 @@ const char *xenbus_strstate(enum xenbus_state state) * 2 == noisy debug messages (logfile only). * 3 == will flood your log (logfile only). */ +static void xen_pv_output_msg(struct XenLegacyDevice *xendev, + FILE *f, const char *fmt, va_list args) +{ + if (xendev) { + fprintf(f, "xen be: %s: ", xendev->name); + } else { + fprintf(f, "xen be core: "); + } + vfprintf(f, fmt, args); +} + void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level, const char *fmt, ...) { + FILE *logfile; va_list args; - if (xendev) { - if (msg_level > xendev->debug) { - return; - } - qemu_log("xen be: %s: ", xendev->name); - if (msg_level == 0) { - fprintf(stderr, "xen be: %s: ", xendev->name); - } - } else { - if (msg_level > debug) { - return; - } - qemu_log("xen be core: "); - if (msg_level == 0) { - fprintf(stderr, "xen be core: "); - } + if (msg_level > (xendev ? xendev->debug : debug)) { + return; } - va_start(args, fmt); - qemu_log_vprintf(fmt, args); - va_end(args); + + logfile = qemu_log_lock(); + if (logfile) { + va_start(args, fmt); + xen_pv_output_msg(xendev, logfile, fmt, args); + va_end(args); + qemu_log_unlock(logfile); + } + if (msg_level == 0) { va_start(args, fmt); - vfprintf(stderr, fmt, args); + xen_pv_output_msg(xendev, stderr, fmt, args); va_end(args); } qemu_log_flush(); From patchwork Sun Mar 20 17:11:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553191 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp880741mag; Sun, 20 Mar 2022 10:26:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu/rL6OI04lBZJtv0B3hg7mOU7f6zjz1GglJuDdHXfrbQWvU4IA47JSMPfe2k8huxcE9lB X-Received: by 2002:a05:622a:34a:b0:2e1:d61b:79c3 with SMTP id r10-20020a05622a034a00b002e1d61b79c3mr14100806qtw.504.1647797193485; Sun, 20 Mar 2022 10:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797193; cv=none; d=google.com; s=arc-20160816; b=x5sBCoU9TtjvRrr8ewOfNdPUwR2Nxq3J+Oq4iI/vkdXvyTcrpT77Vst3Y2tAOGl1hR SrS24sxtsH1VBAPuSpt3+ENTT3ARlRnYXdwTnt3GhNBaoyIIujHT8XGJFfYEZJ3USbHl VBaY4+8XGDKmyElcCRtxeXtLxKAkvnhOGQGeA+WJupwxSqG2nNVjPb5zSkWU6eZkRAjQ 6qBSGZduFIwESg8lPfRbcFM3MGdxRVM2ovi4x8FLzHLg5KvdvbSgYe3Z3uzpe3ry1CeA g6NCPXs+v6+IBflRgHon6+ndNZP0ocb3CCpNLMUrcpE3jt5jcA2UEV4005zzcueJmLO0 qbhA== 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=XymUoOZu9qgmLYieG14wpZ+N97PZ7+UZcXb+KUhmS5o=; b=Mj4mvradDpMkXcDX9HIA8F6tWDr9xSNkB7VGLFxyftXGpzx4WTHNVvDJMh9wNvJs4Z kysu0VG22JIkVIDnG57L2kE+FzoWAb2EL30ljnw1VSL8ZOUEGAsvD0P9ANdiM/djOjMg 9JX59ydVrhXe93bHz7lPdksvej2ZOjhiJ574SRz+e/QmNxWCdH7XdRgIAopzFl4JyKbi FvIeZOAxnldBEk0fOWOwdNTkdrv2NlC8hXtnuyITp1wcsCaRxdRR+KK4zAs+NncXZRzZ 4v0R0g9DfpgKzSn2I7sJBhG3ZT3qjohUizQk2a3ZlqueQY2LcNmKeCR29lqRjnbUGwki WiDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JjLtsCQC; 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 n13-20020a05622a040d00b002e1fbf3be7dsi1516974qtx.110.2022.03.20.10.26.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:26:33 -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=JjLtsCQC; 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]:51332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzK5-0000ik-2Y for patch@linaro.org; Sun, 20 Mar 2022 13:26:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5n-0008MQ-TR for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:47 -0400 Received: from [2607:f8b0:4864:20::52d] (port=33516 helo=mail-pg1-x52d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5l-0003R0-Jy for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:47 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 6so8741591pgg.0 for ; Sun, 20 Mar 2022 10:11:45 -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=XymUoOZu9qgmLYieG14wpZ+N97PZ7+UZcXb+KUhmS5o=; b=JjLtsCQCsYlpOF/T7oGcQRL4/U/UrPZ88oUx//99vfN4Cl5uHynTW41LgI10ufFUmj j2ENoz1Z10wfwaF6Qw3EbHxiaKEiIs9vpkL+rK2FIFUKUAt6wHA4wHadMZyw9WN54qjg wZTMzhwr393Qij6F6vuWrK65V+/hjqXdzCf5CbD6y21lHwmL0otUwLp9reDvO3maQ5az YstjWk4W1XMFv72e4uS+mYPsfnOcQwrHH+OP+8332YKlDqcoWu+a4DpCZzkCoEPseexS F/oHoZ7xfXFiqMACCkCBh466QNxaOmumXAEgEhXVF2gOdNy6KMYHHQcGoR7vv3BS8Yqp rZQw== 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=XymUoOZu9qgmLYieG14wpZ+N97PZ7+UZcXb+KUhmS5o=; b=j9NP0J2PJDQTta7Tspd3SWPqIFbA9XPfrINwe/9erZANslrh9doIsEubpV/o4uGHGD nTpFFxKICTLUig2gVHNCvvMO4gYbsXCoLXy+ApjFVNqaiLOEJ88xtuR0HAjla0Ktuhww cwjVg9lEISMstNuMNtbQy0D+KeZS4RRhAmvLrMAYahlK5+cBtNFVBJSvG7rE9ocVNSgq QFoT9SePKIqqJa+KaJqODEV+xljj9NmAlWA6ARhYVkKJeJBhDJnRt730qSu5Gkw2pEhM IPzdSwGjZOSy9A9PvzukDLDMixxhWOWXsyoQl5NAvLsQzGURlGFJhQe5xeLs3LVjvjMC 79vQ== X-Gm-Message-State: AOAM5315d56l4ycWiylp7IhS9lzy6aTstJOPu6xWsGhZcxG6k7eHkHDP 4fUTHvE6iqdTBtpLFWoxt2kyEJ6G6nI4rA== X-Received: by 2002:a05:6a00:2311:b0:4e1:52bf:e466 with SMTP id h17-20020a056a00231100b004e152bfe466mr20438407pfh.77.1647796304125; Sun, 20 Mar 2022 10:11:44 -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.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 08/36] *: Use fprintf between qemu_log_lock/unlock Date: Sun, 20 Mar 2022 10:11:07 -0700 Message-Id: <20220320171135.2704502-9-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::52d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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" Inside qemu_log, we perform qemu_log_lock/unlock, which need not be done if we have already performed the lock beforehand. Always check the result of qemu_log_lock -- only checking qemu_loglevel_mask races with the acquisition of the lock on the logfile. Signed-off-by: Richard Henderson --- include/exec/log.h | 2 +- accel/tcg/cpu-exec.c | 16 ++--- accel/tcg/translate-all.c | 117 +++++++++++++++++++----------------- accel/tcg/translator.c | 10 +-- cpu.c | 8 +-- hw/net/can/can_sja1000.c | 25 ++++---- net/can/can_socketcan.c | 24 ++++---- target/i386/tcg/translate.c | 14 +++-- tcg/tcg.c | 74 +++++++++++++---------- 9 files changed, 158 insertions(+), 132 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index 3c7fa65ead..6a53199d44 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -73,7 +73,7 @@ static inline void log_page_dump(const char *operation) { FILE *logfile = qemu_log_lock(); if (logfile) { - qemu_log("page layout changed following %s\n", operation); + fprintf(logfile, "page layout changed following %s\n", operation); page_dump(logfile); } qemu_log_unlock(logfile); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index c997c2e8e0..7bc489101f 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -216,16 +216,18 @@ static inline void log_cpu_exec(target_ulong pc, CPUState *cpu, #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) { FILE *logfile = qemu_log_lock(); - int flags = 0; + if (logfile) { + int flags = 0; - if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) { - flags |= CPU_DUMP_FPU; - } + if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) { + flags |= CPU_DUMP_FPU; + } #if defined(TARGET_I386) - flags |= CPU_DUMP_CCOP; + flags |= CPU_DUMP_CCOP; #endif - log_cpu_state(cpu, flags); - qemu_log_unlock(logfile); + log_cpu_state(cpu, flags); + qemu_log_unlock(logfile); + } } #endif /* DEBUG_DISAS */ } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 5971cd53ab..4af7455522 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1529,68 +1529,75 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && qemu_log_in_addr_range(tb->pc)) { FILE *logfile = qemu_log_lock(); - int code_size, data_size; - const tcg_target_ulong *rx_data_gen_ptr; - size_t chunk_start; - int insn = 0; + if (logfile) { + int code_size, data_size; + const tcg_target_ulong *rx_data_gen_ptr; + size_t chunk_start; + int insn = 0; - if (tcg_ctx->data_gen_ptr) { - rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr); - code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr; - data_size = gen_code_size - code_size; - } else { - rx_data_gen_ptr = 0; - code_size = gen_code_size; - data_size = 0; - } - - /* Dump header and the first instruction */ - qemu_log("OUT: [size=%d]\n", gen_code_size); - qemu_log(" -- guest addr 0x" TARGET_FMT_lx " + tb prologue\n", - tcg_ctx->gen_insn_data[insn][0]); - chunk_start = tcg_ctx->gen_insn_end_off[insn]; - log_disas(tb->tc.ptr, chunk_start); - - /* - * Dump each instruction chunk, wrapping up empty chunks into - * the next instruction. The whole array is offset so the - * first entry is the beginning of the 2nd instruction. - */ - while (insn < tb->icount) { - size_t chunk_end = tcg_ctx->gen_insn_end_off[insn]; - if (chunk_end > chunk_start) { - qemu_log(" -- guest addr 0x" TARGET_FMT_lx "\n", - tcg_ctx->gen_insn_data[insn][0]); - log_disas(tb->tc.ptr + chunk_start, chunk_end - chunk_start); - chunk_start = chunk_end; + if (tcg_ctx->data_gen_ptr) { + rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr); + code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr; + data_size = gen_code_size - code_size; + } else { + rx_data_gen_ptr = 0; + code_size = gen_code_size; + data_size = 0; } - insn++; - } - if (chunk_start < code_size) { - qemu_log(" -- tb slow paths + alignment\n"); - log_disas(tb->tc.ptr + chunk_start, code_size - chunk_start); - } + /* Dump header and the first instruction */ + fprintf(logfile, "OUT: [size=%d]\n", gen_code_size); + fprintf(logfile, + " -- guest addr 0x" TARGET_FMT_lx " + tb prologue\n", + tcg_ctx->gen_insn_data[insn][0]); + chunk_start = tcg_ctx->gen_insn_end_off[insn]; + disas(logfile, tb->tc.ptr, chunk_start); - /* Finally dump any data we may have after the block */ - if (data_size) { - int i; - qemu_log(" data: [size=%d]\n", data_size); - for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) { - if (sizeof(tcg_target_ulong) == 8) { - qemu_log("0x%08" PRIxPTR ": .quad 0x%016" TCG_PRIlx "\n", - (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); - } else if (sizeof(tcg_target_ulong) == 4) { - qemu_log("0x%08" PRIxPTR ": .long 0x%08" TCG_PRIlx "\n", - (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); - } else { - qemu_build_not_reached(); + /* + * Dump each instruction chunk, wrapping up empty chunks into + * the next instruction. The whole array is offset so the + * first entry is the beginning of the 2nd instruction. + */ + while (insn < tb->icount) { + size_t chunk_end = tcg_ctx->gen_insn_end_off[insn]; + if (chunk_end > chunk_start) { + fprintf(logfile, " -- guest addr 0x" TARGET_FMT_lx "\n", + tcg_ctx->gen_insn_data[insn][0]); + disas(logfile, tb->tc.ptr + chunk_start, + chunk_end - chunk_start); + chunk_start = chunk_end; + } + insn++; + } + + if (chunk_start < code_size) { + fprintf(logfile, " -- tb slow paths + alignment\n"); + disas(logfile, tb->tc.ptr + chunk_start, + code_size - chunk_start); + } + + /* Finally dump any data we may have after the block */ + if (data_size) { + int i; + fprintf(logfile, " data: [size=%d]\n", data_size); + for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) { + if (sizeof(tcg_target_ulong) == 8) { + fprintf(logfile, + "0x%08" PRIxPTR ": .quad 0x%016" TCG_PRIlx "\n", + (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); + } else if (sizeof(tcg_target_ulong) == 4) { + fprintf(logfile, + "0x%08" PRIxPTR ": .long 0x%08" TCG_PRIlx "\n", + (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); + } else { + qemu_build_not_reached(); + } } } + fprintf(logfile, "\n"); + qemu_log_flush(); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_flush(); - qemu_log_unlock(logfile); } #endif diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index f06c314266..90da944dab 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -140,10 +140,12 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(db->pc_first)) { FILE *logfile = qemu_log_lock(); - qemu_log("----------------\n"); - ops->disas_log(db, cpu); - qemu_log("\n"); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "----------------\n"); + ops->disas_log(db, cpu); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } } #endif } diff --git a/cpu.c b/cpu.c index be1f8b074c..159d0b0d1d 100644 --- a/cpu.c +++ b/cpu.c @@ -401,10 +401,10 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP); if (qemu_log_separate()) { FILE *logfile = qemu_log_lock(); - qemu_log("qemu: fatal: "); - qemu_log_vprintf(fmt, ap2); - qemu_log("\n"); - log_cpu_state(cpu, CPU_DUMP_FPU | CPU_DUMP_CCOP); + fprintf(logfile, "qemu: fatal: "); + vfprintf(logfile, fmt, ap2); + fprintf(logfile, "\n"); + cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP); qemu_log_flush(); qemu_log_unlock(logfile); qemu_log_close(); diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c index 3ba803e947..919e93664d 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -246,22 +246,23 @@ int can_sja_accept_filter(CanSJA1000State *s, static void can_display_msg(const char *prefix, const qemu_can_frame *msg) { - int i; FILE *logfile = qemu_log_lock(); - qemu_log("%s%03X [%01d] %s %s", - prefix, - msg->can_id & QEMU_CAN_EFF_MASK, - msg->can_dlc, - msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF", - msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT"); + if (logfile) { + fprintf(logfile, "%s%03X [%01d] %s %s", + prefix, + msg->can_id & QEMU_CAN_EFF_MASK, + msg->can_dlc, + msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF", + msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT"); - for (i = 0; i < msg->can_dlc; i++) { - qemu_log(" %02X", msg->data[i]); + for (int i = 0; i < msg->can_dlc; i++) { + fprintf(logfile, " %02X", msg->data[i]); + } + fprintf(logfile, "\n"); + qemu_log_flush(); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_flush(); - qemu_log_unlock(logfile); } static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame) diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c index 4b68f60c6b..ae19d35001 100644 --- a/net/can/can_socketcan.c +++ b/net/can/can_socketcan.c @@ -75,20 +75,22 @@ QEMU_BUILD_BUG_ON(offsetof(qemu_can_frame, data) static void can_host_socketcan_display_msg(struct qemu_can_frame *msg) { - int i; FILE *logfile = qemu_log_lock(); - qemu_log("[cansocketcan]: %03X [%01d] %s %s", - msg->can_id & QEMU_CAN_EFF_MASK, - msg->can_dlc, - msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF", - msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT"); - for (i = 0; i < msg->can_dlc; i++) { - qemu_log(" %02X", msg->data[i]); + if (logfile) { + fprintf(logfile, "[cansocketcan]: %03X [%01d] %s %s", + msg->can_id & QEMU_CAN_EFF_MASK, + msg->can_dlc, + msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF", + msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT"); + + for (int i = 0; i < msg->can_dlc; i++) { + fprintf(logfile, " %02X", msg->data[i]); + } + fprintf(logfile, "\n"); + qemu_log_flush(); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_flush(); - qemu_log_unlock(logfile); } static void can_host_socketcan_read(void *opaque) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 2a94d33742..7b75e79e2b 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2581,14 +2581,16 @@ static void gen_unknown_opcode(CPUX86State *env, DisasContext *s) if (qemu_loglevel_mask(LOG_UNIMP)) { FILE *logfile = qemu_log_lock(); - target_ulong pc = s->pc_start, end = s->pc; + if (logfile) { + target_ulong pc = s->pc_start, end = s->pc; - qemu_log("ILLOPC: " TARGET_FMT_lx ":", pc); - for (; pc < end; ++pc) { - qemu_log(" %02x", cpu_ldub_code(env, pc)); + fprintf(logfile, "ILLOPC: " TARGET_FMT_lx ":", pc); + for (; pc < end; ++pc) { + fprintf(logfile, " %02x", cpu_ldub_code(env, pc)); + } + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_unlock(logfile); } } diff --git a/tcg/tcg.c b/tcg/tcg.c index 33a97eabdb..42c1620ec6 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -757,31 +757,35 @@ void tcg_prologue_init(TCGContext *s) #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) { FILE *logfile = qemu_log_lock(); - qemu_log("PROLOGUE: [size=%zu]\n", prologue_size); - if (s->data_gen_ptr) { - size_t code_size = s->data_gen_ptr - s->code_gen_ptr; - size_t data_size = prologue_size - code_size; - size_t i; + if (logfile) { + fprintf(logfile, "PROLOGUE: [size=%zu]\n", prologue_size); + if (s->data_gen_ptr) { + size_t code_size = s->data_gen_ptr - s->code_gen_ptr; + size_t data_size = prologue_size - code_size; + size_t i; - log_disas(s->code_gen_ptr, code_size); + disas(logfile, s->code_gen_ptr, code_size); - for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { - if (sizeof(tcg_target_ulong) == 8) { - qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", - (uintptr_t)s->data_gen_ptr + i, - *(uint64_t *)(s->data_gen_ptr + i)); - } else { - qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n", - (uintptr_t)s->data_gen_ptr + i, - *(uint32_t *)(s->data_gen_ptr + i)); + for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { + if (sizeof(tcg_target_ulong) == 8) { + fprintf(logfile, + "0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", + (uintptr_t)s->data_gen_ptr + i, + *(uint64_t *)(s->data_gen_ptr + i)); + } else { + fprintf(logfile, + "0x%08" PRIxPTR ": .long 0x%08x\n", + (uintptr_t)s->data_gen_ptr + i, + *(uint32_t *)(s->data_gen_ptr + i)); + } } + } else { + disas(logfile, s->code_gen_ptr, prologue_size); } - } else { - log_disas(s->code_gen_ptr, prologue_size); + fprintf(logfile, "\n"); + qemu_log_flush(); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_flush(); - qemu_log_unlock(logfile); } #endif @@ -4201,10 +4205,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP) && qemu_log_in_addr_range(tb->pc))) { FILE *logfile = qemu_log_lock(); - qemu_log("OP:\n"); - tcg_dump_ops(s, false); - qemu_log("\n"); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "OP:\n"); + tcg_dump_ops(s, false); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } } #endif @@ -4246,10 +4252,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND) && qemu_log_in_addr_range(tb->pc))) { FILE *logfile = qemu_log_lock(); - qemu_log("OP before indirect lowering:\n"); - tcg_dump_ops(s, false); - qemu_log("\n"); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "OP before indirect lowering:\n"); + tcg_dump_ops(s, false); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } } #endif /* Replace indirect temps with direct temps. */ @@ -4267,10 +4275,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT) && qemu_log_in_addr_range(tb->pc))) { FILE *logfile = qemu_log_lock(); - qemu_log("OP after optimization and liveness analysis:\n"); - tcg_dump_ops(s, true); - qemu_log("\n"); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "OP after optimization and liveness analysis:\n"); + tcg_dump_ops(s, true); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } } #endif From patchwork Sun Mar 20 17:11:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553185 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp878654mag; Sun, 20 Mar 2022 10:22:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzucFeptIvOtvMPRO05LxlpCSpEOr288EA3pCyuFL8ZIlss5Mjzzbbb90CD2TcqTrkobyng X-Received: by 2002:ad4:5945:0:b0:440:a706:3eb7 with SMTP id eo5-20020ad45945000000b00440a7063eb7mr13762307qvb.96.1647796941674; Sun, 20 Mar 2022 10:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796941; cv=none; d=google.com; s=arc-20160816; b=qECQStvaHGepYt0BZXCjpllImv2BZmSr3sm4iPAzUlUd88KQeq7RR7AmhfOzxXJfyx guaLmdLVJXxhrQqF6rKowNngdDWcCSut7J2HCK79whX2nf+OIxHm+GIESN0MpO2jsF6A PwDwVSH68mP2MOt3gjf+hj3Gbp9DuaGDJXWYaTLr/Er8dZxP4WTPpF6n7v4bZkB4Px/Z JqWL7AEQPr7EFcvIeMpm2Nxg20sLsiduqVa7VhsVd3aH8tcoPPVDmPw2KKgTZ8TwYIEn v8bjzOfaECcdXNUoE1ja4EboBZYPGieCPfmXZMpggBQDu9byQsHsE2lM+EsVncY17zI+ yzUQ== 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=SnloB92roRJjW2I8fqc6iuhCF5tiad3l4/Mv7JIcEjs=; b=WdkbK9C4zKOVkmG61XaXoSeCEeSp3i7rYrc8Izva6WSTo2/xXygRYydaxXtNgJCE6a ZvBNvIoaWkh1ZtCe8LiXr328bq6djw7Li/mKzC5WKog2SyMdQI1xrOdd2hcZoO2i9ZQR 8jUYQRal73IlVZA4X2PIlKcwgwXT3i9rrdO9NuxVyYF9I6HoihoTi4ZK5GFtGjBfn3KB 3Uw4H9Wk034dhP6OwBlPZOvHThYMqFlGLtfwwT1lZVkqISc0Bb816vIkRYLULNuxTS/I ERqzVRA/mKzGhnBZLJiqEiBl1CMCFPYP9Lw8NGGN4mdgPc9x9BIeBg/mJEHh1A4siAq6 Fveg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aD6sl379; 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 f10-20020a05620a408a00b0067e4be238a1si1460282qko.230.2022.03.20.10.22.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:22:21 -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=aD6sl379; 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]:42658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzG1-0003Le-6Z for patch@linaro.org; Sun, 20 Mar 2022 13:22:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5r-0008PM-Di for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:51 -0400 Received: from [2607:f8b0:4864:20::42b] (port=35392 helo=mail-pf1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5n-0003R7-9q for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:48 -0400 Received: by mail-pf1-x42b.google.com with SMTP id a5so13704330pfv.2 for ; Sun, 20 Mar 2022 10:11:46 -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=SnloB92roRJjW2I8fqc6iuhCF5tiad3l4/Mv7JIcEjs=; b=aD6sl379pgxtG2JFd3jm4jd6gnwfnJsMebiguKUJ9iQKdXcEXQFi4wWbfq4IooTCbj l5PNrvZeVMuBj1jMErRWUAF8C3t9fIfvT8hno0A40rTWlS3aSgju6j9FN4Ht0hN86SzR wMWmPsuLY6v0HebKnjMmW5fosM/gF1T1uRo2mVjM/8MM6TUCM/4jyV+4HGsNpgnvBW+o svJ3/pkZEXXA56BjQRE4+MG78HWLxfoF6v5Xa7JBH8JEdxo0Zvl2/TQKA6Dh1XampEFa J7r4Vo8gClT68ufBLvGLl/G4/OXVzH2BPIRP1hr6tb62fJFOR3OSFWSdwI56D6yUOB8R rvvw== 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=SnloB92roRJjW2I8fqc6iuhCF5tiad3l4/Mv7JIcEjs=; b=SrFBalrRD9OrU/tGCYLmXD5srDdt4SbUWHfH+rvvshr6PkvQePZTKHV9WXs0/2+dAT ea4MM995+j9+WRDl0BKokrUhTQ+YV8SyE2HzFf+1pIq7sWP1NOHW0GEcLZRBVRiygLLj gIGP5YuEbxxYyz+sThcnuiEdzDgBv/UMQfFADaWMvDgds70TpCO8g42kXHu5/XSwrUui Md2IdBU2bykP6fiaCU7x6D+SiWpv2gSkCZzQ9uV6P8jTRKu2DLvzbxXNPjIXK/w+4AID luDX03/2119BRULMsOVSnQ8sWFPGiWip+5o4yB5l3PcZK9E52N9MV+o7/Ss7Z+ViQFu/ flTA== X-Gm-Message-State: AOAM533/Wy3Xf6C+PzrfzB9Jwuuh4ZB+lPalQb1hgfVymc05d3CdwgIQ 7JCZT//II8SEJZamfsmbs/Yd+YDKV/KhGw== X-Received: by 2002:a63:4e5d:0:b0:381:f11:59f6 with SMTP id o29-20020a634e5d000000b003810f1159f6mr15333118pgl.565.1647796305154; Sun, 20 Mar 2022 10:11:45 -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.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 09/36] util/log: Remove qemu_log_vprintf Date: Sun, 20 Mar 2022 10:11:08 -0700 Message-Id: <20220320171135.2704502-10-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::42b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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" This function is no longer used. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/qemu/log.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 10e284291c..6e45b31253 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -72,21 +72,6 @@ void qemu_log_unlock(FILE *fd); /* Logging functions: */ -/* vfprintf-like logging function - */ -static inline void GCC_FMT_ATTR(1, 0) -qemu_log_vprintf(const char *fmt, va_list va) -{ - QemuLogFile *logfile; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - vfprintf(logfile->fd, fmt, va); - } - rcu_read_unlock(); -} - /* log only if a bit is set on the current loglevel mask: * @mask: bit to check in the mask * @fmt: printf-style format string From patchwork Sun Mar 20 17:11:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553190 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp880698mag; Sun, 20 Mar 2022 10:26:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5eBxVtuDGgVk6qFA+82vAtN5RE/EVsGNUWmR82RuWuALU4+cjKUF125tU4fStGVtFR8FF X-Received: by 2002:a05:6214:f27:b0:441:1380:99a0 with SMTP id iw7-20020a0562140f2700b00441138099a0mr4285812qvb.112.1647797188681; Sun, 20 Mar 2022 10:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797188; cv=none; d=google.com; s=arc-20160816; b=fux4gB7WnkllEEEKeS9ekYV/V5WoqMHs7G2Sb7J3FNg6k538BLtOuAebm2psG1F0FG GS7iLyTtB+VqF8FFCNsYkjdxWAlbwGO8yJ3oEcubSkd9cWeud4tuWXjnfribPU+GtG1W PL7BYpXbCpbCTKVzeCrBwTpgKvvh1lMeMzXu3uMET3UDlUTQEkaP+O4SuNWZGkTwJRcT RZIynyYHqHZN5Y+rWdLv/mNnpeSPAKYR/Dbwf/STtLsnsFDjjT/PVKpqkhvEZwLMZxP8 iCMJGSQ7dTGdyQkmAys6Yx2W9X3+YVC0V4s1Ua5jj5lJxQb6+5wcOtHToQRL7yij6/5d bsdA== 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=OBLJhIXzKI/cdzhRUD5EzFRORqxgtBTHvf3b9Zw2Xz8=; b=fCRYjIRE5TjAacykzDpHv4Z7ywrKn7fXoec51o6TtrK+57hVPCjxy6HxJOextPsIim RHFzaNpQDEq4Mq7YogQl5cI+S9uIwbZp7JeVtOvXz7Udh6fHsT6MGEVzgb3Su6sh3tPL KrcEDWExMwIRDrIqacS0hr8hwvFqta/DqkbPlvDRVD439ebEiY1I2KMmOlMD5JCrtGFP 9oj7ZfxPo9R/2SEQdrn0eP2p7Ij01Nh2PGlXGKL7fbR6ib2XZg7Jj0TuXhgGOTkoaop3 B0bewocLGD2XZ0dZdm4XnRlV2So6XpL7U36/a1H15V43ZrR2kV3kBuTVsQFHoWLbPeDD gkYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gA0XEASG; 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 x21-20020a05620a449500b0067e4be238e3si1487335qkp.296.2022.03.20.10.26.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:26:28 -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=gA0XEASG; 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]:51210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzK0-0000dZ-7B for patch@linaro.org; Sun, 20 Mar 2022 13:26:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5r-0008Pt-Jk for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:51 -0400 Received: from [2607:f8b0:4864:20::102d] (port=37611 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5n-0003RQ-D4 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:49 -0400 Received: by mail-pj1-x102d.google.com with SMTP id mz9-20020a17090b378900b001c657559290so12183216pjb.2 for ; Sun, 20 Mar 2022 10:11:47 -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=OBLJhIXzKI/cdzhRUD5EzFRORqxgtBTHvf3b9Zw2Xz8=; b=gA0XEASGAR2s3DczN5S+O7hBXAp9WJpQj0ednhOmArxnoJvwMV67yUodOt5nYetRcS 2Mh8JeiCA+O+Rxllt4zS+5ita3/24T2YmvYjFerm79eCGHSmmAOaq6ZZUL4Zyhkhz+xe WeX+Af3MShNKvtVm4sOKqU6m7YLwH7S3JYPfX6Bs+kNkVxZu7J/Np+wNQHjwhyC+/fRA Bs4dUlfJmHeI3QcAWfO3u20vmr4dqzfzGipwi0LsXpZR/CenrmvhGo42yO58JxFlnq/r gnIXn+dOTODiSxkj845EXC46Bv8kr/p7OqrG0ttbMuFTgAwcETv01rYS78ORxdRlByl2 EIOQ== 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=OBLJhIXzKI/cdzhRUD5EzFRORqxgtBTHvf3b9Zw2Xz8=; b=3ktrFpci/jxFL5FceV238AH7LNqxbgZHUw8N3NLPS6Bo4+FK1PYXdCm4yW3iRf1Sot yc8Xkzv5CIzJxuE8zlNrwF1KIRqlk6bB8FN1UlHh5KToaWUoAfGTQdvGuI4NrnoAbOD8 vGMKexC2TcDchTOkuz9cMKdiiZH40UqtUWiLll3RCoLygspXU5bYud1cXcG1wpepG79L eLup+jfeklN3K7NkESuiVJ/L72uiDrQZl1701v16EU7XGI180nZGWyUdOXI34u9tDFba gytWMU52HCCvpMSVW4eGP+q4hN1mnXJ78x+RtdHeu2PsuXUppjv2Bzb8VpONCXA/hvX1 yH5w== X-Gm-Message-State: AOAM532weg/ciuIUajwWrEfNdWCA+5c0AP8I2ZVGiwPvxKIkzB7b7AeA C/5w6pZcmnotPXqD87Dr5W+ia5IE0vBQPA== X-Received: by 2002:a17:902:f544:b0:153:bb8a:9374 with SMTP id h4-20020a170902f54400b00153bb8a9374mr9316144plf.154.1647796306043; Sun, 20 Mar 2022 10:11:46 -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.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 10/36] tcg: Pass the locked filepointer to tcg_dump_ops Date: Sun, 20 Mar 2022 10:11:09 -0700 Message-Id: <20220320171135.2704502-11-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::102d (failed) 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: -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" We have already looked up and locked the filepointer. Use fprintf instead of qemu_log directly for output in and around tcg_dump_ops. Signed-off-by: Richard Henderson --- tcg/tcg.c | 109 ++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 57 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 42c1620ec6..1e27367af6 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1808,7 +1808,11 @@ static inline TCGReg tcg_regset_first(TCGRegSet d) } } -static void tcg_dump_ops(TCGContext *s, bool have_prefs) +/* Return only the number of characters output -- no error return. */ +#define ne_fprintf(...) \ + ({ int ret_ = fprintf(__VA_ARGS__); ret_ >= 0 ? ret_ : 0; }) + +static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) { char buf[128]; TCGOp *op; @@ -1824,7 +1828,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) if (c == INDEX_op_insn_start) { nb_oargs = 0; - col += qemu_log("\n ----"); + col += ne_fprintf(f, "\n ----"); for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { target_ulong a; @@ -1833,7 +1837,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) #else a = op->args[i]; #endif - col += qemu_log(" " TARGET_FMT_lx, a); + col += ne_fprintf(f, " " TARGET_FMT_lx, a); } } else if (c == INDEX_op_call) { const TCGHelperInfo *info = tcg_call_info(op); @@ -1844,7 +1848,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) nb_iargs = TCGOP_CALLI(op); nb_cargs = def->nb_cargs; - col += qemu_log(" %s ", def->name); + col += ne_fprintf(f, " %s ", def->name); /* * Print the function name from TCGHelperInfo, if available. @@ -1852,15 +1856,15 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) * but the actual function pointer comes from the plugin. */ if (func == info->func) { - col += qemu_log("%s", info->name); + col += ne_fprintf(f, "%s", info->name); } else { - col += qemu_log("plugin(%p)", func); + col += ne_fprintf(f, "plugin(%p)", func); } - col += qemu_log(",$0x%x,$%d", info->flags, nb_oargs); + col += ne_fprintf(f, ",$0x%x,$%d", info->flags, nb_oargs); for (i = 0; i < nb_oargs; i++) { - col += qemu_log(",%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[i])); + col += ne_fprintf(f, ",%s", tcg_get_arg_str(s, buf, sizeof(buf), + op->args[i])); } for (i = 0; i < nb_iargs; i++) { TCGArg arg = op->args[nb_oargs + i]; @@ -1868,34 +1872,32 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) if (arg != TCG_CALL_DUMMY_ARG) { t = tcg_get_arg_str(s, buf, sizeof(buf), arg); } - col += qemu_log(",%s", t); + col += ne_fprintf(f, ",%s", t); } } else { - col += qemu_log(" %s ", def->name); + col += ne_fprintf(f, " %s ", def->name); nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; nb_cargs = def->nb_cargs; if (def->flags & TCG_OPF_VECTOR) { - col += qemu_log("v%d,e%d,", 64 << TCGOP_VECL(op), - 8 << TCGOP_VECE(op)); + col += ne_fprintf(f, "v%d,e%d,", 64 << TCGOP_VECL(op), + 8 << TCGOP_VECE(op)); } k = 0; for (i = 0; i < nb_oargs; i++) { - if (k != 0) { - col += qemu_log(","); - } - col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[k++])); + const char *sep = k ? "," : ""; + col += ne_fprintf(f, "%s%s", sep, + tcg_get_arg_str(s, buf, sizeof(buf), + op->args[k++])); } for (i = 0; i < nb_iargs; i++) { - if (k != 0) { - col += qemu_log(","); - } - col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[k++])); + const char *sep = k ? "," : ""; + col += ne_fprintf(f, "%s%s", sep, + tcg_get_arg_str(s, buf, sizeof(buf), + op->args[k++])); } switch (c) { case INDEX_op_brcond_i32: @@ -1910,9 +1912,9 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) case INDEX_op_cmpsel_vec: if (op->args[k] < ARRAY_SIZE(cond_name) && cond_name[op->args[k]]) { - col += qemu_log(",%s", cond_name[op->args[k++]]); + col += ne_fprintf(f, ",%s", cond_name[op->args[k++]]); } else { - col += qemu_log(",$0x%" TCG_PRIlx, op->args[k++]); + col += ne_fprintf(f, ",$0x%" TCG_PRIlx, op->args[k++]); } i = 1; break; @@ -1927,12 +1929,12 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) unsigned ix = get_mmuidx(oi); if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) { - col += qemu_log(",$0x%x,%u", op, ix); + col += ne_fprintf(f, ",$0x%x,%u", op, ix); } else { const char *s_al, *s_op; s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT]; s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)]; - col += qemu_log(",%s%s,%u", s_al, s_op, ix); + col += ne_fprintf(f, ",%s%s,%u", s_al, s_op, ix); } i = 1; } @@ -1950,9 +1952,9 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) name = bswap_flag_name[flags]; } if (name) { - col += qemu_log(",%s", name); + col += ne_fprintf(f, ",%s", name); } else { - col += qemu_log(",$0x%" TCG_PRIlx, flags); + col += ne_fprintf(f, ",$0x%" TCG_PRIlx, flags); } i = k = 1; } @@ -1967,49 +1969,42 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: case INDEX_op_brcond2_i32: - col += qemu_log("%s$L%d", k ? "," : "", - arg_label(op->args[k])->id); + col += ne_fprintf(f, "%s$L%d", k ? "," : "", + arg_label(op->args[k])->id); i++, k++; break; default: break; } for (; i < nb_cargs; i++, k++) { - col += qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", op->args[k]); + col += ne_fprintf(f, "%s$0x%" TCG_PRIlx, k ? "," : "", + op->args[k]); } } if (have_prefs || op->life) { - - QemuLogFile *logfile; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - for (; col < 40; ++col) { - putc(' ', logfile->fd); - } + for (; col < 40; ++col) { + putc(' ', f); } - rcu_read_unlock(); } if (op->life) { unsigned life = op->life; if (life & (SYNC_ARG * 3)) { - qemu_log(" sync:"); + ne_fprintf(f, " sync:"); for (i = 0; i < 2; ++i) { if (life & (SYNC_ARG << i)) { - qemu_log(" %d", i); + ne_fprintf(f, " %d", i); } } } life /= DEAD_ARG; if (life) { - qemu_log(" dead:"); + ne_fprintf(f, " dead:"); for (i = 0; life; ++i, life >>= 1) { if (life & 1) { - qemu_log(" %d", i); + ne_fprintf(f, " %d", i); } } } @@ -2020,28 +2015,28 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) TCGRegSet set = op->output_pref[i]; if (i == 0) { - qemu_log(" pref="); + ne_fprintf(f, " pref="); } else { - qemu_log(","); + ne_fprintf(f, ","); } if (set == 0) { - qemu_log("none"); + ne_fprintf(f, "none"); } else if (set == MAKE_64BIT_MASK(0, TCG_TARGET_NB_REGS)) { - qemu_log("all"); + ne_fprintf(f, "all"); #ifdef CONFIG_DEBUG_TCG } else if (tcg_regset_single(set)) { TCGReg reg = tcg_regset_first(set); - qemu_log("%s", tcg_target_reg_names[reg]); + ne_fprintf(f, "%s", tcg_target_reg_names[reg]); #endif } else if (TCG_TARGET_NB_REGS <= 32) { - qemu_log("%#x", (uint32_t)set); + ne_fprintf(f, "%#x", (uint32_t)set); } else { - qemu_log("%#" PRIx64, (uint64_t)set); + ne_fprintf(f, "%#" PRIx64, (uint64_t)set); } } } - qemu_log("\n"); + putc('\n', f); } } @@ -4207,7 +4202,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_lock(); if (logfile) { fprintf(logfile, "OP:\n"); - tcg_dump_ops(s, false); + tcg_dump_ops(s, logfile, false); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } @@ -4254,7 +4249,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_lock(); if (logfile) { fprintf(logfile, "OP before indirect lowering:\n"); - tcg_dump_ops(s, false); + tcg_dump_ops(s, logfile, false); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } @@ -4277,7 +4272,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_lock(); if (logfile) { fprintf(logfile, "OP after optimization and liveness analysis:\n"); - tcg_dump_ops(s, true); + tcg_dump_ops(s, logfile, true); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } From patchwork Sun Mar 20 17:11:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553198 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp883876mag; Sun, 20 Mar 2022 10:33:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGKXUrYJSd7IfqAMvTihnH4BKXfOHxBAEoHZYcundI3QJsVYgKYMXYCP2wFJZ4hVxp7xlb X-Received: by 2002:a05:620a:3720:b0:67d:3420:8381 with SMTP id de32-20020a05620a372000b0067d34208381mr10689462qkb.626.1647797581177; Sun, 20 Mar 2022 10:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797581; cv=none; d=google.com; s=arc-20160816; b=q5ykoVafp2BmpWN4/TinQjEolJZuXz6pO9h1qp6n4MQJy0RHI74MskJ0C75ckV8msz E6xieG+w2YKzGfwmopQJlxBcR5JMnXNZ1BTH9X42N3FWxBMKtTB3J43iryCKmTPqVB9s 0kAUwVxbYwWjd90pItCC5v+tIJA8CYejIdkfVDifmTG9D3n45OjAczIFPg80kgmcWnVP ydloQXZTO0JcJK/gsoJyLGNwd9np0Rj/IKOJYCEuoShByqIDWtWJ+8P0jkDwUW2YH/UZ 4fUjhKcslg5XvCTGygeryc9PpKyr+KISknG0GUGT1yX7QWwDdTuiPAquBVfTKZFsvI2p 614Q== 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=V9+EaOr/1vXn37zvEYgcVW2CiCTUfDr4DYqxTsoYhfw=; b=0s6kiK9NezHC5HrIZV4uPWRBRhXH+DEAZtLhUY41BvYquee04vuXKccy+Ak89UQ+9J DDJeZvyRD320Qb/81LJNmAnxtXjQn0IEhzfBwreSrwvFanufp6iQZ5DyboWU9S4ZiGpP yIRx4SPwwaak4mkBTJySBLAgIPKpXckocfSqy0IB9NIHqloyzvJTWc6UJQtJ8eNKdKDM cIxz90aTzCN5XhEU1gXC16OEgpYQy+uXGSSxaKnbZGop8aNua26MsHePY+yJy5taiK1j fLs8NOt+1vy0uCXE5QI9/IiPhmetUbn0dabl3VcDA97gFAake66+0oj3OV9xzauyRNY1 kQwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E33d3vsi; 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 p124-20020a37bf82000000b0067e4be23960si1288804qkf.421.2022.03.20.10.33.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:33: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=E33d3vsi; 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]:40328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzQK-0003wC-NY for patch@linaro.org; Sun, 20 Mar 2022 13:33:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5v-0008UF-E1 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:55 -0400 Received: from [2607:f8b0:4864:20::102e] (port=35577 helo=mail-pj1-x102e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5r-0003Rc-57 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:53 -0400 Received: by mail-pj1-x102e.google.com with SMTP id mj15-20020a17090b368f00b001c637aa358eso14578451pjb.0 for ; Sun, 20 Mar 2022 10:11:47 -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=V9+EaOr/1vXn37zvEYgcVW2CiCTUfDr4DYqxTsoYhfw=; b=E33d3vsi3l0HjbemdUavvIntflo2LmKa3UVOnrmvQ2Y7IL8QTbWRPsSdfGdii/YBT+ 4u6kNsVLn707eWkw6nPStIR8nI6trrsgN5Vgt+9trncbPkg/ytcx2/goBEB6TU0D+02w 5Hd/F9iNF5EkWFYUq0cHrSsYh0RQUHvBBOq6n8JkdsaUulM6TsbtRxE4XqefSJCXs8fa QR+GZQYN9Gnog1SkAzgILSQwQlzOYmgDYeHONycqXUgT65hHVuK5cSRP5kVo48KXAku8 lLH8PdIhri/EFalwvKv4cdf0kmZzEhGtjTIq42a8U2uKy36ZlEO+OkRuH/8sWGB8s5Kf a3vg== 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=V9+EaOr/1vXn37zvEYgcVW2CiCTUfDr4DYqxTsoYhfw=; b=lcHNwFKqzUhzHKe5ifcG4M+xEBYHDyIu3y0S/mIBPdklSbjkK9nwb6sxKMf8EQERFv q3QmfRU65dht/pKPD+PtvRuBLhyG8n8nvjlX74yt0QZa5AIGcTOtjkPx3XhzWs2YPxUU 1V/TYIGOI0caaLoAj2SmjpFJlr4W0Wfwk3GlePjKblz+4maG0cKJ8Vlu6XlrxxKi5mES 05Eg8XfLC9Ve2WG7l/TSLpmTbi4Vrd2ywAolIb+vTWNLLsmxyGMmtMHU2mckelFdONgD kYxuYIgvVx8Sab8hVZjWlnXln2T58AJ2OGC6yo6mVLfZVwGgWwcqKAh4CWGrZmgdVGFH hK4g== X-Gm-Message-State: AOAM531TRSxfBqgkB4l+3RLmufLqw89Yp3ShORRgZBNE2dW+Y/uFibKx EMtKvxP0A1Gpb97ZTi8J72KGd+NSb/JkSQ== X-Received: by 2002:a17:903:2305:b0:154:4aa2:e800 with SMTP id d5-20020a170903230500b001544aa2e800mr3551074plh.167.1647796306911; Sun, 20 Mar 2022 10:11:46 -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.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 11/36] exec/translator: Pass the locked filepointer to disas_log hook Date: Sun, 20 Mar 2022 10:11:10 -0700 Message-Id: <20220320171135.2704502-12-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::102e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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" We have fetched and locked the logfile in translator_loop. Pass the filepointer down to the disas_log hook so that it need not be fetched and locked again. Signed-off-by: Richard Henderson --- include/exec/translator.h | 2 +- accel/tcg/translator.c | 2 +- target/alpha/translate.c | 7 ++++--- target/arm/translate-a64.c | 6 +++--- target/arm/translate.c | 7 ++++--- target/avr/translate.c | 7 ++++--- target/cris/translate.c | 7 ++++--- target/hexagon/translate.c | 7 ++++--- target/hppa/translate.c | 15 ++++++++------- target/i386/tcg/translate.c | 6 +++--- target/m68k/translate.c | 7 ++++--- target/microblaze/translate.c | 7 ++++--- target/mips/tcg/translate.c | 7 ++++--- target/nios2/translate.c | 7 ++++--- target/openrisc/translate.c | 7 ++++--- target/ppc/translate.c | 7 ++++--- target/riscv/translate.c | 10 ++++++---- target/rx/translate.c | 7 ++++--- target/s390x/tcg/translate.c | 11 ++++++----- target/sh4/translate.c | 7 ++++--- target/sparc/translate.c | 7 ++++--- target/tricore/translate.c | 7 ++++--- target/xtensa/translate.c | 7 ++++--- 23 files changed, 92 insertions(+), 72 deletions(-) diff --git a/include/exec/translator.h b/include/exec/translator.h index 9bc46eda59..31d3fa76ff 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -118,7 +118,7 @@ typedef struct TranslatorOps { void (*insn_start)(DisasContextBase *db, CPUState *cpu); void (*translate_insn)(DisasContextBase *db, CPUState *cpu); void (*tb_stop)(DisasContextBase *db, CPUState *cpu); - void (*disas_log)(const DisasContextBase *db, CPUState *cpu); + void (*disas_log)(const DisasContextBase *db, CPUState *cpu, FILE *f); } TranslatorOps; /** diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 90da944dab..7d1505b239 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -142,7 +142,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, FILE *logfile = qemu_log_lock(); if (logfile) { fprintf(logfile, "----------------\n"); - ops->disas_log(db, cpu); + ops->disas_log(db, cpu, logfile); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 66768ab47a..b1f78cff53 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -3027,10 +3027,11 @@ static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void alpha_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void alpha_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps alpha_tr_ops = { diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index d1a59fad9c..87ae8b7571 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -14962,12 +14962,12 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } static void aarch64_tr_disas_log(const DisasContextBase *dcbase, - CPUState *cpu) + CPUState *cpu, FILE *logfile) { DisasContext *dc = container_of(dcbase, DisasContext, base); - qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dc->base.pc_first)); + target_disas(logfile, cpu, dc->base.pc_first, dc->base.tb->size); } const TranslatorOps aarch64_translator_ops = { diff --git a/target/arm/translate.c b/target/arm/translate.c index bf2196b9e2..783a43b4ae 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -9891,12 +9891,13 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void arm_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void arm_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { DisasContext *dc = container_of(dcbase, DisasContext, base); - qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dc->base.pc_first)); + target_disas(logfile, cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps arm_translator_ops = { diff --git a/target/avr/translate.c b/target/avr/translate.c index af8a3e0f9c..dc9c3d6bcc 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -3015,10 +3015,11 @@ static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void avr_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void avr_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps avr_tr_ops = { diff --git a/target/cris/translate.c b/target/cris/translate.c index 3656cd6db1..ac101344a3 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3268,11 +3268,12 @@ static void cris_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void cris_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void cris_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { if (!DISAS_CRIS) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } } diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 98f1452cad..d4fc92f7e9 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -833,10 +833,11 @@ static void hexagon_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void hexagon_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void hexagon_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 5c0b1eb274..c24d3ce3b8 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4305,29 +4305,30 @@ static void hppa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void hppa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void hppa_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { target_ulong pc = dcbase->pc_first; #ifdef CONFIG_USER_ONLY switch (pc) { case 0x00: - qemu_log("IN:\n0x00000000: (null)\n"); + fprintf(logfile, "IN:\n0x00000000: (null)\n"); return; case 0xb0: - qemu_log("IN:\n0x000000b0: light-weight-syscall\n"); + fprintf(logfile, "IN:\n0x000000b0: light-weight-syscall\n"); return; case 0xe0: - qemu_log("IN:\n0x000000e0: set-thread-pointer-syscall\n"); + fprintf(logfile, "IN:\n0x000000e0: set-thread-pointer-syscall\n"); return; case 0x100: - qemu_log("IN:\n0x00000100: syscall\n"); + fprintf(logfile, "IN:\n0x00000100: syscall\n"); return; } #endif - qemu_log("IN: %s\n", lookup_symbol(pc)); - log_target_disas(cs, pc, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(pc)); + target_disas(logfile, cs, pc, dcbase->tb->size); } static const TranslatorOps hppa_tr_ops = { diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 7b75e79e2b..f905a34bd7 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -8692,12 +8692,12 @@ static void i386_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } static void i386_tr_disas_log(const DisasContextBase *dcbase, - CPUState *cpu) + CPUState *cpu, FILE *logfile) { DisasContext *dc = container_of(dcbase, DisasContext, base); - qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dc->base.pc_first)); + target_disas(logfile, cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps i386_tr_ops = { diff --git a/target/m68k/translate.c b/target/m68k/translate.c index af43c8eab8..4026572ed8 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -6257,10 +6257,11 @@ static void m68k_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void m68k_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void m68k_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps m68k_tr_ops = { diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 2561b904b9..bf01384d33 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1833,10 +1833,11 @@ static void mb_tr_tb_stop(DisasContextBase *dcb, CPUState *cs) } } -static void mb_tr_disas_log(const DisasContextBase *dcb, CPUState *cs) +static void mb_tr_disas_log(const DisasContextBase *dcb, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcb->pc_first)); - log_target_disas(cs, dcb->pc_first, dcb->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcb->pc_first)); + target_disas(logfile, cs, dcb->pc_first, dcb->tb->size); } static const TranslatorOps mb_tr_ops = { diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index b82a7ec6ad..6de5b66650 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -16141,10 +16141,11 @@ static void mips_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void mips_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void mips_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps mips_tr_ops = { diff --git a/target/nios2/translate.c b/target/nios2/translate.c index f89271dbed..89b97ef520 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -833,10 +833,11 @@ static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void nios2_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void nios2_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps nios2_tr_ops = { diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index ca79e609da..7b8ad43d5f 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1687,12 +1687,13 @@ static void openrisc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void openrisc_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void openrisc_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { DisasContext *s = container_of(dcbase, DisasContext, base); - qemu_log("IN: %s\n", lookup_symbol(s->base.pc_first)); - log_target_disas(cs, s->base.pc_first, s->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(s->base.pc_first)); + target_disas(logfile, cs, s->base.pc_first, s->base.tb->size); } static const TranslatorOps openrisc_tr_ops = { diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 408ae26173..e0c9f74da4 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7769,10 +7769,11 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void ppc_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void ppc_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps ppc_tr_ops = { diff --git a/target/riscv/translate.c b/target/riscv/translate.c index fac998a6b5..6495726302 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1155,18 +1155,20 @@ static void riscv_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void riscv_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void riscv_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { #ifndef CONFIG_USER_ONLY RISCVCPU *rvcpu = RISCV_CPU(cpu); CPURISCVState *env = &rvcpu->env; #endif - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); #ifndef CONFIG_USER_ONLY - qemu_log("Priv: "TARGET_FMT_ld"; Virt: "TARGET_FMT_ld"\n", env->priv, env->virt); + fprintf(logfile, "Priv: "TARGET_FMT_ld"; Virt: "TARGET_FMT_ld"\n", + env->priv, env->virt); #endif - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps riscv_tr_ops = { diff --git a/target/rx/translate.c b/target/rx/translate.c index 5db8f79a82..c8a8991a63 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -2342,10 +2342,11 @@ static void rx_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void rx_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void rx_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN:\n"); /* , lookup_symbol(dcbase->pc_first)); */ - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps rx_tr_ops = { diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 5acfc0ff9b..1e7f470c4b 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -6660,16 +6660,17 @@ static void s390x_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void s390x_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void s390x_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { DisasContext *dc = container_of(dcbase, DisasContext, base); if (unlikely(dc->ex_value)) { - /* ??? Unfortunately log_target_disas can't use host memory. */ - qemu_log("IN: EXECUTE %016" PRIx64, dc->ex_value); + /* ??? Unfortunately target_disas can't use host memory. */ + fprintf(logfile, "IN: EXECUTE %016" PRIx64, dc->ex_value); } else { - qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cs, dc->base.pc_first, dc->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dc->base.pc_first)); + target_disas(logfile, cs, dc->base.pc_first, dc->base.tb->size); } } diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 43bc88b7b3..f1b190e7cf 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -2352,10 +2352,11 @@ static void sh4_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void sh4_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void sh4_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps sh4_tr_ops = { diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 4c7c7b5347..2e28222d31 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5901,10 +5901,11 @@ static void sparc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void sparc_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void sparc_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps sparc_tr_ops = { diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 417edbd3f0..d170500fa5 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8861,10 +8861,11 @@ static void tricore_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void tricore_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void tricore_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps tricore_tr_ops = { diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index b1491ed625..a9e69c4153 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1296,10 +1296,11 @@ static void xtensa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void xtensa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void xtensa_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps xtensa_translator_ops = { From patchwork Sun Mar 20 17:11:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553195 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp881816mag; Sun, 20 Mar 2022 10:28:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/s1hrSuCD4nRb0LWWTo9ByqD/I978H9scLRjSzvqrDu8kP2rP4bNr3ZnqrbuZ649SIgJZ X-Received: by 2002:a05:622a:146:b0:2e1:b8d5:e88c with SMTP id v6-20020a05622a014600b002e1b8d5e88cmr14076575qtw.472.1647797323516; Sun, 20 Mar 2022 10:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797323; cv=none; d=google.com; s=arc-20160816; b=zYHfgai15et8USbtAxic/AkCUTHof0nGt2LOkerw7WXSFwkqsUEgn/Fn4jb/JfrdS8 1UnKiNkob85bItxODAi0oGBBhYYCbNslTP9I/aJ38yy6HAUG33b45SC5tVxcD9EvPcZQ JVHevWhG2G/qhhfKTiH4nu3Sgn+LtGQnbM0k52h5ppv/PPpn18PssdAJLQ6TeTyZUrvK Od71YKFjcIT4atPFNdbdkw90DaABvQsJUAp4gjrsUAYKvRMOvm9h2hG9Vq2qoGTD6LMC cYEQZER+aXIFxapEM1YxIx/6Pk7aj6bKjCkmHSnbdMHWhx0vNXWFu1L524c2kaaWFwps KJRQ== 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=fCluu6SAceuICVILsHlila9mg06bMaWRED/sDhgyEaA=; b=eRkDLGzRM+2jvc/e9rLRIaiDgVHORtlqpnoSabW6m0leeyJYJ5QeMJeodtFEOOkeSn Ogq9xudAGa+EYG9e6vzwATFKUDhjmS+dYs1xkN3dS47pIVd8W/dnZhqTRs7I11yf8+Yz AprC8hE8Oi83ReS9C7jOPsO6Nji0+/UCCRL5GerMfie9cYB1KDIIA1OOjlJ0TSVEYjsd CrE9w6sWBRko14KoqS0afaYi41bjMP7pmXfIXLRCY2HUSbF2zz5ygKm2rFnnsc/WnFjH zd2/b+dteMed/fYJ9eGi4WHlSqA1A4f7KllM+4XCrbOlt3493Hj2ButLjBVwzR+wBvhd I01Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yyfXStKL; 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 a5-20020ac86105000000b002e1fbf3c0basi1382104qtm.683.2022.03.20.10.28.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:28:43 -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=yyfXStKL; 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]:60040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzMB-0006ag-3Q for patch@linaro.org; Sun, 20 Mar 2022 13:28:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5v-0008U2-C8 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:55 -0400 Received: from [2607:f8b0:4864:20::630] (port=33610 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5r-0003S5-At for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:53 -0400 Received: by mail-pl1-x630.google.com with SMTP id t22so10919148plo.0 for ; Sun, 20 Mar 2022 10:11:48 -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=fCluu6SAceuICVILsHlila9mg06bMaWRED/sDhgyEaA=; b=yyfXStKLgRELxO6ob4by7e4wGGY+wkFkuV2GEEVIw5N/v6eSmUlxU84j0EOhzFyA3c BKWP56k7iVZgPD3aJodfB9EbXWTSGIbWvHbvce1c24xvrYwZoxU7n9nLsIlQ83eMyj4L HMCsfndQgAoMApxSy2x0ZwBmGpDP1Z0pH6N4BV4lxZKlbJptc8L375/KGw8vOBBUQm/7 LW4/1ZIP+rDzwVQzkYjJE2U04CQgAUzMc2FrG0opkVNhTk899dfZR/FOFWE9Lf+c28Z2 gY0fxCbtjPbVpdNdgN5qOxG24uVl2BPmlnIqEHkPLJDoBE0EJO3Hoy6kzrowtLZHUb9+ QQ1w== 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=fCluu6SAceuICVILsHlila9mg06bMaWRED/sDhgyEaA=; b=5jCP31eVp1ZSc5JkUrIDi4SphF2zKraWALFjVDzgOilOue6HcrKw/JdliTzrR2WTZ+ sxz5FKT1DL+NN5Auuqiu1ZADQw63f23zuTe+oqEvlCzu0hUBbA7ZtZ/FpEDd0GufzbLE jurdNdgpNYf18i9aSDQrdU5TCUx1G+SCP+J5eOAMKQTQUIEu8Us52oCdXRblx2yrpIRv 7MSgX2lJPCcB6SkM+lP4SP+04Zl0aW2QVakxB9ykh82qYffD2+7ofZC3IlHvDvNBDDcl ZAJZQCSZ5eTPR12qZlkqknxY+XAF+ZzYqKvjLArju+/0/E83Y9wpcHAhKc3kh7E3OMZm /sDw== X-Gm-Message-State: AOAM5301qkcqntEOzNWHeTsvnTYe5JvyDoGIe4EPFSvjJRuTo4MbwluB omqLWZNWlOpenR3nXCMVQE9Z01+NPsSPHQ== X-Received: by 2002:a17:902:ce8a:b0:154:361b:48d1 with SMTP id f10-20020a170902ce8a00b00154361b48d1mr6401406plg.72.1647796307722; Sun, 20 Mar 2022 10:11:47 -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.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 12/36] exec/log: Remove log_disas and log_target_disas Date: Sun, 20 Mar 2022 10:11:11 -0700 Message-Id: <20220320171135.2704502-13-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::630 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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" These functions are no longer used. Signed-off-by: Richard Henderson --- include/exec/log.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index 6a53199d44..d131a3140d 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -43,30 +43,6 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) } #ifdef NEED_CPU_H -/* disas() and target_disas() to qemu_logfile: */ -static inline void log_target_disas(CPUState *cpu, target_ulong start, - target_ulong len) -{ - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - target_disas(logfile->fd, cpu, start, len); - } - rcu_read_unlock(); -} - -static inline void log_disas(const void *code, unsigned long size) -{ - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - disas(logfile->fd, code, size); - } - rcu_read_unlock(); -} - #if defined(CONFIG_USER_ONLY) /* page_dump() output to the log file: */ static inline void log_page_dump(const char *operation) From patchwork Sun Mar 20 17:11:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553179 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp874219mag; Sun, 20 Mar 2022 10:14:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymfVjJuRQLPtxX6dphLmTL5A5KxED6MrwR4xzUDgJ/eB3JzqMsw3z3x+8+7tKCdIfFh0bv X-Received: by 2002:a05:620a:13ab:b0:67d:4094:ba1f with SMTP id m11-20020a05620a13ab00b0067d4094ba1fmr10798606qki.567.1647796452852; Sun, 20 Mar 2022 10:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796452; cv=none; d=google.com; s=arc-20160816; b=SRCjvhFkKlC98jLW/Mgv+Qig++E7FWi6E23O733uEp18M3gfb8ih50aM4U/9kgFLOv QgMH4lyC62TBoQ88WlGmk0CouJEFjTvBCqi9OCbZXz4GvJe+XworcaTwm3WQYyQ2EeL2 ZYk9DMbfQ+LvhSSrEkoeVINulU+PhKXANnQ/pdHnQGofQY5pNbaLMtf6TTlcHYNk20j2 dhA2edwPIohmmiWlaS3AynusimX/DEtiqPI7QsDO3x3rEIfshXWy7fhWgDqy/f336O/F 0xnBhFQCW0tseGzknVqHUfRvTV4q4Y+KsMonxhbV3ya8VUC9rfOQfl2EFgqZDHbY1SwG /WYQ== 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=45VpLy6jFhpJxRzAu/NUCd+ixVE/bvEmVYHxJFdcwEI=; b=G7d50W5O5mw8rD7mykrHh2T2va5E4VTMD3wqyHXi3vuAoW3tN4viOGybEPJtKBM9g1 wTpaZqyYuPSZbQ8hwBBnpcZ4EpK4Uu7r3EjjG3Bn+pIUS3CUit7oWcY5f0HD4jYHrUJ1 ffwEmI0PIx6vKf4vFILUwWoLC5Y85qVkcrBp/iBzq3UOzT09kQXRcbBP5ggxlrqdPY1b SkuVUVrxQCreMo+TUNluSzAdnHUO2kENgQkJFLRaP1KaJl32I2BVHdpvBprsqrPt/gbs TwnCzA0vUyS+tIU51b4GuVQ1zcgjFeCiO2vQ/kK6Z+dJRrMoFVdiVeEU5M7HWKhTmbYl TfvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AqI/QYvs"; 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 11-20020a0562140d4b00b00440e46a7c18si1351741qvr.182.2022.03.20.10.14.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:14:12 -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="AqI/QYvs"; 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]:53912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVz88-00007e-Ea for patch@linaro.org; Sun, 20 Mar 2022 13:14:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5s-0008Qv-Nx for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:53 -0400 Received: from [2607:f8b0:4864:20::632] (port=38695 helo=mail-pl1-x632.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5r-0003SE-AV for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:52 -0400 Received: by mail-pl1-x632.google.com with SMTP id n18so10885288plg.5 for ; Sun, 20 Mar 2022 10:11:49 -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=45VpLy6jFhpJxRzAu/NUCd+ixVE/bvEmVYHxJFdcwEI=; b=AqI/QYvs1iFbSj6GhvU6rcWDKefh9916SfT7qzjRMFTUTGqmxe+lcZX+B6W1+8Mtn5 5IdZhMVGEcLTLG2SHg2SxIubRoJ+cE3/LJ1qG69zl9hy2YBVTpru9fEU9+L2Xqt2kOfk Ut0NiYTvjgZHILqj9QmB1vqwdg8g9X1/KnjQNEFNmABz9JhYJoiCsJQFHRFw5nWWNw64 smcvfzZ9uT1k1WFEtyJLBXAMcJCj0nPL8OMjk5VITNRtVGCQC0y0gOYnoJcG192lhRQm VnDGfg0QhaaVlRUrDLVjRdX5L1KzrQbLVD8hnuBaFy6F+aXcon2x2zEKfOGLu1l5+0Ix HEJw== 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=45VpLy6jFhpJxRzAu/NUCd+ixVE/bvEmVYHxJFdcwEI=; b=nbOopZ5GUk773eUvoQJvBejEhw1Ymrqhj9frvV3A9BJ9ZRVoIyP0z8iddlz2oYX67C xchxDxnuLQBksk26uD04RNWwtPDH/ino00U5P/RWiC2D7KYyChX++IrjFlqKpsVwAjDo lMy0qjY0DfDVwkdz7V00arY7vSthKRE5itHqq+NFeq5itjphVzGikDanEuDJzMI0xo7T GxfCdzJYDb04wK2kY2VeXleGYiBcZxAvrH0UEWILL3aJwvQUNYi8GDci0Ud6T4Vlp1MB SxlD55+ZV2y4Cgt2BMcDJaFVAvaBieQQfgTxQP+Cy9nFiXpMaeSyw14XnnE+gXV2YT1m EBBg== X-Gm-Message-State: AOAM531FHpka/AAAXqushbyWLmGqVa6/bJMztJ2/bf50+3duoD0LuDoK jiq1vOezIKQlJG3LzFh4f5KUEp1K7+UASA== X-Received: by 2002:a17:902:ab10:b0:153:b520:dbbe with SMTP id ik16-20020a170902ab1000b00153b520dbbemr9314935plb.55.1647796308606; Sun, 20 Mar 2022 10:11:48 -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.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 13/36] accel/tcg: Use cpu_dump_state between qemu_log_lock/unlock Date: Sun, 20 Mar 2022 10:11:12 -0700 Message-Id: <20220320171135.2704502-14-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::632 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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" Inside log_cpu_state, we perform qemu_log_lock/unlock, which need not be done if we have already performed the lock beforehand. Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7bc489101f..8b7d6ae9b9 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -225,7 +225,7 @@ static inline void log_cpu_exec(target_ulong pc, CPUState *cpu, #if defined(TARGET_I386) flags |= CPU_DUMP_CCOP; #endif - log_cpu_state(cpu, flags); + cpu_dump_state(cpu, logfile, flags); qemu_log_unlock(logfile); } } From patchwork Sun Mar 20 17:11:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553189 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp880696mag; Sun, 20 Mar 2022 10:26:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF/+vTt9Ayvq92wxNjwb1w/DxJSgSwZgW6A+EfI/8KhwXtXxkrjm++U18MRU5lwiTtJTW0 X-Received: by 2002:ad4:5bc1:0:b0:42c:37be:6ac3 with SMTP id t1-20020ad45bc1000000b0042c37be6ac3mr13849507qvt.18.1647797188510; Sun, 20 Mar 2022 10:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797188; cv=none; d=google.com; s=arc-20160816; b=oN+WhuyU+hPp+Tox6ha6FSuS8h7lI9YZaiUZlj2IwQDBsCIerszmq+GRjEFEAHPYry PZtrqgrIIgFusHAiPKQDHCVVaXbEf977Q0hqSdOFkzwMurb8D8jREWpFG1WFuCwmft+8 mu6aJw0BJYkmXKoQQM8SuUw638Y9dUEWGvoIFjAL75orl8rCNHi94fQAb1wpsr+3u5+2 0JQWE/2PoEcneW/Am30CpEKCk8EtUfytWiy3lWep2dTBQ5L1veOOrXFUAcBTvwNBTpMV qPDlWqJZ3wFwi+3soMaRhPmPjbhxjlzoWRBQTIaBiYpjTga96pGumaF95EeSCowmzbyS adWw== 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=gN673K8AiC7tUSgFbelgmQvdK3DgFVdFgWV8e2JASA4=; b=tqlkI3iypEl1E5xpzEv+RvVKhQTmqaKt/ve0Jgz5mozVuFFe1yuryFxW0ou6/gth3Q RT2eolYwEIoxRfoDJKPyNJTP+NrGFUUMkWptz8NNeCmliuP1fumAwaEZg3gwgkKQeW4U x3A0exeBVltQLBtd0lBI2GCJARVp5/ZVFeWF6+G4ApaWXkunQRm+7Zk+7ZFo9aG735lG H/Faq5piQ67YSmaCHRa2eJLNc1Hr3z8zDqK5HVafCCZBABkwPG7fnLvvfSy8N+/IfHi6 4067fkarlfB5jqBjrJTRs9/Ku3KV3alLj9lPc0b3dM1oVSprw4zq2UpnInKqqJdwSkj2 Wtkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vyd/vnm5"; 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 18-20020ac85912000000b002e1fbf3c056si1489404qty.583.2022.03.20.10.26.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:26:28 -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="vyd/vnm5"; 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]:51372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzK0-0000js-1N for patch@linaro.org; Sun, 20 Mar 2022 13:26:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5v-0008U8-Dp for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:55 -0400 Received: from [2607:f8b0:4864:20::62d] (port=42803 helo=mail-pl1-x62d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5r-0003SI-Ay for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:53 -0400 Received: by mail-pl1-x62d.google.com with SMTP id p17so10876541plo.9 for ; Sun, 20 Mar 2022 10:11:50 -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=gN673K8AiC7tUSgFbelgmQvdK3DgFVdFgWV8e2JASA4=; b=vyd/vnm5J3FNcVJHa610l2KBke3GWQFNJd18+GQ3c66b9V5FOW7qkRjP+YTOHmx6F8 NRPRhxrQDGPw6l7NOXRPvFK7tj5YOW+H7AH4Nkxucm0wSL+VvahhzLw90mdeToT2Lwkn ZnjacEb3PjPW/xvQZA+WdEtsGl+QguL8NUvb9gvwqmaUhDhqMGO+sY1ZL3YHdZlreC9d i4fXuOdFZk5N23cJO8Zm4Mhd490d0ey/QY9t7MW5MbS6CezvsDSed5NHKOnKxYexkt+5 0TUeVufhPm/zz4VCI+8RFtKjvnOBoLTqGNBiIYjoRCVQWCchCX7j3weZp0rZYBZe1hbA bpVQ== 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=gN673K8AiC7tUSgFbelgmQvdK3DgFVdFgWV8e2JASA4=; b=smTwemENyfsSpoEhoHmOVyrp2wi/8C/Mlrm3TBoTYTQ2KJI77kaNaxRFGMJaXE9cda Nb8EXBsQ362OI4U/pSYBfRxIFbHif/zW+/4/xTLGWBCxVZg3kMUfAbCD2I1Gla7OMFVS d5tLGrA2IL2unhpAfw/y7EzH5SU2VEW/F9ZV0319vwerMDRWhQFi9CUlQPF5es9wR2lb aRSyrfq9Arwouee+pXk99gbtFocMccGto/lj9pT2+yDrc6iEDhV/uQsDnrE4rWfn1DiW 3e6N+bskEANDcUAwQMLMd4O/DkYiq8t047S00ha3kBnNmvB9VRbDRmziP1OLgfps3anK Q/Dg== X-Gm-Message-State: AOAM5326rjLh3XpkyzbVgitJyY4AvfwJf3hl6K3q5nMKh8AExVk/pzqh WkIHOxVazB3yKm/dZ3GZvzoz2Hw9EVgFAw== X-Received: by 2002:a17:902:a38a:b0:153:c6e:4dea with SMTP id x10-20020a170902a38a00b001530c6e4deamr9162477pla.110.1647796309426; Sun, 20 Mar 2022 10:11:49 -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.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 14/36] target/nios2: Remove log_cpu_state from reset Date: Sun, 20 Mar 2022 10:11:13 -0700 Message-Id: <20220320171135.2704502-15-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::62d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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" This is redundant with the logging done in cpu_common_reset. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/nios2/cpu.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 6975ae4bdb..b0877cb39e 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -46,11 +46,6 @@ static void nios2_cpu_reset(DeviceState *dev) Nios2CPUClass *ncc = NIOS2_CPU_GET_CLASS(cpu); CPUNios2State *env = &cpu->env; - if (qemu_loglevel_mask(CPU_LOG_RESET)) { - qemu_log("CPU Reset (CPU %d)\n", cs->cpu_index); - log_cpu_state(cs, 0); - } - ncc->parent_reset(dev); memset(env->regs, 0, sizeof(uint32_t) * NUM_CORE_REGS); From patchwork Sun Mar 20 17:11:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553187 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp878681mag; Sun, 20 Mar 2022 10:22:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiIbMdEgd2PXHowCTNrGn4XZe8ARm7QGIukFml6fEgbXZ0Je8O6ouv2apEazpt/bmDTm0Y X-Received: by 2002:a05:6214:c49:b0:43c:dca9:b55e with SMTP id r9-20020a0562140c4900b0043cdca9b55emr14233194qvj.102.1647796943974; Sun, 20 Mar 2022 10:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796943; cv=none; d=google.com; s=arc-20160816; b=0eoPiMbXDcqUg+wbhWJHoj/krdp4LGY0H8zDV6qTy8d3ZOXj2XUzTPdUkK6DQGjZ8k 5pA1oEQMCnBRzxY8VlY01+qk66ZwKgV5vUtVE99mg3m0DBuUEHMfp+mJKn5d1xgDbs0O wk16kA2K2MD4TzS2yjo8XjMMe80deuzXPu2HJYtnDo+0wMGUKEmAX9t4nT7vDw5AlTg2 Nt/y9LLZ7WgW5qn59ArvZi0xuUWkK1WTILwx0nD8MdqZFDZD/EN6tc2DFO7L/tTMtLuL 4lF6pO1gilNqVrLG5CxPMgIopKTgpUNoWlecUvJ83rEOWciot/hiFN31X6QwU4ZqHO72 xbjQ== 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=nPJER5VpJQWDzK3DbfrzuAnOWSXda5Fj/5jRAuARZxU=; b=c2TI7X3/J8OJnXP4Lw9Y+uasKZAb2arXEymqczbOozoxvgmU95ZkNVGrU5kHmYQcO8 mJKddyz8sL0cdImxJd0FDrGABsoCX1MpUc8zHgwfYcWWjfivrUtdpvwpRdll3WnrJk5A Wq+MIn1PcW9xHertyMphuQo8ikTMt+Cpq1LcickohSFuT2TnUwUAaDnPEqge8t6xWojv XQpRE1pvzDdSevSefuNTEDsdDWOw0e48egUWe7EyQ8XdUZXksPfcGMk3vqjCVbnhaqmj z97cAKK+6JQuJyVuNIobkCddxM815qcJzbEGahx8m5UmUvC+T6ErpCmmIC5uT+LBjITM XDKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mI+cOOnt; 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 cc14-20020a056214044e00b00440e46a7ce0si1279852qvb.382.2022.03.20.10.22.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:22:23 -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=mI+cOOnt; 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]:42760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzG3-0003Pt-H3 for patch@linaro.org; Sun, 20 Mar 2022 13:22:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5v-0008UD-E7 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:55 -0400 Received: from [2607:f8b0:4864:20::1034] (port=33973 helo=mail-pj1-x1034.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5s-0003SR-2v for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:53 -0400 Received: by mail-pj1-x1034.google.com with SMTP id o68-20020a17090a0a4a00b001c686a48263so6075212pjo.1 for ; Sun, 20 Mar 2022 10:11:51 -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=nPJER5VpJQWDzK3DbfrzuAnOWSXda5Fj/5jRAuARZxU=; b=mI+cOOnt9YT5V5agfVxk9gCjYvnKZCLR2ij/AGdqfuc8751CE0moLz3d7ErkQKbolu sybH+W/s67DAyhWYHSm5YechTSHkh6MhP7MueJJv/GiFjqZ650NVf7Pny3PPa6b0h+an 82wouplwImGIhZ7er4VNem3YbnU00TKuEh/qUSXGgrJJisEpK8jmJhO0tEjjzjYoIkX1 Om/GcFgNVkzvAsk6QsXg0Y/BFNoAO/7RkVkqYNLiFHHj/U0KQwv17YHI/PQe2KgJw1kq 0HdzEP+SIeGFn8oRmTRymE5BkMvemKGW8jLYRxoKaGjSKm+mL468l8YDf9RkA6nSugvk 2gLw== 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=nPJER5VpJQWDzK3DbfrzuAnOWSXda5Fj/5jRAuARZxU=; b=QeXSZmCiWRQbyM6xJEVH+8DoTbRSq6Eey1RX5BIyvlK6XYFVMrk1HuznBBYyMiG71y Y5nZJSpHRpR9XL+0aMrdBsIciIy3eZtVno7iSdAt/3iLvgG5/KE3xArlmGUaFOl/moqP qE8RbROctsrmdsTVO4SL4+oZuDT8gxyGeTRtaCadGWLX0GsLUV1GjVHhCi7jZL0p604j z8swQvYGg1nmrToz7VSdbjNd4OXgYV/asEcXaIHYqygnwWemdElopFQM3CrqZN649s4/ 6hbkMakzAv4LSHx7EutiEOFA8gvrhCUawDs+3gDnpd6FbOPvyNYtJHqPlA5KC4qIH/J5 2dJA== X-Gm-Message-State: AOAM533G3hmofMlvepG+8eFMia6plZDxyyOcVjVyKAKRID43xsVqa8u6 BDTxWBjErqnsOGb1SHDF6SPPAMWZNHpDeg== X-Received: by 2002:a17:902:9a46:b0:14e:ea0f:28cf with SMTP id x6-20020a1709029a4600b0014eea0f28cfmr9138390plv.43.1647796310392; Sun, 20 Mar 2022 10:11:50 -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.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 15/36] util/log: Use qemu_log_lock/unlock in qemu_log Date: Sun, 20 Mar 2022 10:11:14 -0700 Message-Id: <20220320171135.2704502-16-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::1034 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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" Avoid using QemuLogFile and RCU directly. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- util/log.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/util/log.c b/util/log.c index b1651d8122..3ec6e90575 100644 --- a/util/log.c +++ b/util/log.c @@ -62,23 +62,22 @@ void qemu_log_unlock(FILE *fd) /* Return the number of characters emitted. */ int qemu_log(const char *fmt, ...) { + FILE *f = qemu_log_lock(); int ret = 0; - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { + if (f) { va_list ap; + va_start(ap, fmt); - ret = vfprintf(logfile->fd, fmt, ap); + ret = vfprintf(f, fmt, ap); va_end(ap); + qemu_log_unlock(f); /* Don't pass back error results. */ if (ret < 0) { ret = 0; } } - rcu_read_unlock(); return ret; } From patchwork Sun Mar 20 17:11:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553183 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp876484mag; Sun, 20 Mar 2022 10:18:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbuNTPLhkGfD8oejeI0+4VmrHqhdla+YuD5uL80rdvKT6vyj0NSZ1h9XKzbTqUPXEpwSrO X-Received: by 2002:ac8:4417:0:b0:2e1:a82c:1a6f with SMTP id j23-20020ac84417000000b002e1a82c1a6fmr13659501qtn.375.1647796705890; Sun, 20 Mar 2022 10:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796705; cv=none; d=google.com; s=arc-20160816; b=joyk41vNb9ewztYoG6uCaPviqbnQBwHlrB0VzgmbQBk3kJDsxaBw59YQGmdp14lqaN 4irSxgh2WJUjKrqs/XIHEkx9O2XwE8jqy2UIMvFORZDGWRBbnlT4cSlPxCCWUUetgrUb /QTqXnm6Hp2ZeU3/BS9RW6h8Ci0UMGAORaqTJ/ybzOsqKGgoEtVaQgX4m3m9kW37MVfY XjJRjO4UADNmylfJK9Mj0sL5AN8RazjRN/2FHg5Jo9cM7wftv3gB3AQMG1MOBacGhs/B h3ofLBYH+my3miz9/5EbKRRljUWmi5y7dVMUUboddv7URbiWwrBYVrUeNtUI9nRZncji AT8Q== 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=zBy/sQij0prDNPCZW6KqDJ1PqyHxGR1GI9KNvJm6bVE=; b=M/WxJOTqIUXQeiWGXhNvuyCujdtGPOOuiUXKo9Rg/n+D7HYJtXd26VHdJJOGYWTKek Go+KrhWPAHKo13IvOJp+tDcjnChwusKm9FffMZaC73jCi9v0BhkWbbRr0jHO3NZopao+ qDSNap4nwjSpuf/CMx86xmjE9qcXkqozvDdmuFUBwE1VK/ebOUzYgQh3K+guj5iha09w h2lYvrzd+f6dYUIJVgMJt5b8dcz5zrhbi9UkJagVqx8Jx08/eq5zdZDNf0cWJVXOonQj uIo8a018v8p86G7vDvOJF/V7xsncCZiBvFNpaC+JzGzVLgrmj72MlBP8zL+lVcCsDejs QDsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D2ElIB7B; 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 m18-20020ad44b72000000b0044105f365e2si1271054qvx.569.2022.03.20.10.18.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:18:25 -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=D2ElIB7B; 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]:34156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzCD-000633-E6 for patch@linaro.org; Sun, 20 Mar 2022 13:18:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5v-0008US-FI for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:57 -0400 Received: from [2607:f8b0:4864:20::529] (port=33513 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5s-0003Sg-H5 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:54 -0400 Received: by mail-pg1-x529.google.com with SMTP id 6so8741718pgg.0 for ; Sun, 20 Mar 2022 10:11:52 -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=zBy/sQij0prDNPCZW6KqDJ1PqyHxGR1GI9KNvJm6bVE=; b=D2ElIB7Bosv8Yx3dNUnf2GOvHXX3BI07A6j3MD3Hyk7jCFXvoO1l2oMbpzKQ/hEtGf uSz39pffNmCr6IRMzHjQ7GuBNIgTiUuIYpWpLcO1GN9tyC9nE3S5s8xz8316ltRb9dN6 vfeyaveGPS5vT0o/vI5d/Ep1tJkuJsvvFJy6sFAUtPOojIIzr6knoLQVTCE6lSTzqipt FJZl7mMGwNfVlKbBYKCr5SpMkhH96WwAB+uNyOe2dvaZIr/5KvnPCqeI24FkSDmYu+C9 eWm9EBBSonZWIINQeb7TNOVc8N6B+Wvdn/w3JsdoIXRIF2e2evZ3BlpxePjhlc51rMUh ez7w== 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=zBy/sQij0prDNPCZW6KqDJ1PqyHxGR1GI9KNvJm6bVE=; b=EKYQz+WmzS3IMf3celEmZRFMo9sa0T2vJDe5IpwUsSCMeT0rx50D1Cpd3iPhBrpZqS uiDkfjexCDHpwiamdrJXCADO7HP43cO5zM3lwqOfLdhSQybeGuHMXJVWHrTRLE1Z9Wjm 3+9YpsqVIEVNnmQ1dV8lMlqxrttmSTihJvWkw8gksRA5ny5br5ilT3ytiJlg/3uZgJCg VQzkCfr+IiY/PpDwWhTp5UPDlKGGe7SlF5gbVFMUSqPuYAlGFPuUY1JYvqTW1BCcjDhh Dl5bc5DD53Kmt8RFBDqaTMyC5+0T+GdEzZhgbxWH+S1zo1M99paF5Tz5xv1t2ghIo6DM L2jA== X-Gm-Message-State: AOAM532vHRba8p2O1h2ZlqdTo3zH53Nt/cjldRw4sHeNxNNhHDD7OcWJ 1kOPcEdz7YSDjzuraxcfEyZm7DdBW/Wgiw== X-Received: by 2002:a05:6a00:ad2:b0:4f1:2734:a3d9 with SMTP id c18-20020a056a000ad200b004f12734a3d9mr20343057pfl.61.1647796311278; Sun, 20 Mar 2022 10:11:51 -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.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 16/36] util/log: Remove qemu_log_flush Date: Sun, 20 Mar 2022 10:11:15 -0700 Message-Id: <20220320171135.2704502-17-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::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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" All uses flush output immediately before or after qemu_log_unlock. Instead of a separate call, move the flush into qemu_log_unlock. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/log.h | 2 -- accel/tcg/translate-all.c | 1 - cpu.c | 1 - hw/net/can/can_sja1000.c | 1 - hw/xen/xen_pvdev.c | 1 - net/can/can_socketcan.c | 1 - tcg/tcg.c | 1 - util/log.c | 14 +------------- 8 files changed, 1 insertion(+), 21 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 6e45b31253..10578ba21c 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -121,8 +121,6 @@ int qemu_str_to_log_mask(const char *str); */ void qemu_print_log_usage(FILE *f); -/* fflush() the log file */ -void qemu_log_flush(void); /* Close the log file */ void qemu_log_close(void); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4af7455522..837f50f5b9 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1595,7 +1595,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } } fprintf(logfile, "\n"); - qemu_log_flush(); qemu_log_unlock(logfile); } } diff --git a/cpu.c b/cpu.c index 159d0b0d1d..054f21b307 100644 --- a/cpu.c +++ b/cpu.c @@ -405,7 +405,6 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) vfprintf(logfile, fmt, ap2); fprintf(logfile, "\n"); cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP); - qemu_log_flush(); qemu_log_unlock(logfile); qemu_log_close(); } diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c index 919e93664d..3d144508a2 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -260,7 +260,6 @@ static void can_display_msg(const char *prefix, const qemu_can_frame *msg) fprintf(logfile, " %02X", msg->data[i]); } fprintf(logfile, "\n"); - qemu_log_flush(); qemu_log_unlock(logfile); } } diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index 355bbda60d..9095080b0d 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -230,7 +230,6 @@ void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level, xen_pv_output_msg(xendev, stderr, fmt, args); va_end(args); } - qemu_log_flush(); } void xen_pv_evtchn_event(void *opaque) diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c index ae19d35001..47743e5fd9 100644 --- a/net/can/can_socketcan.c +++ b/net/can/can_socketcan.c @@ -88,7 +88,6 @@ static void can_host_socketcan_display_msg(struct qemu_can_frame *msg) fprintf(logfile, " %02X", msg->data[i]); } fprintf(logfile, "\n"); - qemu_log_flush(); qemu_log_unlock(logfile); } } diff --git a/tcg/tcg.c b/tcg/tcg.c index 1e27367af6..e5d45eca9f 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -783,7 +783,6 @@ void tcg_prologue_init(TCGContext *s) disas(logfile, s->code_gen_ptr, prologue_size); } fprintf(logfile, "\n"); - qemu_log_flush(); qemu_log_unlock(logfile); } } diff --git a/util/log.c b/util/log.c index 3ec6e90575..73597c40c0 100644 --- a/util/log.c +++ b/util/log.c @@ -54,6 +54,7 @@ FILE *qemu_log_lock(void) void qemu_log_unlock(FILE *fd) { if (fd) { + fflush(fd); qemu_funlockfile(fd); rcu_read_unlock(); } @@ -277,19 +278,6 @@ out: g_strfreev(ranges); } -/* fflush() the log file */ -void qemu_log_flush(void) -{ - QemuLogFile *logfile; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - fflush(logfile->fd); - } - rcu_read_unlock(); -} - /* Close the log file */ void qemu_log_close(void) { From patchwork Sun Mar 20 17:11:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553202 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp885208mag; Sun, 20 Mar 2022 10:36:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVIvrPlWeav04B/1hTF/30Oz3wC6JIFwChGvqe3D5uMxjGF7XYJyzMOY3TXvIBOC9toYKK X-Received: by 2002:ac8:5c84:0:b0:2e1:ceaa:d134 with SMTP id r4-20020ac85c84000000b002e1ceaad134mr13540470qta.247.1647797774690; Sun, 20 Mar 2022 10:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797774; cv=none; d=google.com; s=arc-20160816; b=tTg6LvXoq3Ro0AoXqsa6yg6UU3GCFfbzKOvI5F0+cKCEU/DfLavq8dBtw0avwSbXEC sMgusyJOr/VcgDk15JrKoL6E3r/w0+wS3sEsXalHSoyyIMI5BwfvuMC5uKzz8Fa+1to2 edl8r1UIaukQPSnxliDkH08C/T8f1AX7/hSMX5XL8B6pB06hzSQ8guONTuP1NlJMoHNW 31rKfwM9jgyToBcKlH8ib4lADiPupbQgYwPrtvotKLVs9ZDvaTKIB3DeefckSae+Odna j45xaXodP02CJWHx57SmRadyejdLTrHHAmk8qOkBxfMQKzcbiWsRYWUtnWmCiskD1FHr hyjQ== 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=WUo/UXugquCgKpGx2VP7SOTX0x7aIWwccomkB6QAm9Q=; b=ApETcB4wZChmdOXp5w+jNT6rwq1Cemi26K2az1vXKlnno49mALwNOM6cK5/wfHW8lw 8CgbUUDwsVN8oQenpz3LFe/1MvcBQ5pNpEUcpwmYG2S6u7iIWV8ayXlYmzNrK0oNSL6S DMHaDQ9CCiDHwJVu8QL437nlib+GyFFAWw2WA/ncHV9NMfW8rl2JW+bPwrydRqRhfggj WG4ytzQhXEzHlvvmBgcUl/iE3ZHiDHiMjXtBkv5pDMDO2YJf9PGmo7ib+TYgDKbX56I6 bJ0pv1fmNT2EaZM5tFWoRPZXs9krg8ARnUlac0pP7LhTnQW1Lo0F56sNRpO2NPgI/rsO ebxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lR7xroze; 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 w9-20020ac87e89000000b002e1fbf3bf1asi1521314qtj.267.2022.03.20.10.36.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:36:14 -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=lR7xroze; 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]:48936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzTR-0001IY-Pu for patch@linaro.org; Sun, 20 Mar 2022 13:36:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5x-0008W2-CO for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:58 -0400 Received: from [2607:f8b0:4864:20::52b] (port=45993 helo=mail-pg1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5v-0003St-3j for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:56 -0400 Received: by mail-pg1-x52b.google.com with SMTP id o13so8738104pgc.12 for ; Sun, 20 Mar 2022 10:11:52 -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=WUo/UXugquCgKpGx2VP7SOTX0x7aIWwccomkB6QAm9Q=; b=lR7xrozeJMnsVVDvJU+Wu9VdwiRnknyIPcGLcXTET0IivLgLR8vHlWLYb6Y+PXr9sl 3bObCfPTT/XUKq5qcBwE7QpjaXjlN7IUxQQeXtIBm9m3vIomdaAXdgw706pEfmpj/jmQ 1Gc620efJ7g6GT/GoicY40S1zaWPKPRLLSTVhct6e/3DEymC1DnM86UMHwceDjJCdi8L xzVyWqbq7nvPnNdoalTgmXr+Zh2ddG6Q8RN/75WDQG9Gx21laCrf0FZKlpF0i8h71nn/ ijjih8ypzFTDftXRO7H7bg4kglVU6UMnPc+rmtp9YIFEE+EFA+c52FNZUEBoQONMmXZf z6Fw== 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=WUo/UXugquCgKpGx2VP7SOTX0x7aIWwccomkB6QAm9Q=; b=RnmxuyQdVjSLCab/3OvckPWWU0orz47702uZIzuWLrkDiqajCtwhJEo8eIW6eoPWRG D6KDAvHUDVICn3hRSAhiAm48sqx1bOuBNuEs41uZUuV5tx5p8jD+8N25nofqC5Br7MYq UrBb+Mo5/AP9oG7mUn6/sK4dzJADH254cCeDbxxGpUSToUULEjAtdpJz61GCSadtN7JY BPZvkdp5psUuEwwpRw1FfR7t7L4QxkBnH+vCBBnQrssVOrCDM+tluqPK+ijd5AJlC24D 5GdHzBpgG7cdANUEZgYNE1YbyzD2nKjuDIuHsRwfaEYMFvWmrGGLqPLks7y+Q5CFGHLL ao9g== X-Gm-Message-State: AOAM531A0BxUk5dbPtg0ex9fUSQ8HFyQGgdJKOY779LZ2B13l7vnlAuV zbCzKBzrKW/cW66Rbe1JrzfvFsi6cZNQ4Q== X-Received: by 2002:a65:6942:0:b0:378:9365:5963 with SMTP id w2-20020a656942000000b0037893655963mr15235347pgq.142.1647796312098; Sun, 20 Mar 2022 10:11:52 -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.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 17/36] util/log: Drop call to setvbuf Date: Sun, 20 Mar 2022 10:11:16 -0700 Message-Id: <20220320171135.2704502-18-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::52b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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" Now that the log buffer is flushed after every qemu_log_unlock, which includes every call to qemu_log, we do not need to force line buffering (or unbuffering for windows). Block buffer the entire loggable unit. Signed-off-by: Richard Henderson --- util/log.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/util/log.c b/util/log.c index 73597c40c0..be20ae6c1c 100644 --- a/util/log.c +++ b/util/log.c @@ -145,12 +145,6 @@ void qemu_set_log(int log_flags, Error **errp) logfile->fd = stderr; } -#if defined(_WIN32) - /* Win32 doesn't support line-buffering, so use unbuffered output. */ - setvbuf(logfile->fd, NULL, _IONBF, 0); -#else - setvbuf(logfile->fd, NULL, _IOLBF, 0); -#endif log_append = 1; qatomic_rcu_set(&qemu_logfile, logfile); } From patchwork Sun Mar 20 17:11:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553188 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp880628mag; Sun, 20 Mar 2022 10:26:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynnja1ENvzs9ecngKvBwFJMDWcQjYkdMQxEKDlom74vRp2aztxA7MOeuvSVIHqNjUqNV2u X-Received: by 2002:a37:6cd:0:b0:67b:118d:81e8 with SMTP id 196-20020a3706cd000000b0067b118d81e8mr10909325qkg.88.1647797182590; Sun, 20 Mar 2022 10:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797182; cv=none; d=google.com; s=arc-20160816; b=TBV4YqB+hCI9nnuD56BO1l3DWBkyLEYXodxl4amfWU25ekasaxRvuSb9sakBzy1Nsg L9TznAGs74fpoMG6benozaT/h8qNxoWWHs1mt2cqZV1As0UE8qpZKsnPojLQc141qB6y BCLUqWf90k2Yy3XyBT7YxaVo2ozRfmC1je27xp9snkQZa/naN/uNXjupGpD6nC+ayzxL u61DGIS1pYfcKYLlJENyH/E84Jwg8uGGrULTK6Nozd+xwtHA/ovU4ri4/ys5IfdUp+h+ aib4U5bSdMA8sA2c1Pii3gGPc1n0cI0kefNdObVDgeMyU4cw8UBpbwbk93h5FFS84KdM iVug== 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=91XMdGfqxA7BvJwgW6QHFNJ0sL3SZqCOihIKSdvbIRg=; b=tYbt8nmlYX0Lrq4Ut+uPMNnBdvHOOuD0ARBjCVaUXelS4nYSb5nCTbk9oxloVVs/Nq yUoieHdhwoJI35y5upmozS23GZ5SFElIge9N5PLUtBjH5oINHFjEqPioIl1I91mgeNIs ITm3zQhRG94AlbLdRYP4l5BZxNLbtm3qb57Dxxo4KER4AYlRUDTjKE6gUwnPvjWr58kq yngqYlVoICBz6GjEoE1lUKzb9fxW0MWIrzuNBBnE0zjltQCmzUuyEXHcj5LHPX5Zx1R0 f5f5e+lY9zejHhPpMKD4WbawOgm0j3k0wTyG/fuTQnS8Yro5cjRsxnKLFM8eCcnFei6X nLqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GFmnPbA+; 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 u4-20020a05622a17c400b002e203823602si1463717qtk.232.2022.03.20.10.26.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:26:22 -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=GFmnPbA+; 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]:50860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzJu-0000QB-5m for patch@linaro.org; Sun, 20 Mar 2022 13:26:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5x-0008W3-Cj for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:58 -0400 Received: from [2607:f8b0:4864:20::631] (port=42807 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 1nVz5v-0003TA-4U for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:56 -0400 Received: by mail-pl1-x631.google.com with SMTP id p17so10876604plo.9 for ; Sun, 20 Mar 2022 10:11:53 -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=91XMdGfqxA7BvJwgW6QHFNJ0sL3SZqCOihIKSdvbIRg=; b=GFmnPbA+Foj745z27nMHc1bIyzNzpu+5gAxboDYLKfD2eWqq8t2ejszgpHHjphuQIp 85UFuXLN1vISyAGUn3HbTI8efQqqLgNekyzN2PnjSZeF6TEtJK0xqRTo7WdhxKL3uuxO Fue7osoDJ7qsSqNRYWKtKadAVJcqg9l+Rg2TYg2Fj78cEuj6EGZDTXjuyN2Iog+TwOQM ozVwlttJZdqsCscF4SS85pACcdsOtz5Bzf9R84i1rLftxWgj24R4OXMnkdyUq6iD6/tJ POxaGytPu0fw/heJAgVG92+GiPl9QkY3VwsZ61VfB/B8lZgXugeLe43e0kTeqGZ3Dika 5vnQ== 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=91XMdGfqxA7BvJwgW6QHFNJ0sL3SZqCOihIKSdvbIRg=; b=kJWsixn5Eiemvc1IDjpS9uBaHHtPTmlnfUZAFqXhz7L0th41IbNPD/evstr0vZJSlb egvxHJjR0EU7anyy6CuuNWj6o3PhWVvElYhlkcrM+27k8fjakMA274+KxeO8XieErupt 2i/X1NTfl6kCi9TWyj16FxcihNHjvi/XznBxNYY4UT4hW5znVg5gSD0XoIfEIZ2ihrvA B220Rt/kB90DMCYnUoJlT2fqXKF++xIEWEPmEY0xDFxR33JQr7eM5LMyk6QODrMV+1SJ 6t23Xy64mByqlaS6wEEMZ14XiU14EJCWdwmMV34Knb8HhWNrVMFM+5X8rTQGZ4w6caSE FcOg== X-Gm-Message-State: AOAM531uYZNzzk9IQpb7/T3ZDggSyYylWl8fJaaw+pM+TdV76EI5/1Uo 0FXMaYfPGyzhwq9RW/uEx9cooNiSEaLkoQ== X-Received: by 2002:a17:90a:1b65:b0:1c6:5bc5:99b4 with SMTP id q92-20020a17090a1b6500b001c65bc599b4mr25072202pjq.177.1647796313112; Sun, 20 Mar 2022 10:11:53 -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.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 18/36] bsd-user: Expand log_page_dump inline Date: Sun, 20 Mar 2022 10:11:17 -0700 Message-Id: <20220320171135.2704502-19-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" We have extra stuff to log at the same time. Hoist the qemu_log_lock/unlock to the caller and use fprintf. Signed-off-by: Richard Henderson --- bsd-user/main.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0c8aa1ae90..d25d1c6015 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -503,20 +503,25 @@ int main(int argc, char **argv) g_free(target_environ); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - qemu_log("guest_base %p\n", (void *)guest_base); - log_page_dump("binary load"); + FILE *f = qemu_log_lock(); - qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); - qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); - qemu_log("start_code 0x" TARGET_ABI_FMT_lx "\n", + fprintf(f, "guest_base %p\n", (void *)guest_base); + fprintf(f, "page layout changed following binary load\n"); + page_dump(f); + + fprintf(f, "start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); + fprintf(f, "end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); + fprintf(f, "start_code 0x" TARGET_ABI_FMT_lx "\n", info->start_code); - qemu_log("start_data 0x" TARGET_ABI_FMT_lx "\n", + fprintf(f, "start_data 0x" TARGET_ABI_FMT_lx "\n", info->start_data); - qemu_log("end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); - qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n", + fprintf(f, "end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); + fprintf(f, "start_stack 0x" TARGET_ABI_FMT_lx "\n", info->start_stack); - qemu_log("brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); - qemu_log("entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); + fprintf(f, "brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); + fprintf(f, "entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); + + qemu_log_unlock(f); } /* build Task State */ From patchwork Sun Mar 20 17:11:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553192 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp881744mag; Sun, 20 Mar 2022 10:28:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJsgnWaIt6/3yGOExrIpbH/x8DIwwQB+fS27lrP2wwDTQMG2/s2mFJ4x+3nD8Os3menE7U X-Received: by 2002:a05:622a:4f:b0:2e0:67f7:e760 with SMTP id y15-20020a05622a004f00b002e067f7e760mr14076969qtw.155.1647797316711; Sun, 20 Mar 2022 10:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797316; cv=none; d=google.com; s=arc-20160816; b=C3QjRP4Ap00CGDeF7Q3nhRBysFyFBKlwR8aP3xikahqPV3Wn+1Qpid4Moj+bS+4ZFL rok6U3AuTyW9SsCsMq4TlY1TGbfaHR0b/yZjS43S4CCF5v2MMTttzlIbprIMqyZ3kP1w fCcCYmO/7kezQuuQcQFTfH3R2JD0OnlLsu+CUw9Yb7UCVRVvDaelLdpHPsOuyxoS4BFi 6Mw6FUL0F7uYVYIYVVGqIh5n+LeoUXup31LMBYDBlp8eoxUmG7VoM3cGd/Jgc9D+fqAc ApcAr/9Qb0s/ZKQSSF+7ERbZrZI+/yJ8pq7S5xNo/gybk6Xnb5SYWiqLvpLbbaQ/0Tx4 LArw== 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=RfLYamEZLpY31Sx1p2zuEUJmtGPv8qgDD0cZ+FUaGoI=; b=iDKrNDuOFlQ/x20TWS2DJkxvkKSTdb3RlZ3WhWOMTrrkdPRwWq5iumI21Z0wISiwQL rvUjct/9PTbItb0WbhizYYb78Gbg5nxD+74VfxJ4IIUbnjGk3vLiQIackgNzlpXmDCm7 PKYhBYb10fShfIrCa9ShTA4s8JjfJo69UNF37zYUAPAm1IJVFQJAPQu1Mc+HpCjilI5p E8JX9nzjjne6cqggeh3rhG5xS2ItDe0r1/lMQzZHIOeuzGjTF+rgrIqn7Cfnhc2LX1X5 IOwsrLT5PG87+fK3s1r9j2DX+0Ibf4dQZzSgS03QsUkUeBduInBRpLlL7rmGEqseQGbW nqYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xDeMtjPn; 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 p16-20020a0cfad0000000b00440e46a7d94si1379141qvo.562.2022.03.20.10.28.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:28:36 -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=xDeMtjPn; 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]:59346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzM4-000698-8z for patch@linaro.org; Sun, 20 Mar 2022 13:28:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5y-0008WA-HO for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:58 -0400 Received: from [2607:f8b0:4864:20::529] (port=40489 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5v-0003TK-5Z for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:57 -0400 Received: by mail-pg1-x529.google.com with SMTP id w21so5045109pgm.7 for ; Sun, 20 Mar 2022 10:11:54 -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=RfLYamEZLpY31Sx1p2zuEUJmtGPv8qgDD0cZ+FUaGoI=; b=xDeMtjPn7K80IMXve9W5HqQK/tXiUFtg7XrmPqUe2Of09BlEFsrj93ZYlN86r0K8uj CtDZkSouY5f4zr7HgkjOknQ27Tri1bGmSagmk7O2n96FCxKrDxRZpAaroFXBn6GtSjVN wRqa49ySzXiKZ+/gl9Sd6yhUYCQA/X4ptXm5vOyx1LLMM50LHwrdE/ChVbw2KOlDUEjQ mnxXh6lhOVoOStA35k/h8r3og3zovgqRPnTixTwYYBTwLl1MON+p5H4iOcPs8C9LBfuP ViI6l9sVpY8aALE/na7ABC3LTymY44QuJnWXOpHqCYDGjDH89poamk5vk1ttBgbwk1Xp clag== 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=RfLYamEZLpY31Sx1p2zuEUJmtGPv8qgDD0cZ+FUaGoI=; b=vACrAVU02+DT5j/w6GQJn4+9TJwvALyksawFO18D/kwfeBua6r9Zg6/J11Zwgb+MXS ZwkWqdw7CJrNM/BNiKbmM9FXU56yf7Io0bVKf2u8geVBh6P8iHtma+exbnXOgH3Q43LO KX2Flh9ZFLd2e1RrgHHS9HtRTEaeXwJBuJc0LYw4XdrspHmxal5eJ0iQkhWS2rPo5Sy2 9GrSz/9Cd6lwhC9c0i/Khy1TIAvBSrlDA74gfxfXLOOWDDsbfKbx6z3c4qAFu4TrIsbW 5wzbnedvRg1KWb642LMTU9YItzB86Q+3opypZjbLgIfh1IsOQ5ywx+41b1XdYdE8OrG6 KFZA== X-Gm-Message-State: AOAM533lCjHWgXl6iNAR/VnPz1OpLHnCxNFuFRMXTSjG5n4cKnaZPUg+ QG/6fVjcv0SufUN+wjEa6FtCasaR5hJ4DQ== X-Received: by 2002:a63:7d5d:0:b0:34c:17:6174 with SMTP id m29-20020a637d5d000000b0034c00176174mr15682508pgn.133.1647796313965; Sun, 20 Mar 2022 10:11:53 -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.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 19/36] linux-user: Expand log_page_dump inline Date: Sun, 20 Mar 2022 10:11:18 -0700 Message-Id: <20220320171135.2704502-20-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::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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" We have extra stuff to log at the same time. Hoist the qemu_log_lock/unlock to the caller and use fprintf. Signed-off-by: Richard Henderson --- include/exec/log.h | 15 --------------- linux-user/main.c | 43 +++++++++++++++++++++++++++++-------------- linux-user/mmap.c | 7 ++++++- 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index d131a3140d..ad0a40cfeb 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -42,19 +42,4 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) } } -#ifdef NEED_CPU_H -#if defined(CONFIG_USER_ONLY) -/* page_dump() output to the log file: */ -static inline void log_page_dump(const char *operation) -{ - FILE *logfile = qemu_log_lock(); - if (logfile) { - fprintf(logfile, "page layout changed following %s\n", operation); - page_dump(logfile); - } - qemu_log_unlock(logfile); -} -#endif -#endif - #endif diff --git a/linux-user/main.c b/linux-user/main.c index 6aed4929ab..2bdee78019 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -857,21 +857,36 @@ int main(int argc, char **argv, char **envp) g_free(target_environ); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - qemu_log("guest_base %p\n", (void *)guest_base); - log_page_dump("binary load"); + FILE *f = qemu_log_lock(); + if (f) { + fprintf(f, "guest_base %p\n", (void *)guest_base); + fprintf(f, "page layout changed following binary load\n"); + page_dump(f); - qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); - qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); - qemu_log("start_code 0x" TARGET_ABI_FMT_lx "\n", info->start_code); - qemu_log("start_data 0x" TARGET_ABI_FMT_lx "\n", info->start_data); - qemu_log("end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); - qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n", info->start_stack); - qemu_log("brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); - qemu_log("entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); - qemu_log("argv_start 0x" TARGET_ABI_FMT_lx "\n", info->arg_start); - qemu_log("env_start 0x" TARGET_ABI_FMT_lx "\n", - info->arg_end + (abi_ulong)sizeof(abi_ulong)); - qemu_log("auxv_start 0x" TARGET_ABI_FMT_lx "\n", info->saved_auxv); + fprintf(f, "start_brk 0x" TARGET_ABI_FMT_lx "\n", + info->start_brk); + fprintf(f, "end_code 0x" TARGET_ABI_FMT_lx "\n", + info->end_code); + fprintf(f, "start_code 0x" TARGET_ABI_FMT_lx "\n", + info->start_code); + fprintf(f, "start_data 0x" TARGET_ABI_FMT_lx "\n", + info->start_data); + fprintf(f, "end_data 0x" TARGET_ABI_FMT_lx "\n", + info->end_data); + fprintf(f, "start_stack 0x" TARGET_ABI_FMT_lx "\n", + info->start_stack); + fprintf(f, "brk 0x" TARGET_ABI_FMT_lx "\n", + info->brk); + fprintf(f, "entry 0x" TARGET_ABI_FMT_lx "\n", + info->entry); + fprintf(f, "argv_start 0x" TARGET_ABI_FMT_lx "\n", + info->arg_start); + fprintf(f, "env_start 0x" TARGET_ABI_FMT_lx "\n", + info->arg_end + (abi_ulong)sizeof(abi_ulong)); + fprintf(f, "auxv_start 0x" TARGET_ABI_FMT_lx "\n", + info->saved_auxv); + qemu_log_unlock(f); + } } target_set_brk(info->brk); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index c125031b90..1aa343a491 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -630,7 +630,12 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - log_page_dump(__func__); + FILE *f = qemu_log_lock(); + if (f) { + fprintf(f, "page layout changed following mmap\n"); + page_dump(f); + qemu_log_unlock(f); + } } tb_invalidate_phys_range(start, start + len); mmap_unlock(); From patchwork Sun Mar 20 17:11:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553194 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp881798mag; Sun, 20 Mar 2022 10:28:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT5UUprCiElKWMK3C6shq/5Mv95t5yquHzSeGqlJZaysxVBLYxtJTQ/BcXZeg9u4ofDBpX X-Received: by 2002:a05:6214:19cb:b0:440:a253:b027 with SMTP id j11-20020a05621419cb00b00440a253b027mr13430281qvc.72.1647797321885; Sun, 20 Mar 2022 10:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797321; cv=none; d=google.com; s=arc-20160816; b=IDlo4+pZXo69gkGA8vwdUINj8ElCirIyTfGJ1xjEXcfd1Zg4jGoW8Sli7HyUnH5fSN uUik8gWmFxi42mACr5E/rBZHcmrs3dsgj5I7pp7bU417VMbQuh1ARdiKKKlcfzDedrt1 60L8uqzEEpFtHvwcwnHfu0DLRyNtNO1qvaiujImlTRXGXhM83fxgilV1GTE8ETvr11Gn +JowMiWUsrt8bg3plkNyChqZLvFkAUMzfy0Ye2wmnQ43EoaTBIe0MVPr7+rzyap176l9 iwBjU+LlWtc14lXSTv5ZQL6KYkjCKDAJhwRobpwRuQxGh1SBd6erWmcPt3nbSbMElPeu sIEg== 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=L87S22rf4qAItkg1Hc+56nj9SIVR24PlTDFBvPEqmNI=; b=eFiKKx2vauPhHJT8pFWcorW4AnEGV+XorqTBR90+1m+ql0Ll7yVnWj6WXHvJ/8nD+0 aKjn/m3v0YJGJqVYAlizwpqSEBCRTqZlsQKVkFyV/UfiuV6ea7QlqKzdWtobFYRuwRVv eV0GJKT9PyxwHt4XHMLLbPOdsU+RlkrEVdbsBMqx13Z+MM0d0ufVtfszB0A4bpxyhZ2I p7NOZWIHNC3gu/CBE3cG41WTeUDIDw3wIDVQznLCW2eWOt6dklpnDiFhBqkqw3GSgBTu gz2Ku8guqCjGveAgBzvU91ZaezAsZzMXtLZb/IUXo0wCD9CojjnG73HyLGjJK64o2Tkw 3oKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cAnFwt6L; 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 t6-20020a05622a01c600b002e1fbf3bedbsi1475375qtw.204.2022.03.20.10.28.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:28:41 -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=cAnFwt6L; 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]:59826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzM9-0006Rd-GY for patch@linaro.org; Sun, 20 Mar 2022 13:28:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5y-0008W9-GP for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:58 -0400 Received: from [2607:f8b0:4864:20::430] (port=39599 helo=mail-pf1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5w-0003Tb-0w for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:57 -0400 Received: by mail-pf1-x430.google.com with SMTP id u22so2278328pfg.6 for ; Sun, 20 Mar 2022 10:11:55 -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=L87S22rf4qAItkg1Hc+56nj9SIVR24PlTDFBvPEqmNI=; b=cAnFwt6LggNoa2zywcdOwNBqDtulXjZKfZTs9BJ8XqTB+P6kNy0OUdF6H2nXDIFWG+ gN3+HdTslg7rpcRUypYlleh9fTu4i0uETstdD4uB7wFUKjY3iY3C9G8KFROS0zzUD6Ey wV9yuLpk3yYi6WcOHKzMJfrJe6Tox5dEAbbDypNXeet3ZyS37SRpYi22uCPEYdolE7Tr tkXe8kxbnQZ3ZBAY2n4G+am1fcJ1Aalhrw4StCARoKSdf4Oth4ElfsyXOvDghMxPxju3 niw/EEZCpWBku6yDWNXFmGKezHF8ILFxpayZDFV732ewHKLZO+rDSl9+myXFNAA5Am18 8Ymw== 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=L87S22rf4qAItkg1Hc+56nj9SIVR24PlTDFBvPEqmNI=; b=ug9S6HLHLcJdikyWdG2DyKx4pCb0PHGT5a3WrDIQk1Ex3CzuVkz61/a57KxRXLRulW +1kdkAFQJEkbFqtn7wZ6JYOXW2BbPrd8BaP2IJyx+glbniCuHcCcQ/wrKyLnnpaNmSsx d4fOO/U4v4LZT/PIgXVXG+SW9sw2WWhg9zp833N9hQ7qT0GN8MbMP5hOydJp6onCqYOh 1Dh88r1yI3gNS4/gWswYGp/dEN6Q+GSPij+YJELBx0L6Zo+qlE76JWGOUPS5VMl1C8fv d8/Cxk2JsbJ04gVF0CcUqo3nvRlfeQ9QGE0yE2ixeSuyQQy67w65cYzswsV5r1B5LvEx uUwQ== X-Gm-Message-State: AOAM530zV0sXfZbQKeZzYHoWB7bmh14Cl4XVJYVChswSrJKhkl91nQds grXBa0QytjxCXv3LXA2RuE5MdXCWBZTJ7w== X-Received: by 2002:a05:6a00:198c:b0:4f7:7e0f:bfc2 with SMTP id d12-20020a056a00198c00b004f77e0fbfc2mr19519700pfl.44.1647796314800; Sun, 20 Mar 2022 10:11:54 -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.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 20/36] tests/unit: Do not reference QemuLogFile directly Date: Sun, 20 Mar 2022 10:11:19 -0700 Message-Id: <20220320171135.2704502-21-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::430 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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" Use qemu_log_lock/unlock instead of the raw rcu_read. 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 93c6d666e8..fc22bf40b4 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -110,12 +110,10 @@ static void test_parse_path(gconstpointer data) static void test_logfile_write(gconstpointer data) { - QemuLogFile *logfile; - QemuLogFile *logfile2; + FILE *logfile0, *logfile1; gchar const *dir = data; - g_autofree gchar *file_path = NULL; + g_autofree gchar *file_path0 = NULL; g_autofree gchar *file_path1 = NULL; - FILE *orig_fd; /* * 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 = g_build_filename(dir, "qemu_test_log_write0.log", NULL); + file_path0 = g_build_filename(dir, "qemu_test_log_write0.log", NULL); file_path1 = g_build_filename(dir, "qemu_test_log_write1.log", NULL); /* * 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 = qatomic_rcu_read(&qemu_logfile); - orig_fd = 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 = qemu_log_lock(); + g_assert(logfile0); + fprintf(logfile0, "%s 1st write to file\n", __func__); + fflush(logfile0); /* Change the logfile and ensure that the handle is still valid. */ qemu_set_log_filename(file_path1, &error_abort); - logfile2 = qatomic_rcu_read(&qemu_logfile); - g_assert(logfile->fd == orig_fd); - g_assert(logfile2->fd != logfile->fd); - fprintf(logfile->fd, "%s 2nd write to file\n", __func__); - fflush(logfile->fd); - rcu_read_unlock(); + logfile1 = qemu_log_lock(); + g_assert(logfile1); + g_assert(logfile0 != logfile1); + fprintf(logfile0, "%s 2nd write to file\n", __func__); + fflush(logfile0); + qemu_log_unlock(logfile0); + qemu_log_unlock(logfile1); } static void test_logfile_lock(gconstpointer data) From patchwork Sun Mar 20 17:11:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553206 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp887922mag; Sun, 20 Mar 2022 10:42:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBWD6uZSMqxc/4zopwWPIhZMVnlq8rMQI8q1VVjU5GYXAqUjssQg1vct9HYMsDOF5oF1eA X-Received: by 2002:a05:6214:c48:b0:440:cded:f2ab with SMTP id r8-20020a0562140c4800b00440cdedf2abmr13574248qvj.18.1647798174232; Sun, 20 Mar 2022 10:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798174; cv=none; d=google.com; s=arc-20160816; b=xo41gjGEsf2b/Qa8a8mRbpLWZ4TEXQhAefZBFG1X/jVSbQX0Bh91QIPQfPLdMygBFS TuYO5h4vxK+nGzr/qXwsw04CND4HKlSLwR7C/wuM2kPAppEI5ayRNDVi4Mx+dPi9PZyh zNRajWpZtf1Zj5kbVjx3MrK+T7Oau8ofjykmAOO7Fj9F1p2kF6WQ9cGkmjcUrhVdMLXt nDpYIt3r0s2BFbUkMhB1D5kDWDFV2oIgRiPEKwmqbFe2tUHiWRm7gPYdls5pjJa/C3l6 3dpZ1GdVJkhRwGqIccPwO7t5VxtzNr+WQY3+9web5Kv0PNx/eAbhQ4eRI/uqgAzl3Ppf iUxw== 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=HY6g2dz/onqNKInKBF8VriYCnDheK410T+QzLO/qQ+A=; b=iFL3tQTsDKNI8EPc5bqV5OwDUlamMsx6x2e41OVHsybsOrXX+vxlTGyWOuIO47ECPw 0SCAZf4CwNsfGvrcvask2dIIXiJo7w0yAfMhY3cXdlZaag7XT/u3nIpcUeJKc2aUlTed KXTH+OxlUKf/sduihTQrvswDfTep6X+V7hxuTasnMnmMj0W7hQ1FfK3OR3LdfSVePYUB KEo070gl/yBrEXg2bII5st2kJENVYttcwMTcKxw9v548s5ckJcWMRp9/JesqLN931XjY iiSMSmPKx8NiVyqeGPnztTBgLShHNjX27UaZdxEr5aby/XxhrFeIhHv/qD57r0L6CO1L UTBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N0LxrPCJ; 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 u127-20020a379285000000b0067e4be2396fsi1281276qkd.436.2022.03.20.10.42.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:42:54 -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=N0LxrPCJ; 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]:57400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzZt-00073E-R0 for patch@linaro.org; Sun, 20 Mar 2022 13:42:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5y-0008WB-If for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:58 -0400 Received: from [2607:f8b0:4864:20::42b] (port=34765 helo=mail-pf1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5x-0003Tr-4y for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:58 -0400 Received: by mail-pf1-x42b.google.com with SMTP id l8so13701577pfu.1 for ; Sun, 20 Mar 2022 10:11:56 -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=HY6g2dz/onqNKInKBF8VriYCnDheK410T+QzLO/qQ+A=; b=N0LxrPCJhpe3LVEG3sfYUU6Sfg32w+gmviRiRSf53bK6jVUrGASP0styDXbxwEPg0W kGPL+QDxlIRrGpJPTBjMwbQucKRcq0ShycgbJ9ccBLUk3ak2Mbj+HvzXrW2K930bwzi7 P0TgofFw0aLD0YovpLLdsYjIZmOCkIhXOMdedqXvUW6lLMJ+JJkIpcAI2Pbu0PtW+44h W/7rImjZlcuINyz3NPF+XYByzLcuAOPvtXEGLilYXC020NWFjIT/ZRI0WoAICGMNP21l uvKRJyRU64SKDS7rC1YB0yMvEU/kf9ExgnnO2IhUGjwPe9TDKjuYoHQpgIVO28AuAnxX /fEw== 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=HY6g2dz/onqNKInKBF8VriYCnDheK410T+QzLO/qQ+A=; b=KecC2fq/i9/4+c+4MFf+CfBJzHWx7+9HVXdNMTNBQnKmHHcUs1WQJKecos/GLUqn/q HGirR3B0a5L6U4C2XpWuiA1ShmtCozrTn55EqlkZZL1q6NjZW9OZKnyErKmvMB+dNpdD ooUHNqZ4NVyGCsuqVsjFrD7rBZ61BnY1uPTJQcwQPYK2wwabmfTe0tyOHGn14QlO5JlR 4qRy6wHfBIQwqBhnD2+V3wnZa3UOd5P+89DVczK5m+zioZ3DovZoAvjsROIGmVXF2TOZ r5KQqcKXjlRwUoeP6FdTaTf6OPvefI7iaGahI/x7CT7qzu60FbWy5NmznmN5yZWTerqO 1qqw== X-Gm-Message-State: AOAM532cKL+MPGnF5Xqj4lJZpvfU/QIKmHY8eNGxKP1KnPWEnr7wOr5D ontqu85ZwtAyAufDq/oKakziEq4L3w9gsQ== X-Received: by 2002:a63:6645:0:b0:382:65eb:1215 with SMTP id a66-20020a636645000000b0038265eb1215mr3918995pgc.337.1647796315599; Sun, 20 Mar 2022 10:11:55 -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.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 21/36] include/exec/log: Do not reference QemuLogFile directly Date: Sun, 20 Mar 2022 10:11:20 -0700 Message-Id: <20220320171135.2704502-22-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::42b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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" Use qemu_log_lock/unlock instead of the raw rcu_read. Signed-off-by: Richard Henderson --- include/exec/log.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index ad0a40cfeb..10d0e809d4 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -15,15 +15,10 @@ */ static inline void log_cpu_state(CPUState *cpu, int flags) { - QemuLogFile *logfile; - - if (qemu_log_enabled()) { - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - cpu_dump_state(cpu, logfile->fd, flags); - } - rcu_read_unlock(); + FILE *f = qemu_log_lock(); + if (f) { + cpu_dump_state(cpu, f, flags); + qemu_log_unlock(f); } } From patchwork Sun Mar 20 17:11:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553209 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp891535mag; Sun, 20 Mar 2022 10:51:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7VWSdIvCr8URjrtDR8rJt6Ln4G+ciiYY7gHcUkMh3tIjK/31ZinZR3rx7W9+Y71oVork4 X-Received: by 2002:a05:622a:11c9:b0:2e1:dd8d:33bc with SMTP id n9-20020a05622a11c900b002e1dd8d33bcmr13847101qtk.368.1647798683762; Sun, 20 Mar 2022 10:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798683; cv=none; d=google.com; s=arc-20160816; b=ujJkxN3RyBxNUPWDsG0qU+6e7OUroqsBf/xuBR1Hyuh+eAO2xVCliXISB9VTKbAInA 3GiWntbGJ3//h3xz/ULZX6Sa0jOrLDHt3YOK2akid/PFOIlEZJxw6K1iOuBu7RxrOxhv GpmV+h8GUjT+5Y3IutsUnbX6ZSVvyg48kEzNO78weWjWK180NzUsrkFjIh5YVRBvXDFI iUgef+q8RkwQUL68l80pZKcx/XUCdVsbsC8nbt1tjpXKnpay66zwtYxb2dgsrnv0Y7gX ag4P4NKOVm8kiz1u4YMWKfGlCYCxE4s8PKa4BTz3+notyFSwBc+t3L5gGj1GoDPYZZDS km5g== 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=THGd3lL3k1TYcfn7NVeHgS8AdzPbg7kpOdsIIF9l+TA=; b=phEJJONs+tTMDJ0xlo55tFLDVdoAg5vcHGNnUwwFgfbsOrKYMcHNBGpqH4uJCKnEDt WsVDe6sjbJhKF5XRCiQ/fnZJ56FbTX8K4B+U8vuzgpAU9As837Zz+sIWhU73SsQdh5Ca CfD9oOuAxnl91PIGiQr5Or9Ti1jD2/KR9HczYlIaPiq5OID7M2vmUHptEH8T/bvXI0hX kFtB0D/CF+CVMMYQRK3iYHHlv+xHbayXfdyH/3ITQ1bzFuUvwuUseV4YgAQSqOlBIp0m QsDc+kL4hs8f1hRrkp2atAyFpV8su1KnioaYC8GZYv87sPBFMYlSwH6mmH7snJvmcWnZ qLsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gu/J9y3X"; 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 j6-20020a05620a410600b0067e4be23848si1541754qko.141.2022.03.20.10.51.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:51:23 -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="gu/J9y3X"; 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]:37822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzi7-0004qF-Aw for patch@linaro.org; Sun, 20 Mar 2022 13:51:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz61-00005l-4f for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:01 -0400 Received: from [2607:f8b0:4864:20::62a] (port=34479 helo=mail-pl1-x62a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5y-0003Tx-7j for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:59 -0400 Received: by mail-pl1-x62a.google.com with SMTP id i11so10197054plr.1 for ; Sun, 20 Mar 2022 10:11:57 -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=THGd3lL3k1TYcfn7NVeHgS8AdzPbg7kpOdsIIF9l+TA=; b=gu/J9y3Xbp7DURODPmJkaHY2rvKu0Uhz0c7qBDWYkGBMcIV+VKGB76Wnn6zQiiGg5t FpRsFjn+fBK0E89gBlZtAHZ08Zd0pcJimjNK/JSDfdAHJ0LwLN8fLnkE/x2K0Kn4PjNT tHc8mPIJnT1WrgX09uYstwFvkedUZ+wOqeRZXXh5U3VI61b2U6J0oUoQkU3YeXyIveOv XvyXrHMdRrRqrC4FZE3LjejOSHy7Oq2ikqFl/FIepcjE4YgnWOR9ro5B8/AeP92KZAyO 8/cGiJhLslAiePPepdQs48OeE6/TFSLKF0yM+8fgVrdGO8MQvPNefmRtx9d0Gc0+LKfR tXwg== 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=THGd3lL3k1TYcfn7NVeHgS8AdzPbg7kpOdsIIF9l+TA=; b=O78rpJ6QJq+txyDBguxvpQ2yR2jc8/YGkkmfol5X3hl/TRGbstDDwr4gUc9tayXh1e Xbs8DPFbc0146xpRPQifYrQmDzHHzw3MkI/dByGeBvsQORjeg0XhJLCoQYMoNl/i+pe0 ey1kaaHUbl3St7B+ts1LSMJ0ARbSHG8MnrjkJfCyA8vEp2caxqRSAEY6EdccUpSiZcp5 dQ8sKE0QyXkTJ5kHVBVWmUlvaoUKNaZsZiMuFYnApdQrYrjUXMYGWVzHGTLHoKowJeWB a2TmulcQ5wdDOPtFr6j5cGiz9/R92pn/zGZUu3fv/O2ulYrfeRahpkQt4GHQspnFGWX2 50/A== X-Gm-Message-State: AOAM533K0kOqsLL83PVN8FKy2zrON12uHcqXyWl3w/ajoB4yamL15aFH 1OWcn3ZHUAaIHUqPp23/jgAUN4tyWmftvA== X-Received: by 2002:a17:902:7781:b0:153:35ef:e3d1 with SMTP id o1-20020a170902778100b0015335efe3d1mr9309074pll.116.1647796316622; Sun, 20 Mar 2022 10:11:56 -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.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 22/36] include/qemu/log: Move entire implementation out-of-line Date: Sun, 20 Mar 2022 10:11:21 -0700 Message-Id: <20220320171135.2704502-23-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::62a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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" Move QemuLogFile, qemu_logfile, and all inline functions into qemu/log.c. No need to expose these implementation details in the api. Signed-off-by: Richard Henderson --- include/qemu/log.h | 38 ++++---------------------------------- tests/unit/test-logging.c | 1 + util/log.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 10578ba21c..c63416c9e0 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -3,46 +3,16 @@ /* A small part of this API is split into its own header */ #include "qemu/log-for-trace.h" -#include "qemu/rcu.h" - -typedef struct QemuLogFile { - struct rcu_head rcu; - FILE *fd; -} QemuLogFile; - -/* Private global variable, don't use */ -extern QemuLogFile *qemu_logfile; - /* * The new API: - * */ -/* Log settings checking macros: */ +/* Returns true if qemu_log() will really write somewhere. */ +bool qemu_log_enabled(void); -/* Returns true if qemu_log() will really write somewhere - */ -static inline bool qemu_log_enabled(void) -{ - return qemu_logfile != NULL; -} - -/* Returns true if qemu_log() will write somewhere else than stderr - */ -static inline bool qemu_log_separate(void) -{ - QemuLogFile *logfile; - bool res = false; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile && logfile->fd != stderr) { - res = true; - } - rcu_read_unlock(); - return res; -} +/* Returns true if qemu_log() will write somewhere other than stderr. */ +bool qemu_log_separate(void); #define CPU_LOG_TB_OUT_ASM (1 << 0) #define CPU_LOG_TB_IN_ASM (1 << 1) diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index fc22bf40b4..7016710a74 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -30,6 +30,7 @@ #include "qemu-common.h" #include "qapi/error.h" #include "qemu/log.h" +#include "qemu/rcu.h" static void test_parse_range(void) { diff --git a/util/log.c b/util/log.c index be20ae6c1c..7e8b152742 100644 --- a/util/log.c +++ b/util/log.c @@ -26,14 +26,42 @@ #include "trace/control.h" #include "qemu/thread.h" #include "qemu/lockable.h" +#include "qemu/rcu.h" + + +typedef struct QemuLogFile { + struct rcu_head rcu; + FILE *fd; +} QemuLogFile; static char *logfilename; static QemuMutex qemu_logfile_mutex; -QemuLogFile *qemu_logfile; +static QemuLogFile *qemu_logfile; int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; +/* Returns true if qemu_log() will really write somewhere. */ +bool qemu_log_enabled(void) +{ + return qemu_logfile != NULL; +} + +/* Returns true if qemu_log() will write somewhere other than stderr. */ +bool qemu_log_separate(void) +{ + QemuLogFile *logfile; + bool res = false; + + rcu_read_lock(); + logfile = qatomic_rcu_read(&qemu_logfile); + if (logfile && logfile->fd != stderr) { + res = true; + } + rcu_read_unlock(); + return res; +} + /* Lock/unlock output. */ FILE *qemu_log_lock(void) From patchwork Sun Mar 20 17:11:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553196 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp883605mag; Sun, 20 Mar 2022 10:32:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXnDIcIKeghHo0Vwjbr9U0c5rf6x5iNpZZXmkMVbuzu5UCSerw3fJHtlvWrnMi1tlo0slH X-Received: by 2002:a37:86c2:0:b0:506:cfe7:ce67 with SMTP id i185-20020a3786c2000000b00506cfe7ce67mr10854523qkd.564.1647797546275; Sun, 20 Mar 2022 10:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797546; cv=none; d=google.com; s=arc-20160816; b=T8WlC1E+W0mey2t4YXo9XcE88yflZu0Jka6TyNx5KtVk5mn7oyHIZfB3SET08KIlUc He++U1ZIGsjfeDUfdzazbTQDRn/N/t/GHM+QJmPbpfcXXRcPzVmfmBVV/L0LKsQ8P6gL yiVxFFzX6BbPldFrPfZiILegrTz7um8YMIngYd5euJb/3qhA2B2LEjGFCZ2CmHroULXf voIn3CeMd9xv/a5KVcgkI6/GIYHuJRwVcTB1ni5E3+f+JQUnGgmZU08c8tVkY39P1Xbg IIZXzJdJIiRA2FMuyJHSWRIYTiKJCCu2kam3K8aMwUOQ0XJn5hq9xu9WuizeVtei343C tFhA== 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=Hu9aRYzYIgbIdzSTEVhW4soYbAG6jLfuaaPgAkD8sGQ=; b=zvBAiNVurhOdlNUnIxLKQkcyqQL+1++U4S6VBlNtEKJv4Dbp8PiQCr+S00HrWG3J4B s007FMBoQsGKDPDvT3sRn9tzRXlTr4ZvrM09/0H5P1ezNCFo01ee2bxyHOXBirhti8qS 7mtE/tIqaApEEgg9Cxz2vd4KONgoNm9/Jt2Lx4SrtBXNNPvLtMPl40hvBTH7WJM8vo1T IgH0Uh6dlliE17BoFLp904+y+OF6n9W9v5MbFzylp64EYk09uth9IPD/u+3SjHagICfH R7RzzYKLQWUoIVEz63Zd3bXzAm66ZQ2gz7M9wubbqNoJYEHxZ+D6LlKkBOAt1Dgcej5r +kaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qh8huIxA; 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 c10-20020ac87dca000000b002e1fbf3bf3csi1446840qte.301.2022.03.20.10.32.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:32:26 -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=Qh8huIxA; 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]:39564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzPl-0003Rd-TG for patch@linaro.org; Sun, 20 Mar 2022 13:32:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz61-00005p-5U for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:01 -0400 Received: from [2607:f8b0:4864:20::629] (port=38687 helo=mail-pl1-x629.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5y-0003UG-VD for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:00 -0400 Received: by mail-pl1-x629.google.com with SMTP id n18so10885446plg.5 for ; Sun, 20 Mar 2022 10:11:58 -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=Hu9aRYzYIgbIdzSTEVhW4soYbAG6jLfuaaPgAkD8sGQ=; b=Qh8huIxAEYt/Z5x1IVM0vM3opFwm3z+Tgu5TIUEWkya8omECsefqapLtx7I/4ytWK7 YOJnoofFhl9GTJqGxChRneDsU/CzxiBWaYYikeeurItuT8UVJHh8Yo33Jl/6yaJGYykC cRwxxOsOYfc/Rji252uBe6/LlTUli+HPrPSMlqqMnLrTPS7mSlBwsfyhvglNNCpLHpMl WsPGiKysbeKAjL2InlufLz25KM++AUG1r5D5akLelTIisvVJvE5JwGPNhQPUneOnCgYy i1ZKgkSuBdC9xZawhzNm1U4lX1ddclFvm0vg2nBQXzmRlsxY/5r+bmt6l4+H/f4A1CJf UEYg== 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=Hu9aRYzYIgbIdzSTEVhW4soYbAG6jLfuaaPgAkD8sGQ=; b=Qm+Rof4+u7rBTwCAi6n6CumiLEA/6eYHXP2vEwzasNoKoOSUbg5HwXW6K/QPNywCxB e2AMleDLRKYFT3rSv01AgGsm4H1MZsFQypWEaecUuRH/GwmRpxI/H+D6AXnpu8oxYSVU kaoAl3/cpB85ZNnOtME/IqIEpXwJk6exBzcFRFras7B7pI7V0symMlVWPv67SSTmAPsl WhEOdjAHUMoQU+4EZ4HXVJN6+lN0NT9RrCdcmRu/QIOhs8tPJxjsn/V9riWbHIBbw8LM JrXa5AZAnWCoKwbtY8651b/Gqd23H5UOvnAx7zQHDQXMedY10ouKxVcV00a9A1FTIzSW I5MA== X-Gm-Message-State: AOAM530idZg8+4cYROCrAm4zalQk++pE5/XaRh9iG/6GGEKcS/bzO6Ar nBvhVvqnOFWls8kT/rgaCrkfyojHwVTOUw== X-Received: by 2002:a17:90b:4b83:b0:1c7:2497:3800 with SMTP id lr3-20020a17090b4b8300b001c724973800mr31537pjb.225.1647796317666; Sun, 20 Mar 2022 10:11:57 -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.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 23/36] sysemu/os-win32: Test for and use _lock_file/_unlock_file Date: Sun, 20 Mar 2022 10:11:22 -0700 Message-Id: <20220320171135.2704502-24-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::629 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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 bug referenced in os-win32.h was fixed in mingw-w64 v6. According to repology, version 5 used by ubuntu 18, which is not yet out of support, so provide a meson link test for it. Signed-off-by: Richard Henderson --- meson.build | 12 ++++++++++++ include/sysemu/os-win32.h | 16 +++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 282e7c4650..f22a09dac5 100644 --- a/meson.build +++ b/meson.build @@ -2018,6 +2018,18 @@ foreach k, v: config_host endif endforeach +# Older versions of MinGW do not import _lock_file and _unlock_file properly. +# This was fixed for v6.0.0 with commit b48e3ac8969d. +if targetos == 'windows' + config_host_data.set('HAVE__LOCK_FILE', cc.links(''' + #include + int main(void) { + _lock_file(NULL); + _unlock_file(NULL); + return 0; + }''', name: '_lock_file and _unlock_file')) +endif + ######################## # Target configuration # ######################## diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index 770752222a..649f417d39 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -113,20 +113,22 @@ static inline char *realpath(const char *path, char *resolved_path) return resolved_path; } -/* ??? Mingw appears to export _lock_file and _unlock_file as the functions - * with which to lock a stdio handle. But something is wrong in the markup, - * either in the header or the library, such that we get undefined references - * to "_imp___lock_file" etc when linking. Since we seem to have no other - * alternative, and the usage within the logging functions isn't critical, - * ignore FILE locking. +/* + * Older versions of MinGW do not import _lock_file and _unlock_file properly. + * This was fixed for v6.0.0 with commit b48e3ac8969d. */ - static inline void qemu_flockfile(FILE *f) { +#ifdef HAVE__LOCK_FILE + _lock_file(f); +#endif } static inline void qemu_funlockfile(FILE *f) { +#ifdef HAVE__LOCK_FILE + _unlock_file(f); +#endif } /* We wrap all the sockets functions so that we can From patchwork Sun Mar 20 17:11:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553193 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp881791mag; Sun, 20 Mar 2022 10:28:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9WoWXOpoL0b30h/bgqGEjcBcYSxlA+1s7Dzt4gRd4aDXOBazoYN9m7pqi113woR10jg0R X-Received: by 2002:a05:6214:2344:b0:429:4d92:cec2 with SMTP id hu4-20020a056214234400b004294d92cec2mr13110482qvb.0.1647797321192; Sun, 20 Mar 2022 10:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797321; cv=none; d=google.com; s=arc-20160816; b=Xv8qNcD+cwWprfrNVgWkQhbAMfpq1lHIako9Pi4KCUuhuche/0G5e6sVjn4Pm8R2UF Yu86SGc9eT7s0tVSqFipfWFxRdBll+PPtA9AW6CUT1XkzgBG5wgLKXIGSpwVxwlT232f h9eFuDIiJi3g8D/f5E9cyxKiGyaooi2NOVp2rBxLMlbu2s8ux66+kmwdPDyNKoceX4h3 OcYjTvgE2lmkl9ACTUCxEKcSbNAEnBwZcu+02lAB1iVhsRftzh8S22MOYq5X29ZlPCsQ MZWXaynx6/URCy3mCA9RuONj1QbvOqKdhSDuUDcVs/wKd5xGZlo+/1eE0vkanNUDwVM8 UzjA== 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=h0xc9BI1YGSLEUvZQaFfOPBOYlCXbsk+XY8xxzjyhJU=; b=PHU5aPCq3ejKR0fswCBlvZ5mo4r4M4Fe75BCYTHVtSk6qIwk2BDsvKRh+S9Vi3Fgq5 mAGsthSPOEFEpkXUoujeJmNAdNzf0HxEmLJa30Q1YwJ6TuhtMsl0FN7YItOTes0HGSaA qiumy1d/eReIdb2aDNVccYUH3HL/CbwRwtkAkZxKilsHOj0zpr/qW4sbEVSGSuDh/k13 u0xjr+zWxEI5kFMzr2Jm0nXdHQwZx0kir3WCupNVZcMRnpNTq7+xZzAyyM5u5gJs+aEp mlgsoYct2jd7wamKrSn5OzSTZstr9yz9/Z0OBSYgC42H+eaOCYNcRN6dZjFnTcrQ53vc 1GZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m8jE1oJf; 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 g187-20020a379dc4000000b0067e4be2398csi1267466qke.465.2022.03.20.10.28.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:28:41 -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=m8jE1oJf; 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]:59762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzM8-0006PW-Pd for patch@linaro.org; Sun, 20 Mar 2022 13:28:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz62-0000BV-Oh for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:02 -0400 Received: from [2607:f8b0:4864:20::62e] (port=45648 helo=mail-pl1-x62e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz60-0003UW-T4 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:02 -0400 Received: by mail-pl1-x62e.google.com with SMTP id k6so3717141plg.12 for ; Sun, 20 Mar 2022 10:11:59 -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=h0xc9BI1YGSLEUvZQaFfOPBOYlCXbsk+XY8xxzjyhJU=; b=m8jE1oJfEWsYEp9Ty2SzzXR/6cSsKE20/7fg9BGdQPoCTv6n2e8abW0VvOdOFU7EVP ueZlsH0GTKVnhZzGLCgMKtE0cUyM5D3FNctQL+/KRqJEQohToNGNK5chg+Tt7XoJA7lq El3DMy6unormZGUgymlRauav4eUoE2eNr1r9haO8LIPD4vJ5BfbUv5XPYFHqn1nUZgkg 3oJqXKShstv/YyD+wzmYVUaW/k0rJn7jdBXP/Ww6hfWu4xR0HSZAvJknXiwLR1drR8Vm QZAGvMKKRGEDL6iJ4ax7daWgpfMHcovYoczhRIWzusHkh3aFn1+IM+FJbozsX0SvcrKE lxoQ== 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=h0xc9BI1YGSLEUvZQaFfOPBOYlCXbsk+XY8xxzjyhJU=; b=GjGCMj8LbBAvFbXXQCS7TYAnf3Zu4UehOBTemOYanGX+iF2R04ZyiKrGQk5+Iw1obB jtYWVKCG+OxWpQslIB8UKBUzyToVnZnvT23cJ2hnCikyzJbQyRC/Ctu2VCwkiV88pZZk ff3g0WKBwusILTv5ZygkB9ASH9T2bd1+2SxwOFGvG6tUgdPjnS+fYteBbek0IyohkBD7 0GbosPuMB2BL+VSKVe9rVBKykBn0CL+i6qGEfRH3MhTcUv9V1XPw4JPO9Ze3TJXYYKy+ coF+3Vc/J37zHef/+iKtZx6jxVfhwphLhGCvbEGdtLr0xVMg3xptbEErpZn/GkVvM+P2 Ksfg== X-Gm-Message-State: AOAM532FuMbGuQ6Img36PeucXX8MMs2t7P5OkmaQavTbPv0usDm5XYgU +hrs9Qx7mbaifYoZpMHla460qv+HnNgzjw== X-Received: by 2002:a17:90a:4bc2:b0:1b8:cdd3:53e2 with SMTP id u2-20020a17090a4bc200b001b8cdd353e2mr32318943pjl.219.1647796318691; Sun, 20 Mar 2022 10:11:58 -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.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 24/36] util/log: Introduce qemu_set_log_filename_flags Date: Sun, 20 Mar 2022 10:11:23 -0700 Message-Id: <20220320171135.2704502-25-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::62e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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" Provide a function to set both filename and flags at the same time. This is the common case at startup. Signed-off-by: Richard Henderson --- include/qemu/log.h | 1 + util/log.c | 122 ++++++++++++++++++++++++++++----------------- 2 files changed, 77 insertions(+), 46 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index c63416c9e0..ef247776cf 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -82,6 +82,7 @@ extern const QEMULogItem qemu_log_items[]; void qemu_set_log(int log_flags, Error **errp); void qemu_set_log_filename(const char *filename, Error **errp); +void qemu_set_log_filename_flags(const char *name, int flags, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); bool qemu_log_in_addr_range(uint64_t addr); int qemu_str_to_log_mask(const char *str); diff --git a/util/log.c b/util/log.c index 7e8b152742..46a0d38d41 100644 --- a/util/log.c +++ b/util/log.c @@ -126,15 +126,58 @@ static void qemu_logfile_free(QemuLogFile *logfile) } /* enable or disable low levels log */ -void qemu_set_log(int log_flags, Error **errp) +static void qemu_set_log_internal(const char *filename, bool changed_name, + int log_flags, Error **errp) { - bool need_to_open_file = false; + bool need_to_open_file; QemuLogFile *logfile; - qemu_loglevel = log_flags; + QEMU_LOCK_GUARD(&qemu_logfile_mutex); + logfile = qemu_logfile; + + if (changed_name) { + char *newname = NULL; + + /* + * Allow the user to include %d in their logfile which will be + * substituted with the current PID. This is useful for debugging many + * nested linux-user tasks but will result in lots of logs. + * + * filename may be NULL. In that case, log output is sent to stderr + */ + if (filename) { + char *pidstr = strstr(filename, "%"); + + if (pidstr) { + /* We only accept one %d, no other format strings */ + if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { + error_setg(errp, "Bad logfile format: %s", filename); + return; + } + newname = g_strdup_printf(filename, getpid()); + } else { + newname = g_strdup(filename); + } + } + + g_free(logfilename); + logfilename = newname; + filename = newname; + + if (logfile) { + qatomic_rcu_set(&qemu_logfile, NULL); + call_rcu(logfile, qemu_logfile_free, rcu); + logfile = NULL; + } + } else { + filename = logfilename; + } + #ifdef CONFIG_TRACE_LOG - qemu_loglevel |= LOG_TRACE; + log_flags |= LOG_TRACE; #endif + qemu_loglevel = log_flags; + /* * In all cases we only log if qemu_loglevel is set. * Also: @@ -143,70 +186,57 @@ void qemu_set_log(int log_flags, Error **errp) * If we are daemonized, * we will only log if there is a logfilename. */ - if (qemu_loglevel && (!is_daemonized() || logfilename)) { - need_to_open_file = true; - } - QEMU_LOCK_GUARD(&qemu_logfile_mutex); - if (qemu_logfile && !need_to_open_file) { - logfile = qemu_logfile; + need_to_open_file = log_flags && (!is_daemonized() || filename); + + if (logfile && !need_to_open_file) { qatomic_rcu_set(&qemu_logfile, NULL); call_rcu(logfile, qemu_logfile_free, rcu); - } else if (!qemu_logfile && need_to_open_file) { - logfile = g_new0(QemuLogFile, 1); - if (logfilename) { - logfile->fd = fopen(logfilename, log_append ? "a" : "w"); - if (!logfile->fd) { + return; + } + if (!logfile && need_to_open_file) { + FILE *fd; + + if (filename) { + fd = fopen(filename, log_append ? "a" : "w"); + if (!fd) { error_setg_errno(errp, errno, "Error opening logfile %s", - logfilename); + filename); return; } /* In case we are a daemon redirect stderr to logfile */ if (is_daemonized()) { - dup2(fileno(logfile->fd), STDERR_FILENO); - fclose(logfile->fd); + dup2(fileno(fd), STDERR_FILENO); + fclose(fd); /* This will skip closing logfile in qemu_log_close() */ - logfile->fd = stderr; + fd = stderr; } } else { /* Default to stderr if no log file specified */ assert(!is_daemonized()); - logfile->fd = stderr; + fd = stderr; } log_append = 1; + + logfile = g_new0(QemuLogFile, 1); + logfile->fd = fd; qatomic_rcu_set(&qemu_logfile, logfile); } } -/* - * Allow the user to include %d in their logfile which will be - * substituted with the current PID. This is useful for debugging many - * nested linux-user tasks but will result in lots of logs. - * - * filename may be NULL. In that case, log output is sent to stderr - */ +void qemu_set_log(int log_flags, Error **errp) +{ + qemu_set_log_internal(NULL, false, log_flags, errp); +} + void qemu_set_log_filename(const char *filename, Error **errp) { - g_free(logfilename); - logfilename = NULL; + qemu_set_log_internal(filename, true, qemu_loglevel, errp); +} - if (filename) { - char *pidstr = strstr(filename, "%"); - if (pidstr) { - /* We only accept one %d, no other format strings */ - if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { - error_setg(errp, "Bad logfile format: %s", filename); - return; - } else { - logfilename = g_strdup_printf(filename, getpid()); - } - } else { - logfilename = g_strdup(filename); - } - } - - qemu_log_close(); - qemu_set_log(qemu_loglevel, errp); +void qemu_set_log_filename_flags(const char *name, int flags, Error **errp) +{ + qemu_set_log_internal(name, true, flags, errp); } /* Returns true if addr is in our debug filter or no filter defined From patchwork Sun Mar 20 17:11:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553200 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp885141mag; Sun, 20 Mar 2022 10:36:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ4RWqwoiBooBgOMW4sINWstfqfBEFa4HvVte97AOrBskO+aCUD4YL7rx9hN36akNVz7MS X-Received: by 2002:a05:620a:2293:b0:600:2b7b:2a19 with SMTP id o19-20020a05620a229300b006002b7b2a19mr10564864qkh.408.1647797763026; Sun, 20 Mar 2022 10:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797763; cv=none; d=google.com; s=arc-20160816; b=Xp/Ibh3tMus77DVBhwJoN/8mYMweYnk9ERVJusTqTyUnXK3rRtf0eWnx0oDmei0ge5 NJnq7RAnSgfe4UdzKc5OCCqNHkqaPq/6NKigf3HufL8BV5YFcxy/sAV/XXXGEI15RiyW U++JUxXpLBBvvYlZmPgH/ia4tV/DHAxB6dnbhFiIoxi+ZmcYig0RTBXXynbD2JeCG1QX iCzIJM43VYxfhxmI8nmPmmtB4IZ6Is/xS01pvPPnAMcKnevZs/54EYmHgd0KKrXG6mJL PHCQvs6MehjAA1wtBixCfxsL3aZjn3wBxBw6xvTzITbORl1gfNvF1KIpi0F8evVD2biT d6qg== 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=yC2sireZoOTYAuTYG5JxotkaWGRw4AVLDFu3n1FRWSw=; b=PRtmjSpQHilYRJJ9Xq2AA4Y9iIEZMublD1dEkqqSHv0piZpzTnVxPfi/VcK+fiYfTr 2QGNODUtcnAf0tsn6eW75QPtVdzHGtR16YyCs5wKSiPMWOmVX49ZhLUB3VcGbHIxhquR zFGrtuou/NPMnV1bXvYFLrmNpleSdQm+TC5mo0FyObQxikjYieamAD9yFW/FuGF3g8i1 0HGWCwq8OmMXcEXPe5LaE3QpiYvB3iapO07aZL2AdiCxh30Qm7SWEdV/Xx2sYJTRgZIZ 72NQ8kZqrwKDnfrwnuZcTMks+RcduNgyeCKk3VjixwWG594cTi/IcFlKuD2aCx45x8Av ZNZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ga9KnqhL; 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 x2-20020a05620a448200b0067e4be2388esi1486857qkp.211.2022.03.20.10.36.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:36:03 -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=ga9KnqhL; 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]:47898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzTG-0000ch-Jp for patch@linaro.org; Sun, 20 Mar 2022 13:36:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz62-0000AA-EB for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:02 -0400 Received: from [2607:f8b0:4864:20::102a] (port=33964 helo=mail-pj1-x102a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz60-0003Ud-Uq for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:02 -0400 Received: by mail-pj1-x102a.google.com with SMTP id o68-20020a17090a0a4a00b001c686a48263so6075330pjo.1 for ; Sun, 20 Mar 2022 10:12: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=yC2sireZoOTYAuTYG5JxotkaWGRw4AVLDFu3n1FRWSw=; b=ga9KnqhL47LNO+pd9SEOECHzxpZHT8tgpKN9YEz06NgCaPr/6lCyH2omP9lCJeP+Bs ZzytrAcBTmIrHoZ0jvtncuzUocbLH0zX/YRB+5q344VpsHaSKgzWOvdLnock7HVlSFTr wqAGso3R/xHJwecSNHbqHV0SfQLFuinDvbpOlfDYGIFOC0iQGV1dQ4H4d59Z9NmDdQjh e8vh/y2yoOwF3FZH6qKwkoz90wy6gv3WK1h1UNed8kIfUyB89E4YGOC8wAkjo+1XOfbO 7uKhcPXik+IShYngulX4snz13DXi3TaoLcjz1LdqFJIPXZNRVSWSGyAFpLGP9IWiF7GU QgrQ== 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=yC2sireZoOTYAuTYG5JxotkaWGRw4AVLDFu3n1FRWSw=; b=6DG5bP4RctCIMKbs0bRDaz1iArRq/Av73uYSO2OPSwevUq/rZ3ymmGcDQG/Cf/4vHg z900WAzoVq6SP5EJJ1/Fqqr/4l7ZNSvJMhECtSaGp8zwM0gv7rKuQktP5eJ8xC/SrvLX IlX9L/KqY6Y1DknWKgwOihRlcAiXsKz9dalPWtXCk+py+baHnwUfkRUmFEgZXneyMtDD n9Brz/1dKLpDuMBhk1hh7OmHZodhMLtsHQJfjazKkH5srd8QgIbV8QW2vcTOTHWlSkBw Gl0aD8k73IaDhCF7bp52vxrGrjFRMnK+tw5R/bzEX5pMTa0EPCQMw+oHp11WrgTEejnJ nqqw== X-Gm-Message-State: AOAM533zZgWLamzFmxT6CJQH5lm1db6sE2uk4BQyERm5/5YMQilF3XFL P/aFbRwnQiSDgNp89KMdhoZlB3Vc/ujtPQ== X-Received: by 2002:a17:90b:38c9:b0:1c7:1ffb:533b with SMTP id nn9-20020a17090b38c900b001c71ffb533bmr640207pjb.220.1647796319663; Sun, 20 Mar 2022 10:11:59 -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.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 25/36] bsd-user: Use qemu_set_log_filename_flags Date: Sun, 20 Mar 2022 10:11:24 -0700 Message-Id: <20220320171135.2704502-26-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::102a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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" Perform all logfile setup in one step. Signed-off-by: Richard Henderson --- bsd-user/main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index d25d1c6015..2c8f8d1c19 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -405,16 +405,16 @@ int main(int argc, char **argv) } /* init debug */ - qemu_set_log_filename(log_file, &error_fatal); - if (log_mask) { - int mask; - - mask = qemu_str_to_log_mask(log_mask); - if (!mask) { - qemu_print_log_usage(stdout); - exit(1); + { + int mask = 0; + if (log_mask) { + mask = qemu_str_to_log_mask(log_mask); + if (!mask) { + qemu_print_log_usage(stdout); + exit(1); + } } - qemu_set_log(mask, &error_fatal); + qemu_set_log_filename_flags(log_file, mask, &error_fatal); } if (optind >= argc) { From patchwork Sun Mar 20 17:11:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553199 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp884221mag; Sun, 20 Mar 2022 10:33:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7WOKgT0vYypps5okSzM6rwEoISFyDA4vhXkLDt/ll94E/3zvZZ7/CFGrxDEFR/cAixKAs X-Received: by 2002:a05:622a:60f:b0:2e2:750:ce24 with SMTP id z15-20020a05622a060f00b002e20750ce24mr6527141qta.315.1647797633133; Sun, 20 Mar 2022 10:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797633; cv=none; d=google.com; s=arc-20160816; b=Vg4NP33VqunJyB+z8/yHWXXGNiX5Zcke6gl9D2kVEiJQT6B1YJSFpQQE7xqGLGCISM jkk9MOHexZxXRMxUGh1UAFuEh2BmDdPaF9ATZEMEddm9RCgZMFodH7wdSfYV3FXMTb5L djLw3AMl5TyPynQqPwwW7ANJD2exuz0UmpZmS9NkXs9+zLw5EadtiXWY21o1AI5s2jjr gfqxCQ2+Jd5R1fgkw67v78VzTVgsUVy1//UTwpryVq+eunRFb2I403qr6iPmFih4AADr 3XlB69qepCJOw52MxzD9c4H8qWpO/9756DjyGChDSdbSEqRWGCR5RDMLYMgc+clje+63 Tn6g== 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=tbvVNjefg+clp9cnxa2dTGnw4THGled3q05yu65oSKo=; b=Jn66S5wkwDs6DOmBnBw224oYaLA9A5Mmd8xRdMUjf88OC7Nq+anDTap2thVbcksaY3 UdCTAiQCxMm9V5G20iXq+LhB0+pDKl/gV+MtBINivVdXuK9i6JxfT15N9AwHm3aG5tEp lXs2Uw4ibCq0cZCAkzv7EpUbujJsEwpULGcHTc5UC3Nw/cRSxCEwZxt4rXDt3+4Sx0um sjmiV9c1GYxeAlBlGAgEOguRD/FaRseyOkMBmOmAj7snr0uChTmhFWa97Y0DVeXOIf0R iOS0sJTSPXS68oRHRW1aXW5TjVtN+kQq/wVNNbQqlswqWqwGPWCCPj8R7KZRdGu5yIg8 FfdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hqrARsdy; 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 c4-20020ac85184000000b002e1fbf3be5dsi1298310qtn.78.2022.03.20.10.33.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:33:53 -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=hqrARsdy; 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]:43066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzRA-0005ls-DA for patch@linaro.org; Sun, 20 Mar 2022 13:33:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz63-0000Eg-LF for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:03 -0400 Received: from [2607:f8b0:4864:20::533] (port=40499 helo=mail-pg1-x533.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz61-0003Uu-Vu for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:03 -0400 Received: by mail-pg1-x533.google.com with SMTP id w21so5045268pgm.7 for ; Sun, 20 Mar 2022 10:12:01 -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=tbvVNjefg+clp9cnxa2dTGnw4THGled3q05yu65oSKo=; b=hqrARsdyXj855FwNSqVrrxSYRCsaLSWD4vBMiFL621BnosRPBDuvANTOIwY2/Bl31U UPotp2yuG3PXcaI/fmrBZ8edO/CnWPpmdc8zCuyCyjeBvZ3vhui3kxAPGWi0M457lB4d FhKh3Ivl7BUv1lm6FeHfN2mSz689Jsvaa8Rg9ZGYXhp4NXs7P2qZdVSNkV/H68YxyKA7 RPTVwQ+4x34j68HfscjRUDE2468MmOCWnGuNyIzg+ZtRGWLCpFrOUEpjFquljqDdly84 aJsymWEXJvkMM4o6xLG5GCF6l8DNdY4hlv/iTtvUJI7J33sRAgrWCtUyNkoA4aLYRCjF mzdg== 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=tbvVNjefg+clp9cnxa2dTGnw4THGled3q05yu65oSKo=; b=4sUjBeEcGotJ86sR6meMDPNEKSaFYYQdizZDDvB7f6y1wPCM0gjE2x3ywoYHy6QFsw MCWdj/DdVF0e5H2KtME4CvqvbgAwQWo+49wrVRqpfvrwoD9Ik5Vrpas4ovQSMffUXuqM i8djohxlXeJzUPDVqqU6qtbBC7IsZIwoqmg140G6Uioygv+ghXMdBBUmwUQBoi7iAW/3 lEsh0yX2L+L7AIWsX3E4l6MchWp9AVGhEfDJkGTdKh9SfBdkv9z3z8Poh0fjFqN4FDKm GD3vx39mATefYI3rXmotgWTQIY6KfdRlv2scjJ3nmFw2XE/g6HaO1ge2EaSmXgdj4jHC JeGQ== X-Gm-Message-State: AOAM533OQl88Fg2FWBa3S5EfXWe/q3PMV0u3D9bCPo9Le5lQKveEWdmQ KF540ouSODba5akHRepZGrBtyphQoQ07SA== X-Received: by 2002:a63:5907:0:b0:382:2f93:5467 with SMTP id n7-20020a635907000000b003822f935467mr9381857pgb.460.1647796320720; Sun, 20 Mar 2022 10:12:00 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 26/36] linux-user: Use qemu_set_log_filename_flags Date: Sun, 20 Mar 2022 10:11:25 -0700 Message-Id: <20220320171135.2704502-27-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::533 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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" Perform all logfile setup in one step. Signed-off-by: Richard Henderson --- linux-user/main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 2bdee78019..75d13eff97 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -85,6 +85,7 @@ static bool enable_strace; * Used to support command line arguments overriding environment variables. */ static int last_log_mask; +static const char *last_log_filename; /* * When running 32-on-64 we should make sure we can fit all of the possible @@ -257,7 +258,7 @@ static void handle_arg_dfilter(const char *arg) static void handle_arg_log_filename(const char *arg) { - qemu_set_log_filename(arg, &error_fatal); + last_log_filename = arg; } static void handle_arg_set_env(const char *arg) @@ -643,7 +644,6 @@ int main(int argc, char **argv, char **envp) int i; int ret; int execfd; - int log_mask; unsigned long max_reserved_va; bool preserve_argv0; @@ -677,10 +677,9 @@ int main(int argc, char **argv, char **envp) optind = parse_args(argc, argv); - log_mask = last_log_mask | (enable_strace ? LOG_STRACE : 0); - if (log_mask) { - qemu_set_log(log_mask, &error_fatal); - } + qemu_set_log_filename_flags(last_log_filename, + last_log_mask | (enable_strace * LOG_STRACE), + &error_fatal); if (!trace_init_backends()) { exit(1); From patchwork Sun Mar 20 17:11:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553210 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp892769mag; Sun, 20 Mar 2022 10:54:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBT0vJkw++jfE5SaL0+TgGAF88VgXPV38pZa39j082srikvvpQYM/wP6ijn03pgVgndmp3 X-Received: by 2002:a0c:8e0b:0:b0:435:1779:7b22 with SMTP id v11-20020a0c8e0b000000b0043517797b22mr13480605qvb.63.1647798874353; Sun, 20 Mar 2022 10:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798874; cv=none; d=google.com; s=arc-20160816; b=ayB9Z4PIC9XbXp5cA8q6kGQzdJPcdupy0Dn3z91AZ9hYFqrTNe9QYYbeNgQ2rqYsID LbAbefj54iMOAn/RrJvTlCgaAYhmjIB29pOlsNskHLz/bfWOrScEj+MvlF17fudkg4OB 4cMCe7sa9EZSKnZr8atphSQlpGhkU/+SQ9pEY7Q//GZZt3D942OqjxZYGurE6pEaPvRt pTSEFNAX+x4Iax7JSd0vE6dqUAqKbriQnqUsGYMs4PGkbtl3qqXH3wPIGC/7q9Hjf5gX rigVbKSgPC34AjVBd7N8JGXMG3VMs7lXf6KZvf4xkeOa+GJX7hSgHoqB4nVNSBybfA+q FXGw== 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=X5VZGVfDRwsa6U5imM3TbqL1rDwZxZr3FYEMX2oqv64=; b=mRgpmN9l8jD9RobrEAS7jsPa9K+1fKQS8O3KLZUlr5oSdh0eGhf9ptOKxOzYeESB3v QJZDbfn23MANMdJCDc3hyqyo5cdKiofcAbhvAJXgHzxMp+YIMnYh2JFLN3MsTGVRO1Vq mNlj8+4vsmI0MIUkWbA6jWk1RNDC60bC11M2IHm63SFLuxJ8/hpps7bnGL5+qWLXkhDQ cquliT3swHQf5BVS4Pviq/wSaOCnqYcMZwGRRFGkUbckzgiSOKBaJlB7JxQOAl5PJ6S+ fywuZCQS9fSe1Z+u5Pv+Zrbx4vF+MSBvGGXVwrauZKxdcIDIdr4YVMqEyGtUV7qHRf9c GjKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gkvCUH+2; 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 u1-20020a05620a0c4100b0067e4be23882si1593912qki.199.2022.03.20.10.54.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:54:34 -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=gkvCUH+2; 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]:46406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzlB-0002Ia-US for patch@linaro.org; Sun, 20 Mar 2022 13:54:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz64-0000H9-8d for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:04 -0400 Received: from [2607:f8b0:4864:20::1031] (port=45830 helo=mail-pj1-x1031.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz62-0003V1-Rj for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:03 -0400 Received: by mail-pj1-x1031.google.com with SMTP id m11-20020a17090a7f8b00b001beef6143a8so12525038pjl.4 for ; Sun, 20 Mar 2022 10:12:02 -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=X5VZGVfDRwsa6U5imM3TbqL1rDwZxZr3FYEMX2oqv64=; b=gkvCUH+25Jp/H+u8K+OTbkHDz4ZpZx+i3HazrP92UjrcXmjhlzNvC8NA92KZia3mfa 2ZT42MycZHIDl8s7chTaKesh5WTKZ2UYHcwDGhK3/xyH39xgryJugYP17fF/kO7RASqe sS2e3MBgHx1i+W1Y5E7JLhrq6oVpGEciaiAvWhXl57TDNTGaL0sBkX2rhhBUDgJCvqG7 C/3v6hS0ki+j97+6C+Ka5do5lKbH9Zl68rKBtSmRyz3vV7mpoVMQMA7L2GS3jPpiIf/s 9QmXKmQdF6xwXZoGvDFlYqUiYI4Qo+n/Sl2k7mwHfhPEJQLXOK0GKHlFcO/liBb6jXUK lD7Q== 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=X5VZGVfDRwsa6U5imM3TbqL1rDwZxZr3FYEMX2oqv64=; b=Yr7aqi8fkV99XKzz6qad/txGbs04KC5XD75ny34Vpv31qIxGI9TVTKjEmsLwQ0YA4L +PXUpaVYH628oUZxUcTLCVG/iWmWkmaDB+9N52xjGxaRIhiTp8UaRV3TPkCrUgsNonHe B5y2dZtgiFLmip6YZm26pgXePNCBhrRXq7aSxOrB5Tx+NtHym7cPP4ElTVBV5m7QhxqK uTTNqUFcOxMxo23jO710GJ5+QQ2S+bI4Kpak0XQVZ6/juRWUtIzgcGAsVHl1QDrR5ANp 8H1F39TGai5HFlGp3onFt/INitEFJ8ZhFLRLkQEv4RxP0kNMh86nOk/r/MKsOSAmVbxA GYNg== X-Gm-Message-State: AOAM533NemXVAxki1G7s2KpgxYsspyhU3VcRekU4cfoqyUVMI/9h7LPT vt56lVjG5zNbbL5BvrYUxPmJ6X4k9M6fSA== X-Received: by 2002:a17:90a:4097:b0:1c6:ca92:7a83 with SMTP id l23-20020a17090a409700b001c6ca927a83mr11177526pjg.130.1647796321538; Sun, 20 Mar 2022 10:12:01 -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.00 (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 27/36] softmmu: Use qemu_set_log_filename_flags Date: Sun, 20 Mar 2022 10:11:26 -0700 Message-Id: <20220320171135.2704502-28-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::1031 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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" Perform all logfile setup at startup in one step. Signed-off-by: Richard Henderson --- softmmu/vl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 73296015af..81c91ec7b0 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2559,19 +2559,16 @@ static void qemu_process_early_options(void) #endif /* Open the logfile at this point and set the log mask if necessary. */ - if (log_file) { - qemu_set_log_filename(log_file, &error_fatal); - } - if (log_mask) { - int mask; - mask = qemu_str_to_log_mask(log_mask); - if (!mask) { - qemu_print_log_usage(stdout); - exit(1); + { + int mask = 0; + if (log_mask) { + mask = qemu_str_to_log_mask(log_mask); + if (!mask) { + qemu_print_log_usage(stdout); + exit(1); + } } - qemu_set_log(mask, &error_fatal); - } else { - qemu_set_log(0, &error_fatal); + qemu_set_log_filename_flags(log_file, mask, &error_fatal); } qemu_add_default_firmwarepath(); 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" }, From patchwork Sun Mar 20 17:11:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553211 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp893740mag; Sun, 20 Mar 2022 10:56:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybH3+ZZCtrGH+2eNbukVnoKVlkwmfMF9B66+Y0/j9NYXlHO1NCjwg/0X/m1llRcJOKm2s9 X-Received: by 2002:ac8:5dc6:0:b0:2e1:a763:d988 with SMTP id e6-20020ac85dc6000000b002e1a763d988mr14107244qtx.22.1647799002084; Sun, 20 Mar 2022 10:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647799002; cv=none; d=google.com; s=arc-20160816; b=nPErOqFkVOkKmM7Fp48ThTYzs6b0MNAwhTge35HdIBa5jxHa3okCYciPkq4xwPnJPl Oow3i10mQORkxwXd3bf6LAlZJp547iDlZECzLXcZ5kfrAR7INCZMdB/nNzWIC70bIFLb NXN/M7CufqR/sFbSjc4yE7Jd9htD0HFXwi+oR7r60cppBQrZBM2uHFSY3x1S736qm+4S lxBiu/TomW90yAGbxPFSoRbau1nrxnFWPb6+j53dr+iCd/RbPw7NRytJe7DtWebMO48N zqxdeI9znvZkH3N19c9LGavEeFUqHUNuKya8TPs7HlFPoLn6pvCF25KG8fGibTHBICnN b/iw== 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=bk/zAi7BLJglpoQ02+PCS2bvRMTlUag208O7lg3rkCQ=; b=rODvAvA8m9S9jQzG5tAL26duVhgBBQD8KGBVGNMrTdAYuVEjlitVrpCg4j2fWdWHXH yT8paiVrFWppdA2g+dc767A1uAlBRV/9AZdXPm5a9BnIlqKuGd91R+UWNk29Fk3kLTyG PV13O5q8THBUFo+FwrMVO5piuynSCdbJMaDaA/dKQZFRZ++jHIcaZETRHFvQ6CQmjAbX rPiwsSOuvGaThyCxDznh/qY5LyXowUwNYJN05XXzd2rtmiNBtsR3gZnIvLdBRpzBAO1R w+1GTY5sL23oOa7jwShvp0Kd4W4wXtKTRB62d8S3NmBxAdacshMRdQYMS+Q974PE3aFz Qb5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iDsHyq6p; 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 s3-20020a0c8d43000000b00440e46a7d29si1287169qvb.455.2022.03.20.10.56.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:56:42 -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=iDsHyq6p; 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]:52558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVznF-0006U1-JO for patch@linaro.org; Sun, 20 Mar 2022 13:56:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz66-0000Mx-Ko for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:06 -0400 Received: from [2607:f8b0:4864:20::52e] (port=41478 helo=mail-pg1-x52e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz64-0003Vi-Gy for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:05 -0400 Received: by mail-pg1-x52e.google.com with SMTP id o26so8742682pgb.8 for ; Sun, 20 Mar 2022 10:12:04 -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=bk/zAi7BLJglpoQ02+PCS2bvRMTlUag208O7lg3rkCQ=; b=iDsHyq6pt0hnEnGlxpQcGnartQoiIGXEO7lQ2h5w4KZCwySYV9hj+cf18DqtrDBaUo SbDqtxM3/g6CRXkx67YqqrGLPT8+UNoLkw/7JLxwyBerMI5/uBjwoRwaZiKeCvPIOWLy 9kgTpNXq5Db+geYDIL3KlJoFW9yD14NCZ8GQQm2a6jPQbhQLsPKJ6Nx0BRTxjx8+h5L0 3kYBtcRPR0Hrc1v+Froba5Z232NOWcKgi9HgPuE2yB/onJ4/MJHP5eQgTkLEk23JRZNM 7VyeCfFVM7w2uGGHClbCa/azwK8jp6nWis3uA5W+DfFxtFSGoU0yyj2KOADbdZpznmG8 VxIg== 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=bk/zAi7BLJglpoQ02+PCS2bvRMTlUag208O7lg3rkCQ=; b=cLt/6JCeSFZUUqMbdaM1kZja8tNrD8nv+UIRZna5YWxwu+ZVtpujpwB6o0XBLZjhC1 LKEcSBClzig573P1sj5jFd4rbIQGLH9m087H1z7W+YhVNhrMlPu7mJ/i0wbzf8W9nxXu 2OM9sYh3mh5fwZuV1m031OirMNOKktcgo+ID0S+ScraYMX50ntZDtXJW5VKaJbWYjPhC 3yuQH/H7ZlgTD7HdH/RliWhi1ozuvnzu1dKlbZYHo9rurIpJ1FzDKGuD8t+x8OSfqKTT flDjdgBjzNjBZFDIyMxV4hgdWMUZsVs2y2VqXCU/k23hforYFeq2Kr9ZQmTosKVx5JeN hgVQ== X-Gm-Message-State: AOAM530y1GuD7xxhTOIPY1+cRb0Bn/oiOzHTjxMviq4PtEvk1AihaofJ kP9X0yeNcHB71vPzed2Np/6UQbPXehQiKQ== X-Received: by 2002:a65:4c82:0:b0:380:3aee:6948 with SMTP id m2-20020a654c82000000b003803aee6948mr15178341pgt.527.1647796323164; Sun, 20 Mar 2022 10:12:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 29/36] util/log: Rename logfilename to global_filename Date: Sun, 20 Mar 2022 10:11:28 -0700 Message-Id: <20220320171135.2704502-30-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::52e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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" Rename to emphasize this is the file-scope global variable. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- util/log.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/util/log.c b/util/log.c index 691d6d7930..e559d37369 100644 --- a/util/log.c +++ b/util/log.c @@ -34,7 +34,7 @@ typedef struct QemuLogFile { FILE *fd; } QemuLogFile; -static char *logfilename; +static char *global_filename; static QemuMutex qemu_logfile_mutex; static QemuLogFile *qemu_logfile; int qemu_loglevel; @@ -160,8 +160,8 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, } } - g_free(logfilename); - logfilename = newname; + g_free(global_filename); + global_filename = newname; filename = newname; if (logfile) { @@ -170,7 +170,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, logfile = NULL; } } else { - filename = logfilename; + filename = global_filename; } #ifdef CONFIG_TRACE_LOG @@ -182,9 +182,8 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, * In all cases we only log if qemu_loglevel is set. * Also: * If not daemonized we will always log either to stderr - * or to a file (if there is a logfilename). - * If we are daemonized, - * we will only log if there is a logfilename. + * or to a file (if there is a filename). + * If we are daemonized, we will only log if there is a filename. */ need_to_open_file = log_flags && (!is_daemonized() || filename); From patchwork Sun Mar 20 17:11:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553203 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp885533mag; Sun, 20 Mar 2022 10:37:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMHlvXuC/HaYB6K4EMxFPb43NUSW4LW5W2mCGzkR++cgkro0m0eRcMRes8WLAUCkXvcltb X-Received: by 2002:ac8:5b8c:0:b0:2e1:e454:7fd1 with SMTP id a12-20020ac85b8c000000b002e1e4547fd1mr13732077qta.687.1647797828248; Sun, 20 Mar 2022 10:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797828; cv=none; d=google.com; s=arc-20160816; b=KMLoAQZ3JxpL9vzKffjj3pvuBVcR7exnfxm8D9JngOSOcbXgp1k8iDqKHikzcIULKj g4Su9g56D2sxDN5LLyqz4HVvpdo/4kR+Dw2Lxa40OtOCpd+iuwNam9+uCThTMBb0gGOc oWLhCd8ZGE23x/LJKe/iID5UnpABx4E6UOXKvzJldUxp/aLvQEBWBRLjyXIQaMr/UsBV LglShn0v5AR4a7EZZ9zeUdczSBELQQDfZtN+Hx/WVPSRuCkdWLll53eo9AF9GQoAgy3s 3K/IHPqf2KKR7Q9D2tVLrsm1+vLOcZx73n7R28lgsiyD7anftnWJkfsZw1YmIYSuncrA +UBA== 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=JKSI3UGozDJNBAh+QUx3PhImAK1Aw8+e6IP7+9yTeH4=; b=lNttUGKsxizI8EjO/wddq1r7bzTPM3upSn2tX1aFXfi1n+SDaTUv6zBu9FK1d5Y1jB eGXM9wwKBFjSGTJmRvOVQNXyOqldPgpUges2dS4Zyl1jOI27XcbM4+LABnd36MjwwfTx 9xMJ+6DR/JJcSjIusAdly/DZAMIjw5OA/3HvuQ6GBr+w4vvwaGmlb5qiFDhQuR4PWQ9K pvrqvOD88PaZyC0kL9kN7icHlKZbyxI4zsfVBV2bLYyTTuA93Ps94CNmy6jqmHY0PW2b P8p3uJUJjmxaoGUnwB9vRkQo/zSjUrdVffmz9RSeyqCeyv8oAS2ZQOC9WujPtbisnKUv Q0Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=euGRNYuM; 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 m124-20020a375882000000b0067e4be239d3si1247728qkb.536.2022.03.20.10.37.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:37:08 -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=euGRNYuM; 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]:51376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzUJ-0002wI-Ps for patch@linaro.org; Sun, 20 Mar 2022 13:37:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz67-0000OO-3m for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:07 -0400 Received: from [2607:f8b0:4864:20::631] (port=35668 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 1nVz65-0003Vu-Er for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:06 -0400 Received: by mail-pl1-x631.google.com with SMTP id n15so10901626plh.2 for ; Sun, 20 Mar 2022 10:12:05 -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=JKSI3UGozDJNBAh+QUx3PhImAK1Aw8+e6IP7+9yTeH4=; b=euGRNYuMu54gk93H0zl0aTUrj12Yy4p3/eCuCwxBUmSOJq2DsMFW6j7tLtHn8jUQ+u g4NOxa1yLlcLYC1H8fMA5WKBG6A3jlDjOYQe7clx0uV2yJi7CvJ2gEgGmnG3TLYqXk8Z CKYrxpVPsIBKi7SQtJEs5fNLjp7Tk3sNRjimJh+hUYVxkwyOwwBdKCJwiFTORI40kXod cgzAB5hvegQVapxdcZwXMcMtm9JDhnFW7A9+UbwTp5zCFaBDLvUgvfaMq+x1aS0imjhe rxQYbNrMi7MkIybqPs9hZHa41f/eFZjJWu9zVMknbX1AkBmJ6SVc+tFl4qimtx8p5tou wc5Q== 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=JKSI3UGozDJNBAh+QUx3PhImAK1Aw8+e6IP7+9yTeH4=; b=eIWJhXNUt0QIPaHndkAzsLbB3QeMvdDCIp9V/Oo2J44P77tXp4RnWACDbb1O+sx4hG +qXk2yD2vNPkT1v9Lm8w2NKUnAOo1wMAZApwtZjkw49twTihuOcQbuDiFk1ClwaTpuQW HSmP8CW7mWfjMBrlNC0yZY5WvQlvT/ZhxcA334jvj9Ik4qZ3cCrNN7mUPl2WgBO7LUwt kmrpNPiE7kvSenM1o2eCGO3SIFe6A73v4HqzdeOmrpXOJrs2/CNGkBsw+C0HMzhG0Wjw ez0NeFlIqwBOLp8SMefrFJPY0EMxIzMvM7iExarNOCd/nZiWVOF+VdN572WZI8yo7xiQ HlOQ== X-Gm-Message-State: AOAM530hTdhdFaO7ch1pyNfXThKcuPUxE+OxBY7J8NqZD9wmfsu810aa 9lkt+/7fuh9us49S3NNEWh3Mgr2oxBhB7A== X-Received: by 2002:a17:90b:390c:b0:1c6:259f:a4cd with SMTP id ob12-20020a17090b390c00b001c6259fa4cdmr32078135pjb.73.1647796324163; Sun, 20 Mar 2022 10:12:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 30/36] util/log: Rename qemu_logfile to global_file Date: Sun, 20 Mar 2022 10:11:29 -0700 Message-Id: <20220320171135.2704502-31-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" Rename to emphasize this is the file-scope global variable. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- util/log.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/util/log.c b/util/log.c index e559d37369..0676ce5bd6 100644 --- a/util/log.c +++ b/util/log.c @@ -36,7 +36,7 @@ typedef struct QemuLogFile { static char *global_filename; static QemuMutex qemu_logfile_mutex; -static QemuLogFile *qemu_logfile; +static QemuLogFile *global_file; int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; @@ -44,7 +44,7 @@ static GArray *debug_regions; /* Returns true if qemu_log() will really write somewhere. */ bool qemu_log_enabled(void) { - return qemu_logfile != NULL; + return global_file != NULL; } /* Returns true if qemu_log() will write somewhere other than stderr. */ @@ -54,7 +54,7 @@ bool qemu_log_separate(void) bool res = false; rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); + logfile = qatomic_rcu_read(&global_file); if (logfile && logfile->fd != stderr) { res = true; } @@ -69,7 +69,7 @@ FILE *qemu_log_lock(void) QemuLogFile *logfile; rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); + logfile = qatomic_rcu_read(&global_file); if (logfile) { qemu_flockfile(logfile->fd); return logfile->fd; @@ -133,7 +133,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, QemuLogFile *logfile; QEMU_LOCK_GUARD(&qemu_logfile_mutex); - logfile = qemu_logfile; + logfile = global_file; if (changed_name) { char *newname = NULL; @@ -165,7 +165,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, filename = newname; if (logfile) { - qatomic_rcu_set(&qemu_logfile, NULL); + qatomic_rcu_set(&global_file, NULL); call_rcu(logfile, qemu_logfile_free, rcu); logfile = NULL; } @@ -188,7 +188,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, need_to_open_file = log_flags && (!is_daemonized() || filename); if (logfile && !need_to_open_file) { - qatomic_rcu_set(&qemu_logfile, NULL); + qatomic_rcu_set(&global_file, NULL); call_rcu(logfile, qemu_logfile_free, rcu); return; } @@ -219,7 +219,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, logfile = g_new0(QemuLogFile, 1); logfile->fd = fd; - qatomic_rcu_set(&qemu_logfile, logfile); + qatomic_rcu_set(&global_file, logfile); } } From patchwork Sun Mar 20 17:11:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553204 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp887545mag; Sun, 20 Mar 2022 10:41:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk/Ige98G9yhYhn4MICgYP8F8mXLI7UMPOsIurnu3+CdZMTl6RGjmnJybGP2Cx/pf/Ywh1 X-Received: by 2002:a05:620a:a57:b0:67d:396a:8a9d with SMTP id j23-20020a05620a0a5700b0067d396a8a9dmr11039690qka.322.1647798117757; Sun, 20 Mar 2022 10:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798117; cv=none; d=google.com; s=arc-20160816; b=Ttf/8rVtOiP1skrSqunRu29EkC2vvLzUBBxkVJx3RnyUqyHeNNRJ6QbtuQCr5DPHAc +jS9ZebpPeNwn/cnoRozgfJpoWn2RZaNtMLGh7zvi5yE45XdbDrKUhZyA7xag5nmtNBL dUp50mL0soh9UhsAMGFeUJsCbgFNJD0g+p7v8t1Qcd7hqyRAqRs/KcCyJxoElfuHhQdw FqmeCuEVYgfrgifPiJgwRbEf90G75Fa66l5NbIRKQ6VyBgsbdiux+v7p15JenG9MIIFX GrO90Sb6IP8Gvk+5TqMYm9YuGy8lglKqBzqKA5UjvPG7WUSFHiVYGQy758VxTooEYi1x rroQ== 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=djzZiLuHHr1dL1YPwKuuIKcK6Xvam7Lxv67yyC1ECSo=; b=fnh7r8W/XlKDWkB7b6IeDlLSok8froIWlP0Ga95y9MCUxr5qn95uMFJD4md25Z6G0r UkU3oC+awYjxfv5iNWGXqyiybBN+mYkA00hcKS8l4myFVp32pgWqYP1UgMjHCBJjoE/p RfJss85wTPvWKv51ZiAfCdVR5bIoDHtHI1ScUU+9sPtaD0BEDeRHXhHjkgrYQjBNq+0E GarvT/RUoXih1zhUrzIYn063uMrGrydmRbQUFzyE1BzzwYlJt+eAMY+bdAvjO4tH8SrE uokbTOXJzkj9Cm/hMlmtr6UhblBEWdDtWARBekWJKQXlz8+0QkzNfEgvFccIjt95zH75 /Mkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wy13zcjz; 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 j6-20020a0cfd46000000b00440e46a7cb0si1263432qvs.334.2022.03.20.10.41.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:41:57 -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=Wy13zcjz; 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]:56330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzYy-0006FW-19 for patch@linaro.org; Sun, 20 Mar 2022 13:41:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz67-0000QM-TH for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:07 -0400 Received: from [2607:f8b0:4864:20::62d] (port=42804 helo=mail-pl1-x62d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz66-0003W6-DK for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:07 -0400 Received: by mail-pl1-x62d.google.com with SMTP id p17so10876873plo.9 for ; Sun, 20 Mar 2022 10:12:06 -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=djzZiLuHHr1dL1YPwKuuIKcK6Xvam7Lxv67yyC1ECSo=; b=Wy13zcjzhRw/UmQnsSco9nDFFjzFjYfWT1KH3Gh6A4G8t/b57AIgVHIj3iXoxzJEou 0E4OVjOV5P1NFKaqsYg7tNzHymvGfw4R6VIRS9tUUGjf/sSPnc9zObzqrDEkan8UgLGw Du5xr7uzYBQdIBxaUDvBOkx19rsDs+ZRUH/8FVM7gvKhrjjldxzsZ0eirS44birEfSBm 1ssgYAzLT6yHOFf7kJfFlAc893zehOiazsLdmOT5X3JFtKeJoCLNwHITQzJqjGLbgYqq 2xhXmVjOafJBuD10h4rqy+eoyx7gPnF4LdqjceEkSVNMQA3k5KpGIzk9tBhNQg+yDPVN 1YvA== 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=djzZiLuHHr1dL1YPwKuuIKcK6Xvam7Lxv67yyC1ECSo=; b=rgZwjVF+Uuoy4kPQQjil6ZytMro615g90IJpXbs+KEUfKoDWkv/7RiuYgMr+oZxw0G Za9rtcTHWqZC08GRN/cfDs7iNrAeusE2H2BVIYbG9/mxm0mJhd59k/e3W86M6VWMv85+ 5NKghzLoDJgsPZEsvZTWOqXkzK9PxOVSqCY56Y2YsT8BymfeuFN2MbPRhDoVQZsNszuV a2rLalMp1+dHn6igoiEdpicUmXh1r/7/gjneaWsuqoqYmM1A/YpjqQw1MsLk+YwXFvRS BVY8gMroCquND8QgPsGcyS48CNAUY8fxq3jxujcrPAMU7yNG41jA6KVcasgHoap+fnUk pAsw== X-Gm-Message-State: AOAM532VaDBXCoRnZberXA2Jn6x8IrQ+Y1pjtB3jkJNaa4N15k78jghO bkOMlGdqrJ/oYUlDQ+9WJSoLCZ2WmFD5fQ== X-Received: by 2002:a17:902:c949:b0:154:5215:1db1 with SMTP id i9-20020a170902c94900b0015452151db1mr2223793pla.163.1647796325188; Sun, 20 Mar 2022 10:12:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 31/36] util/log: Rename qemu_logfile_mutex to global_mutex Date: Sun, 20 Mar 2022 10:11:30 -0700 Message-Id: <20220320171135.2704502-32-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::62d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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" Rename to emphasize this covers the file-scope global variables. Signed-off-by: Richard Henderson --- util/log.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/util/log.c b/util/log.c index 0676ce5bd6..42b13e6bf1 100644 --- a/util/log.c +++ b/util/log.c @@ -34,9 +34,11 @@ typedef struct QemuLogFile { FILE *fd; } QemuLogFile; +/* Mutex covering the other global_* variables. */ +static QemuMutex global_mutex; static char *global_filename; -static QemuMutex qemu_logfile_mutex; static QemuLogFile *global_file; + int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; @@ -110,9 +112,9 @@ int qemu_log(const char *fmt, ...) return ret; } -static void __attribute__((__constructor__)) qemu_logfile_init(void) +static void __attribute__((__constructor__)) startup(void) { - qemu_mutex_init(&qemu_logfile_mutex); + qemu_mutex_init(&global_mutex); } static void qemu_logfile_free(QemuLogFile *logfile) @@ -132,7 +134,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, bool need_to_open_file; QemuLogFile *logfile; - QEMU_LOCK_GUARD(&qemu_logfile_mutex); + QEMU_LOCK_GUARD(&global_mutex); logfile = global_file; if (changed_name) { From patchwork Sun Mar 20 17:11:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553205 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp887794mag; Sun, 20 Mar 2022 10:42:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqIS06i3Z2JTwbRzeEdvGO0gYo+1xUmPB2mIQc22BHVp9xPQPy5SU8TsFgatUUH95y7Fkg X-Received: by 2002:ad4:5dcb:0:b0:43f:c947:bf13 with SMTP id m11-20020ad45dcb000000b0043fc947bf13mr13840789qvh.22.1647798153989; Sun, 20 Mar 2022 10:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798153; cv=none; d=google.com; s=arc-20160816; b=dqeP7aQLCOYHt8VhheOZh4D0NBYzpszYclyAagyej9BNCktN1d+ASRXE+TrX4p9zHO 8peFnySUeObhgOKCmUD2uIMbm7nITmG9xkLh9ZTIFZ56qfJK/CA7y4DJeKLLdjLzK/8i l0J0m3gOM3O7E0AKYzjjlSqpMNdkPSvB8TehtJx0dOolNnWTBubjeCp9tDGBqOuAO2bh ZR0D9NMO1q9kIT02qNSFGONZBnMo5yYs+4KUGXjQBoc0n24AoUeanFdQ2q2uIKT+SzDe 5sM5u/XSCyd+AopatRyqGDFQuDGERimgKEu6NZPn4wSLKSPzQY0OGeOjIabWBn6Mhzf9 qUMg== 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=gCBSdMHIZY9oTeXD1kIq/kpHPvmFkpcjsrAAZS31tWY=; b=U+tnTWIyiA7uFVWOo5QjiwIMxSwOAEykfkLAIQjlUEWua1dcHRpO6eKyHviRog8k5T STLP8WTkF/9ZtLET7pcsC8pl+QQqIv7qgC6UyeVu8uH+5fAtX3vQhTIhkwPfX4Cs1TF6 TTk38alQ/5kIisLoCByXCzen4Ewd1V0geNagMvlQT433z8/6L0QWcZYMF3lXiCyZgg6/ 6Dd+9Mz0FiUDcidef5UkSbl2pY2myMfHgVpC6Dm9f9M6p0PyRQCh5SswQVbm+jsUNYlo UeC6W05WxcDaf7Hq2kXiekUoKITjz7oj7A4KKNKOXroxOmycu/MVI7BnJkV5WBvufuLy eIwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/shiz6q"; 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 h22-20020a05620a401600b0067e4be237f0si1475426qko.53.2022.03.20.10.42.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:42:33 -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="B/shiz6q"; 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]:57032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzZZ-0006ik-Hw for patch@linaro.org; Sun, 20 Mar 2022 13:42:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz68-0000TM-W7 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:11 -0400 Received: from [2607:f8b0:4864:20::531] (port=37783 helo=mail-pg1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz67-0003WJ-Ae for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:08 -0400 Received: by mail-pg1-x531.google.com with SMTP id bc27so8737071pgb.4 for ; Sun, 20 Mar 2022 10:12:06 -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=gCBSdMHIZY9oTeXD1kIq/kpHPvmFkpcjsrAAZS31tWY=; b=B/shiz6qIymYhuvpj6wTahnrzdecbRNJ+ZyCC4mKOhd73lbUjNyp3v5htkzLKYMpWN LvSLdaU/Xvbd+QZr+7uVZvNj1Y4c3QJIRGruq2fWYjkwCwlsNjIoPyTdFt43RUKP0/2G Ju+p2iVUIVmUIYjAZa7yNXPFKLNyDq0ClJcQoLlWAwBMe1NVbi6Ej5Mb7ntHIe31uhTt hIy8g3PRQMQCO/hW9UH1uJgpYfkHOBNWtD09yfRtVtFwR4qpl83+r+iwNzfl6BEKFcyn DY1/MKnDK2xukst25SVKYk+8Np2FhIDRv8DeLwl5CtmTrv2xQs21Bll0kOLVu0tQjRgb Ct+w== 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=gCBSdMHIZY9oTeXD1kIq/kpHPvmFkpcjsrAAZS31tWY=; b=2O2QAI1X1tTlo/jdXgFv15oMKPPPfVq3ntZiEx3/WAKvTzIEOmMsQPJ8jLSk31idT2 N0f0BI7ifrok59JjIrUxMolO83RD2/NZ63oCvZT4MyIEyWaxsFXpcCh90fI+sgWouIjp dnKFklA+l85AcJXhpr6TjY2pDjYhq1tIEuHra6gKaPSg85ylsxRr016i2j2ag6oNzOgo 3+oVFu1aMRbThY00PzD/PYJ7GpQ77VT6mMFhT8c+WIgR7cn82eTySu7UQ+kr91gyAAyt Q7/KwldOysOFvyR7ZJLehNwt/Gzff8T9KdAinCJ1UbPWIjmhUzv4fRR6E/UnPjDdEk00 W89g== X-Gm-Message-State: AOAM533RXVTtP7B5iMh8ahwDTYHNZZpvDgiDMkQtQ70upkSIT+U+JK07 ZCtY2DXfPKgDHV3I5ViuYAJwZmfq0G7uyQ== X-Received: by 2002:a63:1223:0:b0:381:32e6:e56b with SMTP id h35-20020a631223000000b0038132e6e56bmr15007259pgl.375.1647796326031; Sun, 20 Mar 2022 10:12:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 32/36] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal Date: Sun, 20 Mar 2022 10:11:31 -0700 Message-Id: <20220320171135.2704502-33-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::531 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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" Only call is_daemonized once. We require the result on all paths after this point. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- util/log.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/log.c b/util/log.c index 42b13e6bf1..f1f6d09c90 100644 --- a/util/log.c +++ b/util/log.c @@ -132,6 +132,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, int log_flags, Error **errp) { bool need_to_open_file; + bool daemonized; QemuLogFile *logfile; QEMU_LOCK_GUARD(&global_mutex); @@ -187,7 +188,8 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, * or to a file (if there is a filename). * If we are daemonized, we will only log if there is a filename. */ - need_to_open_file = log_flags && (!is_daemonized() || filename); + daemonized = is_daemonized(); + need_to_open_file = log_flags && (!daemonized || filename); if (logfile && !need_to_open_file) { qatomic_rcu_set(&global_file, NULL); @@ -205,7 +207,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, return; } /* In case we are a daemon redirect stderr to logfile */ - if (is_daemonized()) { + if (daemonized) { dup2(fileno(fd), STDERR_FILENO); fclose(fd); /* This will skip closing logfile in qemu_logfile_free. */ @@ -213,7 +215,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, } } else { /* Default to stderr if no log file specified */ - assert(!is_daemonized()); + assert(!daemonized); fd = stderr; } From patchwork Sun Mar 20 17:11:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553212 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp894345mag; Sun, 20 Mar 2022 10:57:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWFWshgnc/JU1eJ4gbHn+xaA5sdsxuyIG70YjieyJrCD1HrfVqsq7diznACgUayKRoCYHK X-Received: by 2002:ad4:5945:0:b0:440:a706:3eb7 with SMTP id eo5-20020ad45945000000b00440a7063eb7mr13832690qvb.96.1647799078674; Sun, 20 Mar 2022 10:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647799078; cv=none; d=google.com; s=arc-20160816; b=zeIQ0ofmfEi4509qGviuSHncuUXvpW6SEKpHyBl+hHohzjLEpEq+YN/y8fCgXbBUXY yCqs0LC3tS71d7H8w5vk3ltxzC8TU+6AWH9TvDqNQ+aF9dOxAhnQ30fQUX3y232kG5uf AEkUcgsQHPhqtCKF/sy4iftqU1PNcT8P4tas626HTsoq5vxdbjabso/BamGYHXCBId/h 7ORKW98tfYhQepcfyDpdGf8Z9Wy6wlEbwUSxtI/34ldkSnt432NTYnvXByV8iLRxQZCh CfmCZKgMpFGyuc3bKSBWQnFid5E7W3wGJSrUzyKpfI+XtS86JIGp8dMlAaG4pNDcYIY5 a2rA== 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=x13T9/TUVJR5WOXUIsAjX0bOPDpTDGONzFnTqPFV7QM=; b=Sr7Dok/EQK1Hg58RjYfnTT6CWxCmLIs8d00MnpoIJrcciMt+vGhWtL4KyCcB7E0d/A 0rlb1/akMi0xQHeUb9aR3/zMmKZKmYppvCe/h5R/K6JdyCxEId3j24ZZuNZpblul7GJA RpG15xhPMW2wzV+XjheK8XB3oFLqF8K8YvKCbR+OnbUu5+L6UeRGix2yq3vv5p6gZekF wEl/Vi6qqGBMXl2IxFLo+y9GTwQrCh+r1xpZPuNr/xEb/knkDK163/8LMYD5QQT589GF zJHyTPcopxnUfk3ZzfQ8ot1dPD5t8h8cgiAgzauSWFclBLDKX9ErEV/a/Nkjq1SqPK/n Bc5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="N/rjaEk8"; 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 j8-20020a05620a410800b0067e4be23837si1516127qko.124.2022.03.20.10.57.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:57: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="N/rjaEk8"; 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]:55034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzoT-0008Dg-VN for patch@linaro.org; Sun, 20 Mar 2022 13:57:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz69-0000UB-W2 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:11 -0400 Received: from [2607:f8b0:4864:20::529] (port=45992 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz68-0003WY-Dg for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:09 -0400 Received: by mail-pg1-x529.google.com with SMTP id o13so8738411pgc.12 for ; Sun, 20 Mar 2022 10:12:07 -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=x13T9/TUVJR5WOXUIsAjX0bOPDpTDGONzFnTqPFV7QM=; b=N/rjaEk8feoQityhP/wli9aTjqe5JbWSn402XOk8mY5MeLJW4YLB23tM321QnAdC+K OpifwMWfYSSbexIszPRtvpyMxOuh8042aeUvHtgqfRZlIfMardfFvnRI3FqlS8Z64a47 bkVC2IiFHGF51CHrQQoP/dcTETZcXYIRJkVIdBRJKYf/NAWgGTzVHj7hmA/E1mE8Hb2H k2nH6JWKCNGa7qPfz5THtVMxjluxL567PhvuK8jn7rdMw1z5ozweYBHUL5wdaA2Zo5oR 13aHM6UdGRDEr0eiZa7/thTsTA8ndeXKJqL70hjNXDKV4dsmXS1j0TIq1vlI1VUYMojP 4gIQ== 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=x13T9/TUVJR5WOXUIsAjX0bOPDpTDGONzFnTqPFV7QM=; b=QcMw9LpGoeZsX3jsvDNjtQINAGAQEdwlShQZN1xD6BHTdx32+4JQS14lNW0PFU+ckA uXdP/iIDLR0Y4RIY9cvO3YPAcNlfe4fNUa8A8M/MOowuc9QG/1WzeaXv2bKJ2l+Ns91K Pi3qlzubGm6pdKMdpNtf4tx7TloLbHqo4fPM2k8ayZIiQX9QKZ2d6lEiLJieB1M/wEkc 2+BEY+qA/DEqoqK7lsMx9MldS70RHEsl8N30ISTKB41YZKBzb+wnsyEJDShLuPBWjTqj vrrLDlv8aXmw8kn/WQwfG6bxIqQCbBYlhbTTXRRSmmWp2Fmxg6J0ogfsRGdetKme38Cm b4IQ== X-Gm-Message-State: AOAM530IIayzEpsNeQhiVaMpZEcSWMBzcf0iZvLJSApAJa4v9aDmpABh 3CNH6QRWpu5kW7QPry4M2Eyx+JwOq9cOZw== X-Received: by 2002:a63:ad4d:0:b0:378:4b82:b881 with SMTP id y13-20020a63ad4d000000b003784b82b881mr15525869pgo.282.1647796327064; Sun, 20 Mar 2022 10:12:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 33/36] util/log: Combine two logfile closes Date: Sun, 20 Mar 2022 10:11:32 -0700 Message-Id: <20220320171135.2704502-34-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::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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" Merge the close from the changed_name block with the close from the !need_to_open_file block. Signed-off-by: Richard Henderson --- util/log.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/util/log.c b/util/log.c index f1f6d09c90..596de0050f 100644 --- a/util/log.c +++ b/util/log.c @@ -166,12 +166,6 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, g_free(global_filename); global_filename = newname; filename = newname; - - if (logfile) { - qatomic_rcu_set(&global_file, NULL); - call_rcu(logfile, qemu_logfile_free, rcu); - logfile = NULL; - } } else { filename = global_filename; } @@ -191,11 +185,12 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, daemonized = is_daemonized(); need_to_open_file = log_flags && (!daemonized || filename); - if (logfile && !need_to_open_file) { + if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); call_rcu(logfile, qemu_logfile_free, rcu); - return; + logfile = NULL; } + if (!logfile && need_to_open_file) { FILE *fd; From patchwork Sun Mar 20 17:11:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553207 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp891151mag; Sun, 20 Mar 2022 10:50:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4C0DUwTHQHncpb+RpVGoUsLeqPMN1ubs/T2DKSu58vGU3lqQRGEf9Mg15ltFmeO3R6csC X-Received: by 2002:ac8:5c4e:0:b0:2e2:104f:7257 with SMTP id j14-20020ac85c4e000000b002e2104f7257mr2236149qtj.544.1647798632079; Sun, 20 Mar 2022 10:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798632; cv=none; d=google.com; s=arc-20160816; b=xH2277ORewf2DUKHUt+uqtFCZdCG81ZYAoe+JiKq5ERhmhSmyC/N9INKoGFfmESwBn EWPt34h7AEQucOvwwfxSLjsX92LNOrBojnHfEnvInxOrAoOySlqkc2uGXmY0feTR/a/k FBBEJDRWwAycJs+C+uUdY37hRpY5D6ISca+VoXGVDQKIr/4dPGEC3Bqm7ohoBJVgNeyd uxNJSKTYHQJ90F1R61qr26C2Qd639hFg6M8fchnTaA7KOko/Fw5xqIiB6DLxXJ23L/j2 RAuoqCh9xQZDBsF82o+0JzpakZ55OacqS3L2XhVojRuv3xx99zHJMGy7Fm8RcK5FxGjn eljg== 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=HX+XPB3fiJw2JeMEDh6SpA1VcXxzUSznHfCOQKqLolk=; b=d3GCvA2t/0Ty8RSBCdXX0IAyaDjrBeUdWSsS/bjHNW9fBRa8Jah4YsLbil5wa66u6u 34m+/LUHVN80VW3o+qQrrXLv9h+XVCy3fjyLF7KpAgEGrD734djpA3CIksuLfCzXNP06 GuOq70ZATvYnFLpaIwIQBaH58/TS3seNFLlSPfE51Sh3p1souANGTbY8f9hfPgQ4HBk5 ljOXDxJbuNruB6pM2fkIVjW3RrBbgubCxRD2U8lUBXhxAQZnrgCCAfuj7vhfx/mKyx4/ A0O8cGieCgzIh3AEIpW05frmblIY1dAdvzE6zW4V4AZ7GvZn3VUV2+zZtYC5cxkw4tYl 0UuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DjlLVb6G; 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 t13-20020ac8588d000000b002e20c2a8992si1261902qta.292.2022.03.20.10.50.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:50:32 -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=DjlLVb6G; 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]:36722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzhH-00045a-Ld for patch@linaro.org; Sun, 20 Mar 2022 13:50:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz6B-0000UE-9V for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:12 -0400 Received: from [2607:f8b0:4864:20::434] (port=37575 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz69-0003Wr-EE for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:11 -0400 Received: by mail-pf1-x434.google.com with SMTP id t5so13673775pfg.4 for ; Sun, 20 Mar 2022 10:12:09 -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=HX+XPB3fiJw2JeMEDh6SpA1VcXxzUSznHfCOQKqLolk=; b=DjlLVb6GZCbSdFyEw0mXZZ4IMhKbhvPFBlTIeATr1n7nBqJ9834Zr+Q6ohGOQAi7A+ HSdW0LkSzZTjgspWWu/UtluSQM7FwF0YAORM2RrPc9jWWMnQ4ng9YhU2RL5lqRt2NeJK Rx6GEINtOOoro5qlC5oBVIb9/fEn+4oGrCGPOCBtbXysamsJ79IRuQTLXyjHHKpdQRSm PA/Y2IHLaSeYlf92lDDiLocFJQspKfrE5hP7AC6vuYusAsAGEW06pbWHRaZ30VQRKFtr HarbMetHhNtxjoXBi10ymy/KprCvpvRgwlmUWPKzp3M2YlaQgMKox9Fi95hogUi8uzX0 NTCw== 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=HX+XPB3fiJw2JeMEDh6SpA1VcXxzUSznHfCOQKqLolk=; b=oKZc2+Eyt5RJawXvCL2++gVmW1UOXDGq+/VNueTsI0nS9uQzrafwdMGluQd1PyyBXU lvmQT3IYMmqoBAvyLwVWelF2Bcvxn4uHrHnOxWt7HQK0a00DxFPQfRkGKUltYtsC7WY2 xKnu5Nscl812qUr17qnNoY7AfYk5TBFznbV5iSx94Cxb1/eXsTqcM7id9hkPfhznVarI fvAx3vOcOMXZZyAQXubBsMhrIJsWlLorANC3WoThttc7dHmGL0f1ZJBn4V9mc1prFm45 K5bljLDVg/XMSPgmc60UStcFs5R1Tj+uvbs+pp+K7ixJ8AlzpOiNYwc5ndIGwBrC2sTV 2L6g== X-Gm-Message-State: AOAM530rW+Axx6jBdC37woWEO9HKO1liTnTa63pl2s5/PuTYCgLli7sg 0Fw/GaZWkoMJD8qv2aD+NCxVnjTi6m+BPQ== X-Received: by 2002:a63:2259:0:b0:382:294c:5bee with SMTP id t25-20020a632259000000b00382294c5beemr10779401pgm.387.1647796327912; Sun, 20 Mar 2022 10:12:07 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 34/36] util/log: Rename QemuLogFile to RCUCloseFILE Date: Sun, 20 Mar 2022 10:11:33 -0700 Message-Id: <20220320171135.2704502-35-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::434 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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" s/QemuLogFile/RCUCloseFILE/ s/qemu_logfile_free/rcu_close_file/ Emphasize that this is only a carrier for passing a pointer to call_rcu for closing, and not the real logfile. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- util/log.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/util/log.c b/util/log.c index 596de0050f..e966d1091d 100644 --- a/util/log.c +++ b/util/log.c @@ -29,15 +29,15 @@ #include "qemu/rcu.h" -typedef struct QemuLogFile { +typedef struct RCUCloseFILE { struct rcu_head rcu; FILE *fd; -} QemuLogFile; +} RCUCloseFILE; /* Mutex covering the other global_* variables. */ static QemuMutex global_mutex; static char *global_filename; -static QemuLogFile *global_file; +static RCUCloseFILE *global_file; int qemu_loglevel; static int log_append = 0; @@ -52,7 +52,7 @@ bool qemu_log_enabled(void) /* Returns true if qemu_log() will write somewhere other than stderr. */ bool qemu_log_separate(void) { - QemuLogFile *logfile; + RCUCloseFILE *logfile; bool res = false; rcu_read_lock(); @@ -68,7 +68,7 @@ bool qemu_log_separate(void) FILE *qemu_log_lock(void) { - QemuLogFile *logfile; + RCUCloseFILE *logfile; rcu_read_lock(); logfile = qatomic_rcu_read(&global_file); @@ -117,14 +117,12 @@ static void __attribute__((__constructor__)) startup(void) qemu_mutex_init(&global_mutex); } -static void qemu_logfile_free(QemuLogFile *logfile) +static void rcu_close_file(RCUCloseFILE *r) { - g_assert(logfile); - - if (logfile->fd != stderr) { - fclose(logfile->fd); + if (r->fd != stderr) { + fclose(r->fd); } - g_free(logfile); + g_free(r); } /* enable or disable low levels log */ @@ -133,7 +131,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, { bool need_to_open_file; bool daemonized; - QemuLogFile *logfile; + RCUCloseFILE *logfile; QEMU_LOCK_GUARD(&global_mutex); logfile = global_file; @@ -187,7 +185,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); - call_rcu(logfile, qemu_logfile_free, rcu); + call_rcu(logfile, rcu_close_file, rcu); logfile = NULL; } @@ -205,7 +203,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, if (daemonized) { dup2(fileno(fd), STDERR_FILENO); fclose(fd); - /* This will skip closing logfile in qemu_logfile_free. */ + /* This will skip closing logfile in rcu_close_file. */ fd = stderr; } } else { @@ -216,7 +214,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, log_append = 1; - logfile = g_new0(QemuLogFile, 1); + logfile = g_new0(RCUCloseFILE, 1); logfile->fd = fd; qatomic_rcu_set(&global_file, logfile); } From patchwork Sun Mar 20 17:11:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553201 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp885183mag; Sun, 20 Mar 2022 10:36:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT1vo5u4coc6Uk0tQRoo1EDC2EXevDci1FdYKeZcckfYAIWWzxFaWUWPGs2EVGQx49FVPk X-Received: by 2002:ad4:5fcb:0:b0:440:aa13:bc81 with SMTP id jq11-20020ad45fcb000000b00440aa13bc81mr13393170qvb.53.1647797770518; Sun, 20 Mar 2022 10:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797770; cv=none; d=google.com; s=arc-20160816; b=QS1nTiJ6+0pA3tBLSBnxurkKU82L48zNXK3YHkpewKJeIj6VKtZXfzTMw8gvt37a0F ZneaDWR5qaxf0ApKr0+bjC8TQzJtfpHATeE0Cj+R03wGeIgGZUD5gZJdMzLb3T5ihMNy ZGVbeRJQ+aFJMEjuZKmPTxIKKd0m7WwyBqIxrLBpyiqm4DL1llhlXgB2kqrszRaJo/t5 jwRr4O2CzQAcDhUF7lv8MwElvPmVshplSAhQphJVoF1bRwptfdl2If0PE2xEhatJB7y7 u3JUS9rmVPdoUgxxhK4rS9nrExTZv0ujzwcyTrVhPFOsc54IMnq1D+/ewHypP4aC+6kf iIzA== 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=v5msDAveF1p/6j9G29fbPZtpzPMOaY2gnc7JkYmq63w=; b=T0cFMWzB2zz0+yNJMQUe1Gx1ibG3RVgDiChk5OOOJLAY2sLWSkVchZGafwZtDvZ/11 Uk4oUyN0RLbweqlupr2jl8IZr8gNceKZ08f1SEly8YmY8qBdQ0V1LIlhVEcwRgyzAZWw altF9lB6biNL+g9ElSN+jLVNwlSaavqeCcVd/Slm0CtbqAz7imB1N1Kz4+tVquQhv4lT XkjQxIOE/LrSlbzf6wEA6sX8sLEY/PYgraEIgOnqwSPGaoUqiUP3/eHTkhX7ElacFwiC LEWnl7hX1jzKkVChdCLcBOrs398T42kzSIHRTfLMdGmTYlDKNXKcOO7t3XuK0Xzw5FLG Bu8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PiNw5nvl; 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 s1-20020a05620a29c100b0067e4be238cdsi1548091qkp.274.2022.03.20.10.36.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:36:10 -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=PiNw5nvl; 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]:48600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzTO-00014k-3u for patch@linaro.org; Sun, 20 Mar 2022 13:36:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz6B-0000Ur-Us for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:13 -0400 Received: from [2607:f8b0:4864:20::433] (port=38464 helo=mail-pf1-x433.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz6A-0003X5-6c for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:11 -0400 Received: by mail-pf1-x433.google.com with SMTP id p5so7544160pfo.5 for ; Sun, 20 Mar 2022 10:12:09 -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=v5msDAveF1p/6j9G29fbPZtpzPMOaY2gnc7JkYmq63w=; b=PiNw5nvllji+Qd62QygTkiMoibJbavRha09GzDnTFMCVjkSnoatM0plCq4vdNKV9dO oFtdZ0gP5unXBVkvSPlronwPnMAivDU+5/H1bu6Wh1ZbD3ztjC2spW7QYEtSQvrlvG5P e42XgmAhbz4H4y3cQusolSx9k92AUBSHDJ74NslLblnoOizs8QVFXSG4wIWaYgf2oGfY GYYymBVlnLAefORFOcMq2NHKFNgsDO58oChiHgKEwcg0G9NTnzWSDL9sEPtPbjRNGw0o cZmcpNp4950xBBILEBAzqH8svektpXhJsE5+9zIOSLV+Nnod4rWinmyKqSI1x6SdNBfY YkqQ== 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=v5msDAveF1p/6j9G29fbPZtpzPMOaY2gnc7JkYmq63w=; b=t56xEfiA2MLU0gELd+HJuTdVwZI2NuWpLQ4f2JSRKA9N/wFvlhcWln4eGFPCMdm8Bo xh0RBzIwLsJSXnWzyeft6BJRyKZ1xOSx+lSlB654UIMRseMi79GQZrrTFrFODWR9JObD 3seze0bzBM4mXcnxh9oDOiVdaOK9rN9bHskIFt3fE8EGnoWHgv1gqUmIjQQ9i1u6PAeo use3//qJm9mgLhIRkRPOoR364Sk/t6gmfRhBxLaovsPItldCv8eggmuT7D1MEUlsKPuq EI48opR+1tti1C6T3lRRJlokQFQqamdcFS+RZppCOiRCxo56ghAmIIIKNqTv0sNwhHCf 6wgg== X-Gm-Message-State: AOAM533ZWRLzjEAy4BnEpN8mCWrI/EWENLppv7++RhcSpPI94O7h3NQf MER+MCwaKtg2divgXWRd5aKCZsGTNS2oiw== X-Received: by 2002:a05:6a00:140c:b0:4e1:530c:edc0 with SMTP id l12-20020a056a00140c00b004e1530cedc0mr19916610pfu.18.1647796328696; Sun, 20 Mar 2022 10:12:08 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 35/36] util/log: Limit RCUCloseFILE to file closing Date: Sun, 20 Mar 2022 10:11:34 -0700 Message-Id: <20220320171135.2704502-36-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::433 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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" Use FILE* for global_file. We can perform an rcu_read on that just as easily as RCUCloseFILE*. This simplifies a couple of places, where previously we required taking the rcu_read_lock simply to avoid racing to dereference RCUCloseFile->fd. Only allocate the RCUCloseFile prior to call_rcu. Signed-off-by: Richard Henderson --- util/log.c | 67 +++++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/util/log.c b/util/log.c index e966d1091d..713a0744be 100644 --- a/util/log.c +++ b/util/log.c @@ -37,7 +37,7 @@ typedef struct RCUCloseFILE { /* Mutex covering the other global_* variables. */ static QemuMutex global_mutex; static char *global_filename; -static RCUCloseFILE *global_file; +static FILE *global_file; int qemu_loglevel; static int log_append = 0; @@ -46,46 +46,37 @@ static GArray *debug_regions; /* Returns true if qemu_log() will really write somewhere. */ bool qemu_log_enabled(void) { - return global_file != NULL; + return qatomic_read(&global_file) != NULL; } /* Returns true if qemu_log() will write somewhere other than stderr. */ bool qemu_log_separate(void) { - RCUCloseFILE *logfile; - bool res = false; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&global_file); - if (logfile && logfile->fd != stderr) { - res = true; - } - rcu_read_unlock(); - return res; + FILE *logfile = qatomic_read(&global_file); + return logfile && logfile != stderr; } /* Lock/unlock output. */ FILE *qemu_log_lock(void) { - RCUCloseFILE *logfile; + FILE *logfile; rcu_read_lock(); logfile = qatomic_rcu_read(&global_file); if (logfile) { - qemu_flockfile(logfile->fd); - return logfile->fd; + qemu_flockfile(logfile); } else { rcu_read_unlock(); - return NULL; } + return logfile; } -void qemu_log_unlock(FILE *fd) +void qemu_log_unlock(FILE *logfile) { - if (fd) { - fflush(fd); - qemu_funlockfile(fd); + if (logfile) { + fflush(logfile); + qemu_funlockfile(logfile); rcu_read_unlock(); } } @@ -93,16 +84,16 @@ void qemu_log_unlock(FILE *fd) /* Return the number of characters emitted. */ int qemu_log(const char *fmt, ...) { - FILE *f = qemu_log_lock(); + FILE *logfile = qemu_log_lock(); int ret = 0; - if (f) { + if (logfile) { va_list ap; va_start(ap, fmt); - ret = vfprintf(f, fmt, ap); + ret = vfprintf(logfile, fmt, ap); va_end(ap); - qemu_log_unlock(f); + qemu_log_unlock(logfile); /* Don't pass back error results. */ if (ret < 0) { @@ -119,9 +110,7 @@ static void __attribute__((__constructor__)) startup(void) static void rcu_close_file(RCUCloseFILE *r) { - if (r->fd != stderr) { - fclose(r->fd); - } + fclose(r->fd); g_free(r); } @@ -131,7 +120,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, { bool need_to_open_file; bool daemonized; - RCUCloseFILE *logfile; + FILE *logfile; QEMU_LOCK_GUARD(&global_mutex); logfile = global_file; @@ -185,37 +174,37 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); - call_rcu(logfile, rcu_close_file, rcu); + if (logfile != stderr) { + RCUCloseFILE *r = g_new0(RCUCloseFILE, 1); + r->fd = logfile; + call_rcu(r, rcu_close_file, rcu); + } logfile = NULL; } if (!logfile && need_to_open_file) { - FILE *fd; - if (filename) { - fd = fopen(filename, log_append ? "a" : "w"); - if (!fd) { + logfile = fopen(filename, log_append ? "a" : "w"); + if (!logfile) { error_setg_errno(errp, errno, "Error opening logfile %s", filename); return; } /* In case we are a daemon redirect stderr to logfile */ if (daemonized) { - dup2(fileno(fd), STDERR_FILENO); - fclose(fd); + dup2(fileno(logfile), STDERR_FILENO); + fclose(logfile); /* This will skip closing logfile in rcu_close_file. */ - fd = stderr; + logfile = stderr; } } else { /* Default to stderr if no log file specified */ assert(!daemonized); - fd = stderr; + logfile = stderr; } log_append = 1; - logfile = g_new0(RCUCloseFILE, 1); - logfile->fd = fd; qatomic_rcu_set(&global_file, logfile); } } From patchwork Sun Mar 20 17:11:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553208 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp891445mag; Sun, 20 Mar 2022 10:51:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxVI8kpZasYlgSlL40Vs1ALtNYDvaLkcXsA6/4bDNCYYFAs1nZodGBaXSRrhwGG4i8GQVt X-Received: by 2002:ad4:574a:0:b0:435:9ce5:c376 with SMTP id q10-20020ad4574a000000b004359ce5c376mr13793052qvx.129.1647798672504; Sun, 20 Mar 2022 10:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798672; cv=none; d=google.com; s=arc-20160816; b=o6exG+nJwSaiunU/9jvMzE589sbnBD60VNopjO48ZizifVEOy0D6qbBWTixO2QW95G 0ton15WBNmkY7PKCQmD24BC2XoUwNsMHWIzqLsRbsN3pO+stp/f4VxMlmyO4P2CeEazr Kk/Vh4cnEKNlcDu4JBoSnAlvdhfzktOGD5tw/LJG4gTWMCVH5SfcDdtG3kUKHgu4FfUy SuK7aplvf41bo3D7RL+PW1Nf8dnWl70sY2PYvWd6ZlQRyqTY7ZAio+sFSEuaeNqT1igD pQtiR2cAfHWqpBPLVbuhlHP+ud3kZxXauvBF/URXdtjtiCfoiq8UOnc/oPzspb1nu5go KLPA== 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=6BKjhVe9YK8zHmub6rTwH9wtPi9i652/xRGlwJ2BHBo=; b=KKPit8+c0sCjYZ7ter8Vl012KJCWw+QdTC3LYcIqsGI7jzYPWKN15CB0Jf/cjet4OT 3i66AZld5RYUnsSm41VDDC8QqDVJIumGj0q9Ek+4Myo+ajkZmJE4dDBqTHg7ivalBkkz MFwo5pdSLx7t10J0Nt+CU6VKrCOaSJZUyLoJfe6WdAe4z3JugtPgd3LNvbDIwwon+NFb CU9w3T7hdln5NderFHPBRifW35ew1RAFqusgR6NKiUfU+Tp7qE1peWFn6o1xCyTwSuRw TXJofEJQMzKFN/BWaag6TAR2R2XrFjdpIG0qTTOhNCQn0N5j9/E4DiH0o2KgDwFE3YEq VK5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ErDUB/8Z"; 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 j25-20020a05620a147900b0067e4be23939si1320674qkl.382.2022.03.20.10.51.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:51:12 -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="ErDUB/8Z"; 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]:37418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzhw-0004a5-27 for patch@linaro.org; Sun, 20 Mar 2022 13:51:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz6C-0000V9-Sc for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:13 -0400 Received: from [2607:f8b0:4864:20::430] (port=43708 helo=mail-pf1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz6A-0003XL-Vv for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:12 -0400 Received: by mail-pf1-x430.google.com with SMTP id t2so13637259pfj.10 for ; Sun, 20 Mar 2022 10:12:10 -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=6BKjhVe9YK8zHmub6rTwH9wtPi9i652/xRGlwJ2BHBo=; b=ErDUB/8ZqoTuLoh6+Jm8ZdyvPbPilwgCSxkF/IhrBrQ968LwARoP0Zeo4drZqKwIns 6vKAF1b5xlC1Vr2o4LCEmIo9lDCo0R2+UgWwmWqYxISiM0qy1KPNv9XUkf5UO5eltFAa aqsUMLbSWEZSrW5bwP/j9SX53Xbzh03q2cZQ5BAJfoxkLYfpcd3nv/tHQfXDSAhyluNV REF3UUyWCKoprsXYBTfUc0bILcdTH/4PdcbEJ/BjmbKtnuU3LFxwMhedgNuawi9gJpQE V4j2xfDZHDPaXGkO7xO6SQ5hN+ZLoeczCYlW5UhI+83/9nHqqzBnQ5wEG8/o34Vw6InT I/eA== 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=6BKjhVe9YK8zHmub6rTwH9wtPi9i652/xRGlwJ2BHBo=; b=sDZrvs3tcIeatUjGifzR6aMPbnDKnpOmg1YhgIqIMIyjqHwkBL9shwSXdYSniFSVCu +O/O3Rd2AikoITRNe3QRhfPPiZOcq6p2leBH6CnUxQ0aIcmtdCU9XBAM6fULYOhQj0RU VsYik0ezlh/ap+2ZV5Q315caGRjMx9jCUrY3a7yz0oKUty+iIIrIlEewBMSOnR1Ee+4c aXuTY3miarRt/zXVEDKST6ZJg1DbOQF8WggTLIH5NKPlGtSBJl5Lugz2XPKGfX/hv55t yB/0w0XJhrKT4JyPbi7G1xmEMxh3z2y8hkALZZmvpB26r2YmuAjfhvUp2VPiUtr/FpYZ HdzQ== X-Gm-Message-State: AOAM533fqoZQUZWN0FN3eoa88IBkzMyYYP2KHXfiWHNK00ACB1Lv0ttH 9De0lCEEM7gv5qbtoUYxMlfHo5VfUeA76g== X-Received: by 2002:a63:1620:0:b0:375:948e:65bf with SMTP id w32-20020a631620000000b00375948e65bfmr15541465pgl.49.1647796329664; Sun, 20 Mar 2022 10:12:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 36/36] util/log: Support per-thread log files Date: Sun, 20 Mar 2022 10:11:35 -0700 Message-Id: <20220320171135.2704502-37-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::430 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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" Add a new log flag, tid, to turn this feature on. Require the log filename to be set, and to contain %d. Do not allow tid to be turned off once it is on, nor let the filename be change thereafter. This avoids the need for signalling each thread to re-open on a name change. Signed-off-by: Richard Henderson --- include/qemu/log.h | 1 + util/log.c | 130 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 103 insertions(+), 28 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 783faec309..6455e47010 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -34,6 +34,7 @@ bool qemu_log_separate(void); #define CPU_LOG_PLUGIN (1 << 18) /* LOG_STRACE is used for user-mode strace logging. */ #define LOG_STRACE (1 << 19) +#define LOG_PER_THREAD (1 << 20) /* Lock/unlock output. */ diff --git a/util/log.c b/util/log.c index 713a0744be..0da67c55de 100644 --- a/util/log.c +++ b/util/log.c @@ -38,22 +38,34 @@ typedef struct RCUCloseFILE { static QemuMutex global_mutex; static char *global_filename; static FILE *global_file; +static __thread FILE *thread_file; int qemu_loglevel; -static int log_append = 0; +static bool log_append; +static bool log_per_thread; static GArray *debug_regions; /* Returns true if qemu_log() will really write somewhere. */ bool qemu_log_enabled(void) { - return qatomic_read(&global_file) != NULL; + return log_per_thread || qatomic_read(&global_file) != NULL; } /* Returns true if qemu_log() will write somewhere other than stderr. */ bool qemu_log_separate(void) { FILE *logfile = qatomic_read(&global_file); - return logfile && logfile != stderr; + return log_per_thread || (logfile && logfile != stderr); +} + +static int log_thread_id(void) +{ +#ifdef __linux__ + return gettid(); /* ??? need syscall before glibc 2.30 */ +#else + static int counter; + return qatomic_fetch_inc(&counter); +#endif } /* Lock/unlock output. */ @@ -62,13 +74,27 @@ FILE *qemu_log_lock(void) { FILE *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&global_file); - if (logfile) { - qemu_flockfile(logfile); - } else { - rcu_read_unlock(); + logfile = thread_file; + if (!logfile) { + if (log_per_thread) { + g_autofree char *filename + = g_strdup_printf(global_filename, log_thread_id()); + logfile = fopen(filename, "w"); + if (!logfile) { + return NULL; + } + thread_file = logfile; + } else { + rcu_read_lock(); + logfile = qatomic_rcu_read(&global_file); + if (!logfile) { + rcu_read_unlock(); + return NULL; + } + } } + + qemu_flockfile(logfile); return logfile; } @@ -77,7 +103,9 @@ void qemu_log_unlock(FILE *logfile) if (logfile) { fflush(logfile); qemu_funlockfile(logfile); - rcu_read_unlock(); + if (!log_per_thread) { + rcu_read_unlock(); + } } } @@ -114,40 +142,74 @@ static void rcu_close_file(RCUCloseFILE *r) g_free(r); } +/** + * valid_filename_template: + * + * Validate the filename template. Require %d if per_thread, allow it + * otherwise; require no other % within the template. + * Return 0 if invalid, 1 if stderr, 2 if strdup, 3 if pid printf. + */ +static int valid_filename_template(const char *filename, + bool per_thread, Error **errp) +{ + if (filename) { + char *pidstr = strstr(filename, "%"); + + if (pidstr) { + /* We only accept one %d, no other format strings */ + if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { + error_setg(errp, "Bad logfile template: %s", filename); + return 0; + } + return per_thread ? 2 : 3; + } + } + if (per_thread) { + error_setg(errp, "Filename template with '%%d' required for 'tid'"); + return 0; + } + return filename ? 2 : 1; +} + /* enable or disable low levels log */ static void qemu_set_log_internal(const char *filename, bool changed_name, int log_flags, Error **errp) { bool need_to_open_file; bool daemonized; + bool per_thread; FILE *logfile; QEMU_LOCK_GUARD(&global_mutex); logfile = global_file; + per_thread = log_flags & LOG_PER_THREAD; + if (changed_name) { char *newname = NULL; /* - * Allow the user to include %d in their logfile which will be - * substituted with the current PID. This is useful for debugging many - * nested linux-user tasks but will result in lots of logs. - * - * filename may be NULL. In that case, log output is sent to stderr + * Once threads start opening their own log files, we have no + * easy mechanism to tell them all to close and re-open. + * There seems little cause to do so either -- this option + * will most often be used at user-only startup. */ - if (filename) { - char *pidstr = strstr(filename, "%"); + if (log_per_thread) { + error_setg(errp, "Cannot change log filename after setting 'tid'"); + return; + } - if (pidstr) { - /* We only accept one %d, no other format strings */ - if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { - error_setg(errp, "Bad logfile format: %s", filename); - return; - } - newname = g_strdup_printf(filename, getpid()); - } else { - newname = g_strdup(filename); - } + switch (valid_filename_template(filename, per_thread, errp)) { + case 0: + return; /* error */ + case 1: + break; /* stderr */ + case 2: + newname = g_strdup(filename); + break; + case 3: + newname = g_strdup_printf(filename, getpid()); + break; } g_free(global_filename); @@ -155,8 +217,17 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, filename = newname; } else { filename = global_filename; + if (per_thread && !valid_filename_template(filename, true, errp)) { + return; /* error */ + } } + /* Once the per-thread flag is set, it cannot be unset. */ + if (per_thread) { + log_per_thread = true; + } + /* The flag itself is not relevant for need_to_open_file. */ + log_flags &= ~LOG_PER_THREAD; #ifdef CONFIG_TRACE_LOG log_flags |= LOG_TRACE; #endif @@ -165,12 +236,13 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, /* * In all cases we only log if qemu_loglevel is set. * Also: + * If per-thread, open the file for each thread in qemu_log_lock. * If not daemonized we will always log either to stderr * or to a file (if there is a filename). * If we are daemonized, we will only log if there is a filename. */ daemonized = is_daemonized(); - need_to_open_file = log_flags && (!daemonized || filename); + need_to_open_file = log_flags && !per_thread && (!daemonized || filename); if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); @@ -355,6 +427,8 @@ const QEMULogItem qemu_log_items[] = { #endif { LOG_STRACE, "strace", "log every user-mode syscall, its input, and its result" }, + { LOG_PER_THREAD, "tid", + "open a separate log file per thread; filename must contain '%d'" }, { 0, NULL, NULL }, };