From patchwork Sat Mar 26 13:24:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554346 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6423225mag; Sat, 26 Mar 2022 06:29:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCXs01YDn4GYMp4eLvGKZlvcICpjB4T+wHcEXJM84MQF8HsmvIpYE940wZecnqueZxQvyx X-Received: by 2002:a05:6214:1cc2:b0:435:1c62:62cc with SMTP id g2-20020a0562141cc200b004351c6262ccmr13261012qvd.26.1648301342472; Sat, 26 Mar 2022 06:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301342; cv=none; d=google.com; s=arc-20160816; b=XXCV0Ijgl3FCkFB8yZdYIyHmf2Vsv6LHN/4hu5IT/W+MR6vfSYOjtIy1MtOUYmAz4a 8CQaAzwStUyThQ+Qr80aRAQNoTkBwSe0hoPITorXOIffIBAqhCQNpDtXmBia9Sgjx0mM zX00xB+PoMCQKKVOIffirCSzuUr+pFOO62S3I9lopjn7H4jkOgEQtxEizxvXvGoUnxyl m/dY9SYibIuDiuJznwDkjPmpz+S9wn4zBnRRJekeNnjLaiH7vJfZ20rcVuXoUTmM4yI3 s4v3nNnrunZCrCvXn0jSMnJGuPtb0RN7w50Ty8wP/kT6FYyMtn2qVtQBrstZSGIQW5QI Y+tg== 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=JqvjDBxg6dzVMRz9GXbJw/AGrIZfs63ojgJ9mrqtjWE=; b=xiVhxKmKqM3R6C2yMk9LT6gALYAG5By/KYjOsrGdACy4YRCPGDQiFVmfv/9pOjPFWt NJ+wkKnP7xdV6sRJagC2E4IWTRePbPJqketj3JdDeDtUaEPgGR148ZpFFYWRodZqGcAC 0CrnWVS6huje9Kivn9JLgFM6hdTrMBfLEwgK9SsmHM5DVpgFg/HJw9m8KweZUkUufAZk RqijRhNsswgkQDTocJtjvcdfLddJclr2x+zPKDJFZsS03pCtTBokmbbKS19Zjd9FAtAb TYHCilEWyrsYo8Z8aUP9ig+PDumRl5D3H/xlW2BHJfv1u4WMVIcDP5dONFffysiriSLR Vlkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LKRHN2T6; 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 y11-20020a0cd98b000000b00440e46a7bc3si2820805qvj.97.2022.03.26.06.29.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:29: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=LKRHN2T6; 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]:33406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6TW-0006iR-2W for patch@linaro.org; Sat, 26 Mar 2022 09:29:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6QH-0006gj-Pz for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:42 -0400 Received: from [2607:f8b0:4864:20::330] (port=41879 helo=mail-ot1-x330.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6QG-0005Jv-5t for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:41 -0400 Received: by mail-ot1-x330.google.com with SMTP id x8-20020a9d6288000000b005b22c373759so7458363otk.8 for ; Sat, 26 Mar 2022 06:25: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=JqvjDBxg6dzVMRz9GXbJw/AGrIZfs63ojgJ9mrqtjWE=; b=LKRHN2T6UpNIqCVNFfdgoIfv6jE76vXzTrQqllhcn68jFhH+eo5tke5n3pJC45BxHf zP2QRhfeHndG7im3+/nDCA87Fh/9cXrE/BAvVMyV0S5pYfUt8QXlfhP+3F+wKW+o+H33 8FWA3soc1PX6pn8OzHd6Mnf6xvEjp+O4Ky4kw98jNSwGbmUX1Xogwoa8ONRSthU1ZZSe kSmNPqnwiSuulxRWs+l4YlzfReTlEmBUEqPDb/LaiHmsxW6BUtEIM4uyrsqF6qxchPH7 09e7/ryDIIP3Z1g8HB/FgHDtCAIq7dZTfYL5P+JnlMUls96mmL9+6p52NC6bDWMdo4FV u4nA== 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=JqvjDBxg6dzVMRz9GXbJw/AGrIZfs63ojgJ9mrqtjWE=; b=BGHly0Ne9VT3NUdS+y2ON2maUvLsdFkTKGhKnG6dJ2Efvf1sW2KMxL4S3DNTuK5WmT eLVTPoAKWlaLBaSkRwv4xEjqM4LokUPucD9HF21C6/KXIPH0r+6IhZnx3IdJSgtLZ3eF +6I4Etq9zd3Lk48oC7cEdQlXRTt1DVjAIUgnXzpYqg2nt4mFwohpRzCrEqL/xLKDn6U9 G9jdMRr58szPm5o25Thv/EZeXLJUvgfytQAPWad+KAzUt86+G/gN1hIjL/K9P/R9B190 y+O8AWyt3yRs+sRUx8RrP8ec/d7yNb6pnh59nOYNubeJc5w7qcJkd1AmHJsuFBT9Mycx A8OA== X-Gm-Message-State: AOAM531UsPA+g8ym6xfvaqcpulHQM0NJQ/D75aIDkysKq2W2GjD7iMDL rPPi0kmIN0xxIPQvpgmyEIPgxDGIjXzx2fM+ X-Received: by 2002:a05:6830:20cc:b0:5ad:95:66e3 with SMTP id z12-20020a05683020cc00b005ad009566e3mr6459170otq.347.1648301139059; Sat, 26 Mar 2022 06:25:39 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 1/8] linux-user/nios2: Hoist pc advance to the top of EXCP_TRAP Date: Sat, 26 Mar 2022 07:24:48 -0600 Message-Id: <20220326132534.543738-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::330 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::330; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x330.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" Note that this advance *should* be done by the translator, as that's the pc value that's supposed to be generated by hardware. However, that's a much larger change across sysemu as well. In the meantime, produce the correct PC for any signals raised by the trap instruction. Signed-off-by: Richard Henderson --- linux-user/nios2/cpu_loop.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 1e93ef34e6..2768ae61dd 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -40,6 +40,12 @@ void cpu_loop(CPUNios2State *env) break; case EXCP_TRAP: + /* + * TODO: This advance should be done in the translator, as + * hardware produces an advanced pc as part of all exceptions. + */ + env->regs[R_PC] += 4; + switch (env->error_code) { case 0: qemu_log_mask(CPU_LOG_INT, "\nSyscall\n"); @@ -56,7 +62,6 @@ void cpu_loop(CPUNios2State *env) env->regs[2] = abs(ret); /* Return value is 0..4096 */ env->regs[7] = ret > 0xfffff000u; - env->regs[R_PC] += 4; break; case 1: @@ -99,7 +104,6 @@ void cpu_loop(CPUNios2State *env) o = env->regs[5]; n = env->regs[6]; env->regs[2] = qatomic_cmpxchg(h, o, n) - o; - env->regs[R_PC] += 4; } break; } From patchwork Sat Mar 26 13:24:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554349 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6425591mag; Sat, 26 Mar 2022 06:32:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2/mrZvIZSBPPWYvp8pdqMl9uMBeHdfLz9MynDfO/L28Y5iWKiBgOm/OfVKL1SIgdHN2Gp X-Received: by 2002:a05:6214:29e1:b0:440:f52d:8bd0 with SMTP id jv1-20020a05621429e100b00440f52d8bd0mr13402070qvb.3.1648301537354; Sat, 26 Mar 2022 06:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301537; cv=none; d=google.com; s=arc-20160816; b=oph5Si+A9dP8BNKloxWSTOupnbHny4HdWG5lHGx+wsR8RzQe3FiHhucoFGvHiYqgL2 g9VxtHV+tK+7aRLRLRRlxZg8d5K90QxmhRyzLNPjQanZI7gQFpmpgbulbtyUJDHR5Dpe /LXO17QlqhRRM7j9SygfYOiOyRRY/p8TbS5ScuTmYmRIbD0MDX/y/K8gnFtxI5F5bqoi PlfjTtC6pQu+9+Ilhz6qfApQzIbI6WCsW7bV36da6zGjZPWFZklzCFiZKz3ApAtqXNjt DfyE/pnLEpl/ELiLOXSWgr8kxD650k8v4boB/u11yQuHU2g17sbYB4Y8zqIpByde9XE/ qaxA== 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=h84Ot6YbttCAVb4FAH99rqg1sJS9c+ZhMv9JcX0XF9Q=; b=mODYViueF6+q3FvW9DefpngsDEAZ/L7eK7h3Fco6YJgB7XQIpLVcyW1yV+dlZLuG2l Pq3cEiXq0A8tja46MfQXtyK/Ptcg8wrd+LNHx1EvFHCohgvX3S/1bLwkqXRlZL7YWrpD 9Z0doGNruoylErHJDVPth3NnqfZklr0CO6Zy0GIWavfMjsT+qK2spU4F+wvPvr925oNi pLdzPeyEHv31SKRXzpQ4YVuWYZcalbXWeSN5K4lZM3JIlzZEEYSKTiNksqOvGRWN85AU bw7q9fs+BZTZCM8ksq49fG9g4bMGvkOQHM6Dp1I1pCLTySmhmuDWoHeCpiGeWvKEcyZs 3lag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IrAnnaRQ; 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 n13-20020ad44a2d000000b0044119d6752asi2799037qvz.81.2022.03.26.06.32.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:32:17 -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=IrAnnaRQ; 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]:42066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6We-0004W4-GT for patch@linaro.org; Sat, 26 Mar 2022 09:32:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6QL-0006hh-Mj for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:45 -0400 Received: from [2607:f8b0:4864:20::32d] (port=36779 helo=mail-ot1-x32d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6QI-0005KR-PY for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:43 -0400 Received: by mail-ot1-x32d.google.com with SMTP id y3-20020a056830070300b005cd9c4d03feso7463862ots.3 for ; Sat, 26 Mar 2022 06:25: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=h84Ot6YbttCAVb4FAH99rqg1sJS9c+ZhMv9JcX0XF9Q=; b=IrAnnaRQ0P++IPAx4ctp/wjX5atENOhpaTM0ZkIerw4ApgM5by22UbJWBxwYVXkdwd b3WHga6ZS+M+1fU+dtKjf8yqPVdIrPrA1/Wwkc6iceNInFzdqVlB5lmzuhOx6lTFZLtn 4zZUyZlcoyKaFnARHdYKLzNmPIW3P7S8aNkdM88S0lrj2xFWVQ4CPSU9htqN2huLEhAO 5QKRDF6WwP0O1DA4rdJ+Tm94maHynvJMTRw+x1XVeBLLiwGJr9EAecUwBLHzzTI5T3q8 wzuX6Zy8zjfCisLM+GlB+ZdMGCsZjQWgesOlZ4VgUjnk01OcGd0wbKFri5eNfbi+vPB/ TPfA== 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=h84Ot6YbttCAVb4FAH99rqg1sJS9c+ZhMv9JcX0XF9Q=; b=CUb3qxHn07OvY8nJ8YSns66/7hdCfGfHfp1pmjZ0/qbqdyfds7Y7ht+6WHggcAiIS9 W0IydEp86b5traWgEyAGq4rApvVxCaj5VBGg9D88H6DK97qKTccFplTU4d+G0wEmIDhC 1BfIWbX8aOMPNx5WAnDaKwPLDffftEj2z/7AAcFawSsocIPaxir5Arl0o5mouyeBytRF FAwGSgtVVWxxei4gpgn1+Vws5mBqZ8N9nVrdA8m8QMV8CDXhGnDE/kGcIVKwh2v+kMUP fsbIufEXmnkEYBYf2rjF2mNHoezfkzEMjXrkEozzet4MQtU34zdJBGlKzLhuaS9iin3/ oM7w== X-Gm-Message-State: AOAM5339r/CCM1k+2rg/m35d0AUdsIndPY7NSsjBy448EKE0lTs6rnML /Pkyrvcb2YnBxAGXyMFvuTQDCpmp1PEXLMYU X-Received: by 2002:a9d:69c4:0:b0:5b2:3abb:612a with SMTP id v4-20020a9d69c4000000b005b23abb612amr6516463oto.319.1648301141787; Sat, 26 Mar 2022 06:25:41 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 2/8] linux-user/nios2: Fix clone child return Date: Sat, 26 Mar 2022 07:24:50 -0600 Message-Id: <20220326132534.543738-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::32d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.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: Peter Maydell , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The child side of clone needs to set the secondary syscall return value, r7, to indicate syscall success. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/nios2/target_cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/nios2/target_cpu.h b/linux-user/nios2/target_cpu.h index 2d2008f002..830b4c0741 100644 --- a/linux-user/nios2/target_cpu.h +++ b/linux-user/nios2/target_cpu.h @@ -27,6 +27,7 @@ static inline void cpu_clone_regs_child(CPUNios2State *env, target_ulong newsp, env->regs[R_SP] = newsp; } env->regs[R_RET0] = 0; + env->regs[7] = 0; } static inline void cpu_clone_regs_parent(CPUNios2State *env, unsigned flags) From patchwork Sat Mar 26 13:24:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554348 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6424046mag; Sat, 26 Mar 2022 06:30:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgj4wTJvYZ+zOaI2TtzVtr67MxAjKYTUCe24lV/1cFUmbh0RbeLGplkrDHxn9+sSRYEOc7 X-Received: by 2002:a05:6214:d8d:b0:441:84f3:24e8 with SMTP id e13-20020a0562140d8d00b0044184f324e8mr6653402qve.16.1648301417905; Sat, 26 Mar 2022 06:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301417; cv=none; d=google.com; s=arc-20160816; b=NwKajnz58mTIpnXTkS15jnP6ECDL7FMg946ngATH9pktKunsoVnPchJhiKKG+hkO/2 SETcNMona2FBqViKIbC1+Wiicvkkg4p9Ct/0sNOKoqNLRI90aiq9i2jLq009a/Ol6wbk wJqN+3V1RT5dTsVdpJXQXAewXaUmHcb5nB8PemYMMveB3KZlw11K1H1bxCbY6+1hVDM8 zd0lSzc4nQYufvmB4rgrSawvpyYXRysqhZEwp2lZAuW9t9i8NTWfyM4vFMPiNLINMvp2 9glqTAxIlGJOLUL5U0Zv+TFlM0AWgvX3UAkcmWieyyxV05Rq0DPPkiiCz9TIMNmP3STN IqOw== 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=gySRxuYYwrwZO32brZVPz3NY1et5tLsOdakLrHT0vtA=; b=cLJnBSDUXMDkD3ySS45ifyqklPVzCWFzqWkjS6ZvqdqTBzLMCEmODsQo7+PMH3lJKB HA6CX5JdKCuG2AvYNhFwbCtA6LD/Nkr1GQzr5AFo9aiTUKvaasnoF15+67fZ7iJAyO62 m+ZLOyhlJRTQP+4ESDJwByW6KlnIIG322aO5NkSXmFpZ33PIOtanuGbbaVaz41z/tvJI vsVQfk/W2xJycXE6o8MLba5VazVLNshmjR9xSrl0HdXBbAJdwLJqF7Of1vyikGKx0DcR Hk26xmblvFwFFhudan7EM6RHPhd75ZG+zjcPFym5pJOiYQrULj4fbzbR4c897j+GPrBb 82YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Y/wzKajX"; 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 w6-20020a05620a424600b0067eca2867e8si3891182qko.89.2022.03.26.06.30.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:30:17 -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="Y/wzKajX"; 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]:36754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6Uj-0000qy-EC for patch@linaro.org; Sat, 26 Mar 2022 09:30:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6QS-0006oA-8s for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:52 -0400 Received: from [2001:4860:4864:20::2a] (port=40494 helo=mail-oa1-x2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6QM-0005Ky-TZ for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:48 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-d6e29fb3d7so10738185fac.7 for ; Sat, 26 Mar 2022 06:25: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=gySRxuYYwrwZO32brZVPz3NY1et5tLsOdakLrHT0vtA=; b=Y/wzKajXr3cj1SxddHduccwLyYID/tL3C4uIlWReUbPpz7UExtCrJXQ33nFWzuhZaC +kcrDYW3EQhCHTWuN0qyv26YR8LvByAarhvXWyI8a0s46dVcv/Ybxp6v0y86Id60PSlV RMFpT8YkkwUA1q+t9OB3Cn+AIrbd7NBm5YNzvBKXFj3Z/T+z8e6v/s3wlShM7aoZknig F0HFs7OdhapA6/6aWrI3CnT7tLNYs4CUHaWGtrGKC+FqxgbUmFc9yHrQSA9XSWzyB1dp 5UNSdBcbuvSmWj9smosJ84hiqECy4k7APgzmC4HdWglmxhtaF0PXFP41voatzW4mrveA Q9tg== 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=gySRxuYYwrwZO32brZVPz3NY1et5tLsOdakLrHT0vtA=; b=iSc+y+3w+SD/UlxgxPxv1XerMsRH5hPLSpxtbX+j8zJ1hdjjtcazTFwCgWP46HBtlS QYPFlNczL8UHbLD3xEa76HfmYyNIpF5lTJ98tnEHy4yHYiN2mPV3jExosMMCV1eo8bLx t4W0Nb6VuZe2LMFNcMyUXhipXiQudVEJraDjabdOaBFMIUbMydgFypHmfbmh5RP3AbuP GC3e7w6b3gCpKR/AKiLFbsJf44Q2BnlMqdTr0B08VxrzK8aVfG6yB0MINPDUd9Fx3MxS 8ieQsE0+QP64A8m2Xg9csUY2f8X5HuTV+O8p6F8CYGFwN27TQmUwd7q46YwMVFjxrE2i cvxw== X-Gm-Message-State: AOAM533lB0As2sdkhudekOq4Ssaui1aXcLbAcisL16PBlxkoxCC6mfzW xiWm9QfI5bl09OXp2t98hwJcTLx13YdGQefD X-Received: by 2002:a05:6870:785:b0:da:ac31:3e04 with SMTP id en5-20020a056870078500b000daac313e04mr10690591oab.270.1648301145853; Sat, 26 Mar 2022 06:25:45 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 03/39] util/log: Return bool from qemu_set_log_filename Date: Sat, 26 Mar 2022 07:24:53 -0600 Message-Id: <20220326132534.543738-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2a (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2a; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2a.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, 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" Per the recommendations in qapi/error.h, return false on failure. Use the return value in the monitor, the only place we aren't already passing error_fatal or error_abort. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/qemu/log.h | 2 +- monitor/misc.c | 3 +-- util/log.c | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index ed59ebd4a2..fabfbe41da 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -148,7 +148,7 @@ typedef struct QEMULogItem { extern const QEMULogItem qemu_log_items[]; void qemu_set_log(int log_flags); -void qemu_set_log_filename(const char *filename, Error **errp); +bool 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); int qemu_str_to_log_mask(const char *str); diff --git a/monitor/misc.c b/monitor/misc.c index a756dbd6db..04ec0711da 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -419,8 +419,7 @@ static void hmp_logfile(Monitor *mon, const QDict *qdict) { Error *err = NULL; - qemu_set_log_filename(qdict_get_str(qdict, "filename"), &err); - if (err) { + if (!qemu_set_log_filename(qdict_get_str(qdict, "filename"), &err)) { error_report_err(err); } } diff --git a/util/log.c b/util/log.c index ffa66a267e..a838686a18 100644 --- a/util/log.c +++ b/util/log.c @@ -138,7 +138,7 @@ void qemu_set_log(int log_flags) * * filename may be NULL. In that case, log output is sent to stderr */ -void qemu_set_log_filename(const char *filename, Error **errp) +bool qemu_set_log_filename(const char *filename, Error **errp) { g_free(logfilename); logfilename = NULL; @@ -149,7 +149,7 @@ void qemu_set_log_filename(const char *filename, Error **errp) /* 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; + return false; } else { logfilename = g_strdup_printf(filename, getpid()); } @@ -160,6 +160,7 @@ void qemu_set_log_filename(const char *filename, Error **errp) qemu_log_close(); qemu_set_log(qemu_loglevel); + return true; } /* Returns true if addr is in our debug filter or no filter defined From patchwork Sat Mar 26 13:24:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554351 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6425840mag; Sat, 26 Mar 2022 06:32:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnW14M+UJ9tjS4lq5nE1Tx/q7k9ST9VWGlX85T+SyUhywxOaBUN128X0bWNS9jSUwEOa/R X-Received: by 2002:a05:622a:1aaa:b0:2e1:a40d:8253 with SMTP id s42-20020a05622a1aaa00b002e1a40d8253mr13812388qtc.135.1648301558541; Sat, 26 Mar 2022 06:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301558; cv=none; d=google.com; s=arc-20160816; b=raj8A2SdmUxLadxYM0EwDSe5yW9AgwPoOfVsX5FQ4PAjr4AorDNrLjRkfaT0lsKDFW yg1Jw+N3umD9d6Rkxfe3tb4LDtRsHl0+1b0yan/B/LbMLNOTzWae3TY8Y0kctiW73w0h Rg/vOKlFZ/ugQNTUPiAZJXP4ZUfZLoD59y/C6qv+vC9bp+NEPlFLAzpvfBnZdYfjVGfg eX01pRCB1vXHb84pcx0Rj3hl6jtR7IA/AHSy/zz7+niz35276U8e35xkH2mdbD5RQ3TE ixQ8gwIpN2j2D4u4/lQIeKN6TAsHiDkygRUIBdxMrIiJwbcP8ggZHCm5AZZUgz8nVpAG nTWA== 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=26hq51RiROI5XzJelEXkN2uWQhOSPbaaTZ3h8qaX6EQ=; b=C5AAjkdcW+NRRpSy94ALb2oBpmVKDxlXXavbN9vQNZWXcgU2FCmxKLuqh2RZcyGFww kcSI4jf7SnZKJxTTa6W114TIexrKR3aRtJ9RA4xCb0kuu1xF2WRaubloW5UzndrT3UTT HglCQlIiirusYJrP0mqz2QqMaG34vDvKlW5dWVZGMk76zd4JexNRWS8hlv25aUPL85pn LYd6U6ATFXGhqjG3DctCbWohTjQQxPsSrX0d0+wy2mC9SGqP4xmZinpnEpRYDn3s7Ia/ uaDhkwqL3Bf6tI1qoyg+GwjBGkdXVId/U7y74iJacKIMMUDh8eOIe8SYr+HuoIu3g4Ra gKNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tmp1KyD2; 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 t128-20020a37aa86000000b0067e4be23a6esi2613072qke.691.2022.03.26.06.32.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:32:38 -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=tmp1KyD2; 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 1nY6X0-0004g0-3x for patch@linaro.org; Sat, 26 Mar 2022 09:32:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6QT-0006s4-Fv for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:53 -0400 Received: from [2001:4860:4864:20::2d] (port=43740 helo=mail-oa1-x2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6QR-0005LI-Vz for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:53 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-de2cb87f6aso10701951fac.10 for ; Sat, 26 Mar 2022 06:25: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=26hq51RiROI5XzJelEXkN2uWQhOSPbaaTZ3h8qaX6EQ=; b=tmp1KyD2RxKn8kkjT/Pq/xtKXGmQuRbrstjmfzhPbR2m3ehHWVK7Qihw7UoLYgIQQ+ CburleEMw7mmkyscoqqSU0cKSn+RU3jkueJfIAOrZKujoC9jCwVm7OchO2XbTW6fyyxj QvrzjkpNHfbZY6EqnOtmwYC5YB95uEJWhpJLkJzgFtSbgFPLv/MG7fG+g/to7gbq01LH 06NTba4kr17+0Ve9jbAfdB7qwqI2bW1u+4Dn89/gSxtA1htaPaaarEgb02PMCEE+mIIe Laa+lyxksZrKBGO/hkQOSapZ9y1nCWRFMtpAQhKplqoPZXtoeMN1mm7w8yHOkZrormCZ TYkA== 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=26hq51RiROI5XzJelEXkN2uWQhOSPbaaTZ3h8qaX6EQ=; b=otsr+34VDebvEJUQTa45lKhyL46aQl9Je8duDGLetopfgtnyMJ2VTe8hrM44/O/c99 sqZl3tc9FRmQgOgiQmzEhCx3GWJgKJk5kdn3NXHcnkyhwofkzyM//XFDSfd3MPlJP90a s079p00GMUowTQu0Mk2v5RTGzT0ejMU7bmCLfmiMiw4gasZzwevfyIOIvpB5tlC+9CJc 2QtJ3uHlBLs8zyFM725/ViTI1oYH+ovYVXXadnYG+0ykNRzWZS8o9knyAS2WCzJ4UIgJ VXhDAYKSvw3HWNUQUSCYVEbkBZC9tZnpOrAKph73JesoZyUgPZz0yo/jHbmMGyCjBrQg zQAQ== X-Gm-Message-State: AOAM533N+ePPnXapf4wErRdNG16kE5MXgNe4R/yzZJd0oW9Faq7yxwxr gpkQujEY+KS9k4nAC5HxI8jrn/MQLiraYc2a X-Received: by 2002:a05:6870:3394:b0:dd:cfdd:34c9 with SMTP id w20-20020a056870339400b000ddcfdd34c9mr11506299oae.31.1648301147081; Sat, 26 Mar 2022 06:25:47 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 4/8] linux-user/nios2: Adjust error return Date: Sat, 26 Mar 2022 07:24:54 -0600 Message-Id: <20220326132534.543738-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2d (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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, 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" Follow the kernel assembly, which considers all negative return values to be errors. Signed-off-by: Richard Henderson --- linux-user/nios2/cpu_loop.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index a285781fc5..969460df58 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -55,9 +55,14 @@ void cpu_loop(CPUNios2State *env) env->regs[7], env->regs[8], env->regs[9], 0, 0); + /* + * See the code after translate_rc_and_ret: all negative + * values are errors (aided by userspace restricted to 2G), + * errno is returned positive in r2, and error indication + * is a boolean in r7. + */ env->regs[2] = abs(ret); - /* Return value is 0..4096 */ - env->regs[7] = ret > 0xfffff000u; + env->regs[7] = ret < 0; break; case 1: From patchwork Sat Mar 26 13:24:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554353 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6427562mag; Sat, 26 Mar 2022 06:35:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzngXi4k6LweG23driWekzPXPUMA5Xr6oquh1m46Rd+fO2zzjqFR0T/Iocy6nhPS7ktpjPk X-Received: by 2002:a05:6214:f62:b0:441:2cd7:9cfa with SMTP id iy2-20020a0562140f6200b004412cd79cfamr13174484qvb.61.1648301703556; Sat, 26 Mar 2022 06:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301703; cv=none; d=google.com; s=arc-20160816; b=XMxcjXwZgHzDMnS4Zq4ZxYIuegxWWcPpxsBFLBegEMpt14RwdtCpkHB6AK8hw6peFB r8CYFLfS5GMMPlDI7X/QMK3V89OPWnkyDZLe5V3IRcue83bCd4CXDR8S2FJkIr/6YdX9 /pn42/cZAlIWn8/EkSeNPsEsIcYzkGCZ3Dyed4/45qRTe6gG/fcMsDKQrnK5GQ+mOYHl 7Ied/R4S7Jv8V9N0wdf4ynKpdN1pWMdG92f5PpxgC75BrpIQork0I/E/zv5ol9PbqI3i dJRY1/8+PemYrhcygGcp8tJQEsQbVPc3pAZOe2dkZ3I2b3O/bIavGHtuylkH62sT87XM /kQQ== 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=alXSIX3aVlQbR+ahH+ZLhiXZst3M9kUZiv2iZp+a95Y=; b=MwG+XaxO00Bwt+hohMIQ8hNo5vtiQz5CXOla4MHaPpSLekV4Z9rC8Fz14+HlGnIBd0 /CO5BvjiUTF1+Q9Y/3YMeOOS73W5pFbyFX00gcDl2N5TMUervSOj8b651+b2nMXx79Py UaYAuNA+LRN56Yuuuc/9ow6VY2jfmSx+4ZY4jsrtqpEw8lwzbzntinUW8sy+x4kPzWJa +UIFGc6P+uzeR88TmzkaHLipN9adYNTHwczaNccqJPJ4qcdfGa2m/MoRCfyk2yMHvKYU 4nxHd7ygbGFhXxtv7VVy/yvKCLkdL7WlS7KSFNDc7q4Xn9WZkSjP4LHxEr/UKhpSmymk k35g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lCu0jtZ/"; 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 fi12-20020a0562141a4c00b00441671b505esi2814492qvb.59.2022.03.26.06.35.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:35: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="lCu0jtZ/"; 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]:50546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6ZL-0001kc-0m for patch@linaro.org; Sat, 26 Mar 2022 09:35:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6QU-0006ww-Uf for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:54 -0400 Received: from [2607:f8b0:4864:20::22b] (port=45002 helo=mail-oi1-x22b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6QS-0005Ld-6D for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:54 -0400 Received: by mail-oi1-x22b.google.com with SMTP id t21so6202061oie.11 for ; Sat, 26 Mar 2022 06:25: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=alXSIX3aVlQbR+ahH+ZLhiXZst3M9kUZiv2iZp+a95Y=; b=lCu0jtZ/X8jjLDdXgF35fC5uZeCKlSelXqx6UIHSvBMtox7fpxccKvkLtezfM+/4e3 Pmzd1kNZ9ieiuSjUhNCsLOINWIQwfUHb4EAT6WdJIzrWvs51b9OuJeCNjytSFxr+bHxA eA71zmYsETBdkTO5TpUsJ+rj2yqxsEILZ++6L+euUIXpiSxvak0xAR/ZBa4lo0caUZda 9xfmnktfibYds2BYr0XJK2vIQBDleQBmBXXK/9YU6ZVH6AgUSxDf8fzK1Kq3A5KF5iFl u+r+SHx0lib2iJf9ycB6sf1sU00Y/N3o9o1wMu56KuFIklFD6RIdPsJh/ugPmOLDV8iH CWbw== 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=alXSIX3aVlQbR+ahH+ZLhiXZst3M9kUZiv2iZp+a95Y=; b=X2aDjj1740ryMVItVfBvYg8PcGD944rFqWcbXrtBcFWpJpzP/SvPMXXHHNp1iLb+pC lj+ktW2VvfaHmx+fClXkkmpjxvtPjXQoXvOqEZw9RBMmFFRpE+k9H1v7WnGDMzWUcsPr mUAkS0AujTW9vpWP0co9LtPK1wpGQ0GRnwf1gfyqXyMEqM9uBdpvhXqBg+aEjmd19QS7 s8ylbRX3BLtaX/THPQ5skQk1ROhTJU/KJRki34aINrvSKvhRKHGoioBPJkcNGqx2NoVD qIe+5YNgxZueXXWeih+66FUr9f6N9WE9zzTYcqbeEOUzfI8XS6nqrpJzXQL3w9oV7ixb HpTA== X-Gm-Message-State: AOAM531hv5s6IRXJlRVgXRzMDbfPDFdfT0rSDrZF+R7AdlTqkdykwc0s znajXdCagekmjWfx/46ticAz8oHfUYHgjR6s X-Received: by 2002:a05:6808:23cc:b0:2d9:dc76:1f36 with SMTP id bq12-20020a05680823cc00b002d9dc761f36mr8093205oib.292.1648301151155; Sat, 26 Mar 2022 06:25:51 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/39] os-posix: Use qemu_log_enabled Date: Sat, 26 Mar 2022 07:24:57 -0600 Message-Id: <20220326132534.543738-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 Sat Mar 26 13:24:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554355 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6427605mag; Sat, 26 Mar 2022 06:35:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZUdzdRu0jgzsmz0QWS1SAZNEmn3t8qq9N28SAw6ujcYxCzi5ez/WZnd8bZGs+QhLk/aHy X-Received: by 2002:a05:620a:4547:b0:67d:bb26:9a8c with SMTP id u7-20020a05620a454700b0067dbb269a8cmr10352770qkp.628.1648301708229; Sat, 26 Mar 2022 06:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301708; cv=none; d=google.com; s=arc-20160816; b=Msx6ogOT19gNTGU5U8f/sLompgAxTKNQlzT9TPBVBQ3gg+qnAGXp0WbuutaY5qA5pp Ys2v9umtr2cB4rqUk9PrhPBekS3bz9fuW3sw30wos2mXR40D4lR4vxn18ap5fSPxhrqc DR4gGo8P1eNzCdjAD8KQQ4E3rOXsHESARvSQZQwtPv93PhBNVmR2GMtXFXxPer/Ezm1J UMAvE5lkNrH6NIHSY7TLxNOdcG6vSxrxac21SuaAHkgg2uRYCHnQBGp5hw87NbrKlmCW 4kOaOiy0K8q/CSqcfROEQiSHfryxlRzdeiVQIdYi1IMchKGxBoU15KmWzFKRi9la7bNZ 8Eow== 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=TOJF6hs6MIWp7u5IOBbMVU2hqWWBLm4vep8AaaojE1I=; b=m6FddIMbMl/kRmjwh2Icz8iupmntMBefqcaJRk6aJdArirpkMFAmqDePkOUKkc6r33 xIP514bSCPnpgC8fA+l3oxdJY3rAIB7PlifD0XCyy3ltVWQSTEujuxgwvGJTu3zNh4Sk WZU2R3DtNr1IFn7jb9gTY4gqL79BMm8Udr1222yTPr1UTuiSED8iDy2qufbePDwiqD+6 PHaoSkjMV19NsKFm01KmTPwB17CD+TYVZYL/4j59PS+y98u3dpgWPDrWArpNzTBcoTeC wrRpo2FxICN7C7q42HrCKHILoOkMuxxwfcxxVctGxM/715vS6yH7oMfi5/hzaVXrU1Gm Q4Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fBlXKjbR; 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 g13-20020ac8580d000000b002e1fbf3c0b3si3466361qtg.676.2022.03.26.06.35.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:35: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=fail header.i=@linaro.org header.s=google header.b=fBlXKjbR; 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]:50928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6ZP-0001zf-RE for patch@linaro.org; Sat, 26 Mar 2022 09:35:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6QW-00071m-7F for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:56 -0400 Received: from [2001:4860:4864:20::2d] (port=37200 helo=mail-oa1-x2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6QT-0005Ln-9G for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:55 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-dee0378ce7so360212fac.4 for ; Sat, 26 Mar 2022 06:25: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=TOJF6hs6MIWp7u5IOBbMVU2hqWWBLm4vep8AaaojE1I=; b=fBlXKjbR5gpIbkK9Q5Knhcq7zY+B5/ShAUt1I6RcwgleJHdeakoTeXP6hrUEXvSu/L Gaotd8+EXHS34bzIpKHqoNKqPNr2CCaXE+Hl77TGRa29SZ7vdzLmT+5YQsL2B5OFoeEB fexMjxNFrhl6bfcxsK82V7AUgcGGXnJyhgJWLSZpA4C3em00mjLAliomKegrmInuHeyV h5m62/aEc4bc5FADkyHCSSQLKIVFVVU8j64C+OJXY9+4T7ndcdHS9eXxOcWW0yEFdL1/ 8k2Qu0/lYphUC37cknd7r5Bgfi+OPVkdSIeFy2HxC8tsUxYndZ0zwMUV41PPP4vpl8Tc +vYg== 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=TOJF6hs6MIWp7u5IOBbMVU2hqWWBLm4vep8AaaojE1I=; b=uydTUs8fqbTb2jZyxdUq4pDEt/AIEipiJskRRHUPBvDkVH33C8JkTEniq8VhXZRkmX YoHznifk3GT0cSKyWPCiUiYffngZ2HDixeVd/J1X93VLZ4OA+vhwA5ciyp2Jm0+EDYKv US9YbSlx8ypiWAKrqEFx0+besFaYegPux+ww7mnBBJ0fPwloJetpl15E4msOuwzcRdIt dqaguHlC8IcarDMzcPc30pUc7ql0F1MjhCedAvTofF3vyDtLdoXMNiWcF71xZBrP7jK6 ws5b77DuLuJ2u0GcUiTfsAVWVKnAWbHDvCK90wULCgDI6eUrEbTQbai3lGjAFTDZG/fb 2wgw== X-Gm-Message-State: AOAM530nUTKdKc+8v8q5qYi00uR9rlGlgSDWGtp5X5xWYZ041eUf3Rhu Esw0MhQA5Gy6ArlQw2iKu8qiyRD4JLaa+Jqg X-Received: by 2002:a05:6870:9893:b0:d2:87e4:c71c with SMTP id eg19-20020a056870989300b000d287e4c71cmr7126176oab.132.1648301152316; Sat, 26 Mar 2022 06:25:52 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 6/8] linux-user/nios2: Remove do_sigreturn Date: Sat, 26 Mar 2022 07:24:58 -0600 Message-Id: <20220326132534.543738-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2d (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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, 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: Peter Maydell , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is no sigreturn syscall, only rt_sigreturn. This function is unused. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/nios2/signal.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index 517cd39270..133bc05673 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -185,13 +185,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, unlock_user_struct(frame, frame_addr, 1); } -long do_sigreturn(CPUNios2State *env) -{ - trace_user_do_sigreturn(env, 0); - qemu_log_mask(LOG_UNIMP, "do_sigreturn: not implemented\n"); - return -TARGET_ENOSYS; -} - long do_rt_sigreturn(CPUNios2State *env) { /* Verify, can we follow the stack back */ From patchwork Sat Mar 26 13:25:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554360 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6430281mag; Sat, 26 Mar 2022 06:38:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVBubKzhx0RW3vKLnnuav/iTj4kpK/VWlaIvUnamXaBeqDp3BYumA/SVt7wvb9YwWeTjVQ X-Received: by 2002:a05:622a:1a27:b0:2e0:64c2:7469 with SMTP id f39-20020a05622a1a2700b002e064c27469mr13952747qtb.187.1648301935938; Sat, 26 Mar 2022 06:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301935; cv=none; d=google.com; s=arc-20160816; b=T0JbuiNNijDFuUOXLwOaQwly07Wm2u0Fnbx9iXcwILHsvdwO3mQULpOdnuNAUhUlf6 URDkjfu7iEE0SU+sHX5D+uMo16p1RhNXi6w7E4AzR5XyZknuKJzJ5iTp4YExJrKBQS1k SqiwKYvvTq92ru+RQAv9yU8hRdHCjJGccbDIN8SkapfNVcB/Iz3JCXlSBK9AQulehwXZ fBzh30+wbM0k0depPMjv9JryBfx4gXi39VQylounOTiyaNyzZfmiOOG5ZZzMha42v334 9GPdWKstDYXUzlf51JQRKmc1q8qb1cB067coeMB87auxDrcDDUV69b6OGYDgTJWDYiV6 q+GQ== 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=xYuWaRD3BVfH07lx10ciC+hnANbY9oKSD0sVPEBlcEQ=; b=wWebt3FCQKn1fxNvGzt3SB2MZKstMNuCOpf2wuGzvC5UKpN5WJQgxKyrG2SPpQm+7R 6IFZLFnlM1KEgkA2HkMk89rjDZYIdbUs/dmofTmEmTw4y0i8/SW0P9C7S5km/pjNJNis mp3d6jx26pnOpb1ydvr8puyXwzBbSZ6IrgCO/ahK5oAxfbNCdzPjp1ojRXlpew+2xGfx 042IrhMYznPgvlOHE46gV7R6/0q2vCYU8m1JnpVXssAhw6P4ZWZF3+2iGpNJxzv+4Bg9 dvdLsKBeDClydU+emb1jMF9xYpzQnBN9iy/6HLd1OXNbYbDBmUqrVewxvuUa/ZiFrzXU bzTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J1aFLgD+; 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 br17-20020a05622a1e1100b002e1fd7e2e72si2841764qtb.279.2022.03.26.06.38.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:38:55 -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=J1aFLgD+; 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]:34564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6d5-0001XS-I0 for patch@linaro.org; Sat, 26 Mar 2022 09:38:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6QX-000777-L9 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:57 -0400 Received: from [2607:f8b0:4864:20::22f] (port=43751 helo=mail-oi1-x22f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6QW-0005MW-1M for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:25:57 -0400 Received: by mail-oi1-x22f.google.com with SMTP id w127so11074209oig.10 for ; Sat, 26 Mar 2022 06:25: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=xYuWaRD3BVfH07lx10ciC+hnANbY9oKSD0sVPEBlcEQ=; b=J1aFLgD+2IRA6gLwVZNtDRKl0b+nN+IMO+TqYrEGCk78SNjgeSQ7/V2fvnan+nwwhY mbL28JPUwbCYX9vAUAC0gPYYbiwnRo4qW7nEwL4bVqTewlrirLo6/3dLKzLBRY739PoV iUAkQrS6s+J43fCMj3HBrcO/zpatf/ghtzvXv/iFci8IfuggNopqzHTZUUdZTxma9zFP sR/vSjOzAIQs7uMtGjNd53Kd+QvrPmmRrhXnnBPXlidXO9CZvHfiaxzRSLuEQHSUCOMk e13CpZKaD7sfK20WdSYZ3zxO5p5tQPBR+WCKAkOn5x60mQS5PDbpwWXooPJkChhqOtvc IxfQ== 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=xYuWaRD3BVfH07lx10ciC+hnANbY9oKSD0sVPEBlcEQ=; b=ziqC7gby4mhQ4vJ98xubPSwbAexdoYTMt4LVUBk4FKxNM9mWVOLa6yEaKWlz5womFt iVNAwVQAPrzrSKyi7+qBYi8kqqOEgy7EwrrTQnkd31KZ51D9CQ/4bKL86f8c8EI4jMK+ bK3ba8I07GfduqrlgiNv15UFGmNVNch/ETubYkuifdk4O3qoV5YSdUW4yWaJcCx8iraO 5ezFeH+bZLhwymZN65LhIIjHsp/7N2fB1vJuZkDV9O2a/88lDWxqk9ICu5KQti+/KKM0 XhXCfXqZ9LYhCZKVTzhXrcyJfqEEl7KrBD/mDbNcDxk3KLldfRB5gsJWIqPJ+g/0YVT5 PuMQ== X-Gm-Message-State: AOAM531tAZbgm7gHs4kZ34YpxY4U9Nk/vSOLg10ZCHjWZol1oblloFd3 fo5NMzJoCvyiBHw02Y1VN+9vYKnY1Ly7sL0F X-Received: by 2002:a05:6808:2218:b0:2d9:c3f2:4042 with SMTP id bd24-20020a056808221800b002d9c3f24042mr11825314oib.270.1648301155023; Sat, 26 Mar 2022 06:25:55 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 7/8] linux-user/nios2: Use QEMU_ESIGRETURN from do_rt_sigreturn Date: Sat, 26 Mar 2022 07:25:00 -0600 Message-Id: <20220326132534.543738-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.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" Drop the kernel-specific "pr2" code structure and use the qemu-specific error return value. Signed-off-by: Richard Henderson --- linux-user/nios2/signal.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index 133bc05673..9aa525e723 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -77,8 +77,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) __put_user(env->regs[R_SP], &gregs[28]); } -static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, - int *pr2) +static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc) { int temp; unsigned long *gregs = uc->tuc_mcontext.gregs; @@ -128,8 +127,6 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, __get_user(env->regs[R_SP], &gregs[28]); target_restore_altstack(&uc->tuc_stack, env); - - *pr2 = env->regs[2]; return 0; } @@ -191,7 +188,6 @@ long do_rt_sigreturn(CPUNios2State *env) abi_ulong frame_addr = env->regs[R_SP]; struct target_rt_sigframe *frame; sigset_t set; - int rval; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { goto badframe; @@ -200,15 +196,15 @@ long do_rt_sigreturn(CPUNios2State *env) target_to_host_sigset(&set, &frame->uc.tuc_sigmask); set_sigmask(&set); - if (rt_restore_ucontext(env, &frame->uc, &rval)) { + if (rt_restore_ucontext(env, &frame->uc)) { goto badframe; } unlock_user_struct(frame, frame_addr, 0); - return rval; + return -QEMU_ESIGRETURN; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); - return 0; + return -QEMU_ESIGRETURN; } From patchwork Sat Mar 26 13:25:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554358 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6429094mag; Sat, 26 Mar 2022 06:37:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyF8cBS5SYMlzjTwS9dPItwwasgB0OzqbQxDYcr/NvwBL/rTTFDT5Yb3uUzSxQgD1gEv+54 X-Received: by 2002:a05:622a:2cf:b0:2e2:14ac:6f1b with SMTP id a15-20020a05622a02cf00b002e214ac6f1bmr13839563qtx.557.1648301834592; Sat, 26 Mar 2022 06:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301834; cv=none; d=google.com; s=arc-20160816; b=ZvW+Jd6AhcktGXYoYe454MR+IqU8Mp4OaQ4AoK5ApfAziA0G5CqPkFIVqqoP7d5DlW Td+oVrYOz1w8meI01qa9LxOP/2eXM6jCkah640eyqBF2/7M8Gt6zQcz6mDwjthBl4QRT NXYRbTsIu0E7us2d6iExmNN2jXhiQpZrhBib0zDiv5oNDV0A5dvTvnbNyxt/X6AfexAA 1PcD/fqtl0rr+C/WVTbzfQwYwNd9LKBCQYdFOOIn30A5qt9urkSsdW7x+qOLIFtxQWOA eSoPQJTvXArdDGaoOQZYm8UIV5ZeMwb5kVuQZrNrxK617WgvsbEVZZi4D+/uG/Sko9O1 qnWg== 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=kPR3QL2zkjcobuOtk7sTr4ObN7Yl/0yBneTbMcqTLmw=; b=exL/dsD9Dcv2XfUxKtCZOFOfQBca+GskEYc7K58YFu4akgp4lPFfFrTGbr99iws1dp 9vyCA2r/fi1YpX0wRcE0ip7Plrw+UEaU9QTjRC/J4Xg36bc5uM5nJS7jnbt0lzaec/Nh 1JThXIN1Eb2qcUgFyo9FZfmyxxTTjQWr32BrkDhDBtBnJmn3BzljpalJSn9DRNoUvjTy ymJwT3YaUR2bdFUjBdp4xPHoY1p1qYnPt3RWqH5u3TTCGBkrstERRPJOM2s005LESz7L wS9dfmUrNANmVioK2hegyKN7xZijUCmia1dVUr+tNglYYK03LeOwZy2nw/idjfcvWno4 oQjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CF0vW+cX; 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 c12-20020ad4474c000000b00440e46a7bc6si2885949qvx.100.2022.03.26.06.37.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:37: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=CF0vW+cX; 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]:59168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6bS-0007Wv-7F for patch@linaro.org; Sat, 26 Mar 2022 09:37:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qb-0007Hf-5N for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:01 -0400 Received: from [2607:f8b0:4864:20::232] (port=43754 helo=mail-oi1-x232.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6QY-0005N3-L8 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:00 -0400 Received: by mail-oi1-x232.google.com with SMTP id w127so11074273oig.10 for ; Sat, 26 Mar 2022 06:25: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=kPR3QL2zkjcobuOtk7sTr4ObN7Yl/0yBneTbMcqTLmw=; b=CF0vW+cXHZI6FalbhwNhBqD4kjpPCJZAOLBgfnf6nrJQAfMe/jIkmdhVYY+fC09v8m uTom8A99Bl6sHEfI/R3AjNaqqFTkacyHKFiqRaEd5vKQcCiPM54fRPHDLy92zldkwSnJ 9KRwuZpbGBXIuM1xr/T94YWr/VD3PbW2IdJNTvCFSLA4NBd14oGi0vxwzY22p8OATBIx IsSkgeVdbP+XRpPP0tXijDiGCxqrvQ+gAhHhk/B2qpg0Wl5OgblMOVZbUCmKB4YA0wkn AtWtd8bWaI7I2xBtKJh7ooXbCl+QImxM3SZFLxrP+9Jc2Y6mOSIbT3CecPPCDM8VqAmA I79g== 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=kPR3QL2zkjcobuOtk7sTr4ObN7Yl/0yBneTbMcqTLmw=; b=ZVzc92uTGbB6tGfjR57MiqAWZDjh+VXp+a75LXiFUr3iteeAx0nNFJKcZES7DZ4VED fFFGbklgkIWTBjYpo1kgKOOrMllNPoTyEGGiqZa73fZ5JsaNqeaGjgPwoHBTOympyO2S cB7i9SAnDBo0hwtbLV0NmzTyy7an09evwoOuTai0+YebFxgtna46+4nJc2f2aXoKS+6M 5P6H8IwEZBt42Go3X9uP4XfgkXHr/5+pyk9+RL5puxpVoLdBjs3zu75OQJAcl+eKyqsp l5MkN9YbAiHehssxHVSJxqnNhVliZNNEmlwlGqsG6twdJP6ohjBYLyqHPH475zG6kxEf xa3w== X-Gm-Message-State: AOAM532RccPNjKw/IV7OTtcXDlG+dpoygc2bj2vjrXlUYic9xybPYNAF 27sKWQ2y5LExWeWofrSyBBoKGYVy8Jd/mtJj X-Received: by 2002:a05:6808:3021:b0:2d4:40f3:6b30 with SMTP id ay33-20020a056808302100b002d440f36b30mr12720638oib.31.1648301157550; Sat, 26 Mar 2022 06:25:57 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/39] hw/xen: Split out xen_pv_output_msg Date: Sat, 26 Mar 2022 07:25:02 -0600 Message-Id: <20220326132534.543738-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::232 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x232.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_trylock/unlock instead of qemu_log directly. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- 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..0423c61158 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_trylock(); + 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 Sat Mar 26 13:25: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: 554368 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6439358mag; Sat, 26 Mar 2022 06:52:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuZq7WfDmZAeANzzWV+ERdbaOf5fmUpO9q1Ik1qHSd3Nt3y2BMC4ljlpZjqJyIqQkgpkzl X-Received: by 2002:a05:622a:4cb:b0:2e1:ce8c:f097 with SMTP id q11-20020a05622a04cb00b002e1ce8cf097mr13842260qtx.395.1648302778885; Sat, 26 Mar 2022 06:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302778; cv=none; d=google.com; s=arc-20160816; b=DWHthWX6bHk/PYZO6Bt7xoB/dqOjkAbfyMcvuiJ3mxoOXyuOkr35wUlVzjzLqQGzM1 6lj0amxNGaYA0q6b+MZkoG5wt3hpwrStXKyCRzkp1pC3gscEYyZCzDCV6N8S2gQWBjwz IRVjbc/MLg/cL4+2FVgRUUQ8KgzuGmPnOBG25i+CqQTmgzCEcwNYZstkZPOSkmOu+7A3 EaJkhZzpUEnj8cIuXxi24HJql9COKi388cViM70Mo6ICMHWScIL6Yyumt+zomseGLNNw 6YzuVZ2j0WKWOW2NAldwQ1C5QGL+1muw4YHur2jzuJ5VLE0KzkTRQPF26ZnBpbPnqMod +H4Q== 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=iK8lqn1SAGzUB+I8J8nn0GkTbUc6hKanTx9K30kUSGw=; b=s0lxjI/blSraHReAHIGTRoSVqrc5EnTuQvW5I9cywPKtE5NvvCLra2tBAIz+sxWOZ9 R/9mHiGwuh4YcPIwpDLpKVF5mS7TPd+ZjTVWWe286i1TS7aOQoBdZUzXscTjvLF28eAY 5xGhb4aGZizrBo9EzFmoXAHlRu0vVtpP3O9AtY4yD0Pnc1yWng/AW2nBMs7rPNvgk5bT aAqFb2MfH2Sg1LLkCgADdN2OXI3iOqpf58BUTGHOajL350H/5sMG/5clHnFcbG7B8gIu GUKjxMPwYiR5/COQtmSd0HfbySK4cSDoI+NmfBsOAZmJwGyWj+6W+535Z8vDaYINTmKL BzOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="sD/p6eZn"; 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 a9-20020a056214130900b0044115348c24si2818169qvv.504.2022.03.26.06.52.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:52: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="sD/p6eZn"; 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]:56544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6qc-000801-LA for patch@linaro.org; Sat, 26 Mar 2022 09:52:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qd-0007MM-Hw for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:05 -0400 Received: from [2607:f8b0:4864:20::c2e] (port=36768 helo=mail-oo1-xc2e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qb-0005NT-6T for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:03 -0400 Received: by mail-oo1-xc2e.google.com with SMTP id s1-20020a05682003c100b00324b888f165so1708798ooj.3 for ; Sat, 26 Mar 2022 06:26: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=iK8lqn1SAGzUB+I8J8nn0GkTbUc6hKanTx9K30kUSGw=; b=sD/p6eZnoI/30jrjNN1tNlQRQ4BwyzrqSVa/JGRsWFPW4xwSS8T7A4I/Mr1MldClBF RcOlZSVHmI//Bpqu+iYiscmRxTlF4j/VBYSt4Nrm74QzV6Rht+MpUo/EnA/8/2jYNVTp x1Oj3bUr7ZIIHNLZle8b1VpmUZDWk6NntSCNnlFv6Q8FrTX3dKeJakmKZMUcE/xrqGQD jru0m1+phXWda+TZGGVGxewDYBFV6qoX6PHuw7ZZNR1MnhepXFZGfkdyidqZ1Qa0rC1P Uy5+6Y5qxueiIAHE58t1YHRW9ZJ9nMabPttKG9Dv1tvs7tOzMxst46I2WALP+HA7xreO e6mw== 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=iK8lqn1SAGzUB+I8J8nn0GkTbUc6hKanTx9K30kUSGw=; b=euPuu83j4lPaAKqg2/G3osmTfho4CCRcyEhmLMYhFNTunvafI9vVT2M3TUSNrH9lse /dIoCn5bRJJBrR6zwryD8h+wtI4+P9LnWSqIuvQ7scg8LSf0W/oCkDbcLn2hUtMfunTI xxNyDmtgcAq0UTke3fJfIjS16tzbdTNZRi1b3eOyTcVVmTFliA5UQPXlkuYnaSndD47Z 1YBVpoX+QwkvnZQ2dlsqXPCSfEeKV9RCL2jOxR05mNHSZXJgY2KCjDapTf1vOtIkKAh7 RLGs3KFRbhHGo7Tvt/Lhwd9oPRgHp0oGTjtfgwI3qXAd0OFhFAE5alW+iR5kcPGnW4XT oopQ== X-Gm-Message-State: AOAM532aBHC3AnIeKONaKTLx0mhXCzFDFbDqGuZ4GZWzXF9r3QzFPGBi DIdvnIJ7KEBzN28yn7EoFNJ/S+2iTijQtLEI X-Received: by 2002:a4a:b343:0:b0:324:512e:e340 with SMTP id n3-20020a4ab343000000b00324512ee340mr5741745ooo.59.1648301160056; Sat, 26 Mar 2022 06:26:00 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:25:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 09/39] *: Use fprintf between qemu_log_trylock/unlock Date: Sat, 26 Mar 2022 07:25:04 -0600 Message-Id: <20220326132534.543738-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::c2e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::c2e; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2e.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_trylock/unlock, which need not be done if we have already performed the lock beforehand. Always check the result of qemu_log_trylock -- only checking qemu_loglevel_mask races with the acquisition of the lock on the logfile. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/exec/log.h | 2 +- accel/tcg/cpu-exec.c | 16 ++--- accel/tcg/translate-all.c | 117 +++++++++++++++++++----------------- accel/tcg/translator.c | 10 +-- cpu.c | 14 +++-- hw/net/can/can_sja1000.c | 24 ++++---- net/can/can_socketcan.c | 23 ++++--- target/i386/tcg/translate.c | 14 +++-- tcg/tcg.c | 74 +++++++++++++---------- 9 files changed, 162 insertions(+), 132 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index fb595d1eb7..648f4d2263 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_trylock(); 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 8d0315de75..8a896e772d 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_trylock(); - 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 71ab863c18..4812619f00 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_trylock(); - 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 1506755f3c..af8798f98b 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_trylock(); - 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 ddcbfc724d..3340bb7538 100644 --- a/cpu.c +++ b/cpu.c @@ -401,12 +401,14 @@ 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_trylock(); - qemu_log("qemu: fatal: "); - qemu_log_vprintf(fmt, ap2); - qemu_log("\n"); - log_cpu_state(cpu, CPU_DUMP_FPU | CPU_DUMP_CCOP); - qemu_log_flush(); - qemu_log_unlock(logfile); + if (logfile) { + 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(); } va_end(ap2); diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c index 300313dfb8..23d634af6f 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -249,19 +249,21 @@ static void can_display_msg(const char *prefix, const qemu_can_frame *msg) int i; FILE *logfile = qemu_log_trylock(); - 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 (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 4a505643e9..a6388563c3 100644 --- a/net/can/can_socketcan.c +++ b/net/can/can_socketcan.c @@ -77,18 +77,21 @@ static void can_host_socketcan_display_msg(struct qemu_can_frame *msg) { int i; FILE *logfile = qemu_log_trylock(); - 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 (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 3fb8b530d8..d71bd2b0f4 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_trylock(); - 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 2f09114bf9..892f640fce 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_trylock(); - 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_trylock(); - 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_trylock(); - 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_trylock(); - 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 Sat Mar 26 13:25: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: 554363 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6432439mag; Sat, 26 Mar 2022 06:42:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA81r7zHG+ztq9IW18wH/ngNbN2pdsQGoD4HW8mb22HF+eP/zXTh4U+a6yU+zY2zFkkAlF X-Received: by 2002:ac8:7dd1:0:b0:2e1:c708:12fa with SMTP id c17-20020ac87dd1000000b002e1c70812famr13513726qte.532.1648302152939; Sat, 26 Mar 2022 06:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302152; cv=none; d=google.com; s=arc-20160816; b=J9GRvXuoLo9CmXcdJ0+ULxH8y5esbqNwJ+uFQ1WFX4WJuu/Z7bkQCTltaesE3lpPpo WSnQ5ZLNZkUUOHF/1ioOSN0mKsrIB2DyKxCrfAJY2UzSRnZyGKzVWyHPRQdpV12g6TBJ 7dyt6+BzACGzIxmDn6SubrfElU+PY+yJglPzyz7JoyfhBd6CBasXXF36Gy573wTeOabS OCS28gHOOXkiHKWBvWHsoMqqNV/4uXVz/PRR5VZe8t2DiIqjONWNn/7w9hU0vGA3WDaq 1AapgP5g7rA0I/aDK1SMufhp3Vcc2L6Mv1hviJd2VN9FAk1+JPeI4iHXeih1kd1YP2bY j2mw== 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=KQ2Hs1fcPO+xNkXsj5Tr5G1f8x8slUJxiO5yDeUu3l4=; b=BmPtCs9GM0aWMG0Z1PwV+6oW4hgheCNG4mXdVHxb1EFAFntWU5N8G3wfMCzbuqm7uH UPjw+szfCjbMYDlnDb1GngHdOgJSOSI3Ii6PZj7bB2LcfCXTSBEoW6vMvNOguCHwuc37 9Ie9bNU5vSmWfQ+S5Phe3JvlD0CM4n6fzvclw/Y9B9tYNNDMDd6vwQKK9/AltbzUGxr2 J4wQhWTeemKEPXkGDMeUxgkD8xTwMVlFcFIVMprtHSxotVgNxI0mrwGTjHxQrZQX35Bh JWS0k/LSITl85791QuzrlLrt8hOfnTS+WOR9HLD2CLgiGUT8xDZvPKDJmxmIGA7UL2tW 6Klg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ofby79uC; 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 ay6-20020a05620a178600b0067e4be237d3si3837328qkb.24.2022.03.26.06.42.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:42: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=ofby79uC; 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]:43156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6ga-0007M7-CW for patch@linaro.org; Sat, 26 Mar 2022 09:42:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qe-0007Me-24 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:05 -0400 Received: from [2607:f8b0:4864:20::c2a] (port=38733 helo=mail-oo1-xc2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qc-0005Ni-Lf for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:03 -0400 Received: by mail-oo1-xc2a.google.com with SMTP id v19-20020a056820101300b0032488bb70f5so1783278oor.5 for ; Sat, 26 Mar 2022 06:26: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=KQ2Hs1fcPO+xNkXsj5Tr5G1f8x8slUJxiO5yDeUu3l4=; b=ofby79uCP/bmBC59WvrK2z2MWJPkO4+HYsTugTZVeQXakzc6dlyN+d0MskEFFpew5N RHVIH1dASecnf7PPF27jGOf7DEzlIW6VADNCfqrL8CQZ4sTivhjD/rHH08K0K4aRm7JL n9ckgS7Mn3MqNxI86K3f1omVT9FyjApjo3ACsPNU3B9c06U9xcf5vO/Vqos8W7/ckneN EqFveCIF4X8SQ831L8CcSdKLrEfsXHIPEgAJRQhzgySgt91i6tG2CQsz32itnvZCo2w1 CUZbJsHXLhJ4XoxQzdrk6ZFIyXfwQcx6RqRuWG5DFFco9MqrUTzLCXeQAcsr+1CirwGf ZQEQ== 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=KQ2Hs1fcPO+xNkXsj5Tr5G1f8x8slUJxiO5yDeUu3l4=; b=PXC24XqsDFzGsLBNZ/JutSXBgRG9Q6AzVyWelkOxaZIJkdM2tTmx4Rnrn1VJsOnDQ2 FHFQTN+6+JiN/ANIBZ8hHnO66Qr6SYdtXItU9OGp2v8UGteRuYz/NjMrf3TzUh57mB0L P2dzODLjPOwctdKAVoyYwhJK9420mMCmyGMOmJBTS1lN7tkxp6OozZYsFEh/oXy/ZqXf qTjd/IJKhwfbJJIhD7TQqY0l3Cb4cawBVwxNcy336TOYiGj5M+jFIxvGn5ZG3wu9duCP hYf6lw1jncoHXn5+SWBxhPZPjfe6Pte8B1t6ateSOOfECSyYY4PvSEgfSRMv05ACdz4a H0qg== X-Gm-Message-State: AOAM531FHSTyntbP7/3FBdwV4J7tyhvmIEfevMpQd+n2y+vQRqzlAAIG 4mNtV8b/XpVz+JrmUVsIzMh2KpOjT8nlanAL X-Received: by 2002:a05:6820:350:b0:320:be2b:4fb8 with SMTP id m16-20020a056820035000b00320be2b4fb8mr5719283ooe.2.1648301161579; Sat, 26 Mar 2022 06:26:01 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/39] util/log: Remove qemu_log_vprintf Date: Sat, 26 Mar 2022 07:25:05 -0600 Message-Id: <20220326132534.543738-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::c2a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::c2a; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2a.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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/qemu/log.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index d090faf22a..2d9455dc85 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 G_GNUC_PRINTF(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 Sat Mar 26 13:25: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: 554367 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6436428mag; Sat, 26 Mar 2022 06:48:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcF4TMZVQbzeorH1MwHAxjn54NFNxfmv0c6CFUqCiIn5tfW7xLg/H5cy8ZgG7gyTmqbtx2 X-Received: by 2002:ac8:7d06:0:b0:2e1:d1c4:868 with SMTP id g6-20020ac87d06000000b002e1d1c40868mr13808999qtb.143.1648302508096; Sat, 26 Mar 2022 06:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302508; cv=none; d=google.com; s=arc-20160816; b=DJJlB2TJaTC5m8q//Hz08WZ07qZsz0UWetXhVSMHzd5qeAyDgEx7/SVGrjAghkI1yR Uv5Or63xkq3pqjJTbPOX/9Ucf2GIEHs6GtFPEdAVardWu2L9VdtkMR/rAqIX1Rc5YhHK q5tMDCn2DJ5dNj/B/J9iVweUWGjTEngyzkbr9FTgqEt+aY3swZVzAXRYto3JLALOyyEb O+5eMNPY0V9erRqvRWQ+HxihkngOxhZRW6Jgs+aUIM8xjnIe59m7RfBR0D3mzN7GUjDF rGZHIELKo4cGbnS5HqL3XNxeSGvu98wuK0vKL1LzCE4jWWv+AOstjGLdLaLKqU5nRxk2 MChA== 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=NkGsSfn2WSH+h/mnqwQgaV+ZVNnbzH10Q2LstATJxHc=; b=XMvizS2ZEE3bGL/rm9w19yuQcJ7Av3w/z4Q4UPHgQqJS03dTgR22iPGTdEWpN5y3Z5 ZuNyXHe7XeJv99gKceigsa90+mbKQyJpVohRBMqgYEbyisqhsDC8M5mXDNDuHxRfrRn5 2QWMWBoR3/JXXlB6aBqcBT9clnYXwsTCp2G8Dq2l9u5VtuNLinWK6tjYZk7EYchmBEtM 7zxUftpelPNU70Y4vOyHoNxst0g5h/8aWGF63xK1H1WDI1VHcJ/UFTOm9g7j1jl3n81c P82o9mk2SQY5FQOUEjLZfsfjvcVuqcY9ypgavvqidFcIUb9U2GhsGwb/gKapSE2yd1a8 BhcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZKGzLeY7; 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 a17-20020a05622a065100b002e1fbf3bfd8si3527205qtb.457.2022.03.26.06.48.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:48: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=ZKGzLeY7; 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]:51762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6mJ-0004o3-LH for patch@linaro.org; Sat, 26 Mar 2022 09:48:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qm-0007U0-QT for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:20 -0400 Received: from [2607:f8b0:4864:20::335] (port=34638 helo=mail-ot1-x335.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qe-0005Nw-2S for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:05 -0400 Received: by mail-ot1-x335.google.com with SMTP id n19-20020a9d7113000000b005cd9cff76c3so7470058otj.1 for ; Sat, 26 Mar 2022 06:26: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=NkGsSfn2WSH+h/mnqwQgaV+ZVNnbzH10Q2LstATJxHc=; b=ZKGzLeY7Qs1k4/RCASRlXIPZvqt/2exaMzA0Wv95BYMxOHLz2V0Xtn2zea20IfFuKI yCzGzecQV74pvDbP/jLhmGhPnXypBclIZznvv12N3IGAj6w6yO4v09682l5YTYeFHpmN qYrf+33blP9c2TrlZit2SCDC7zYq05GsqKdBSpIYKqZlFfMivcRr2BAdowCR2mwioUGj P7/Tt+acap9X5j4o+xJRJCQVIjfhuGolFkvaXZiuxBKKgeULohhDewA9qasUQvqjC4q0 H3iStPF+ga86UCfWEKAEjX7z9GFG7EPpQI8jzLhIsmxOk7v9B3lG5Qd2nl40dNOIz2LY eQMg== 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=NkGsSfn2WSH+h/mnqwQgaV+ZVNnbzH10Q2LstATJxHc=; b=IYPdEyNRqudOzvrL3a12GYySGnhSpxXC2wJQDlbjEGuK/2yOdjDS6CwUeHuytAob4J UtRPHNAn9FX0YIVEOcJjMOnikbA000/8WL4FfuTeSQ9QFbD3MWYxNez/uACBlzN5Hpyr JSTnMBixJFlfbcuSTolbfD3F+wnueQyXizPtSgRblnIBjxzbu77hHmjeFPRl5BVhjLIW gA0zzOwtVyjOY0vwuHk/olbX1smcu4LXpugmki5Qc7FIVKQExNrsXUSWI+XGnqHqD8A2 ZfzQDODk8P0nJcvXt6ccWf7xhXS4lAtJ6umZ64Zemh594LkoXrLRb9MXH28gF1+wXmtp du+Q== X-Gm-Message-State: AOAM530GWNSv4312IOmHEvH0BQDrIfkdtGOT6oOxaFarcBbJF9K9h+pl UMGJKQH9c/vinNvRGYT2IngvBV4C68Ox/coC X-Received: by 2002:a05:6830:14d3:b0:5b2:49d9:17b6 with SMTP id t19-20020a05683014d300b005b249d917b6mr6243703otq.321.1648301162910; Sat, 26 Mar 2022 06:26:02 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 11/39] tcg: Pass the locked filepointer to tcg_dump_ops Date: Sat, 26 Mar 2022 07:25:06 -0600 Message-Id: <20220326132534.543738-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::335 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x335.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 Reviewed-by: Alex Bennée --- tcg/tcg.c | 109 ++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 57 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 892f640fce..25e987d881 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_trylock(); 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_trylock(); 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_trylock(); 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 Sat Mar 26 13:25:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554365 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6434969mag; Sat, 26 Mar 2022 06:46:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrj+PY2rek3KuYUMrGDQMfy/r2sJj7vIS0btL3mJ/51+MaIC16GbJf4qYouGZ3zWguMaYA X-Received: by 2002:a37:54c4:0:b0:67e:9cbf:a984 with SMTP id i187-20020a3754c4000000b0067e9cbfa984mr10451042qkb.215.1648302380554; Sat, 26 Mar 2022 06:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302380; cv=none; d=google.com; s=arc-20160816; b=hpUHo7DWSk8BgjEB9gaJct8DJAJenukBTCnHhCaNgaItPDgSj/ZU7OsGoPL/alHV38 uUpKeqIGGURw9m6MIrndeCDmSbZyTlHs2fkJoaOrdudGvT5O/K3gG4CTyjt60sJPss6D 9K/EqvybPGiIc1t7TnEpMffYRZCMgquZCR2Lv+pJbbm7oTxl58RVQrmmQ53OhGWbJNMx hdf5xhqkQw0dUbZLLjx0i/Cbd3AwFtuuY/MT59iGg+1pY35N5TN8pqsR4QEG8novuzzl 575iWQp1KjJo+USoH/lT9F7k6h1pIWtq859azt77cx2pfVukNLKyzl/hZjuTJ6AKMWk5 zXLA== 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=srb8zYnrls4BFF2+J2DHCJQ2uN96wtiF9F7er96M9hY=; b=GsB/aYuWzDX8Vx5GsXlGjnGmvso4CSE14NxqLJF3w2jGxOHqoWWngR+Fc3zwycEgVA l8aEIr1H2tzk1m1P8O7hptiIUFgGCpPuatpk3fde8FolEdDE5OXWPdYFrQF3YlWNBwBs rqsbHpeS7YurkkFZqPt5nj99YbK6PRAPSQSFFsJLAXF0tM05OXZbb7znnWOSnXnJSep1 6GPdnSwfwG7PgmvcSVO6/kPSfAX60WtYsXIqJSVP5ksMjoS949aAUVB7aMBB3m8LDEnO OiFoCV9eVPV9ywbdrqmgouMYp6h86LlDmbuq9lG1zA9vWnG/LZP8MymUY6slwb6+5uTO c5ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FX1UT3pa; 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 h18-20020a0cffd2000000b00440e46a7d39si3141686qvv.471.2022.03.26.06.46.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:46: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=FX1UT3pa; 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]:48074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6kG-0002DH-1f for patch@linaro.org; Sat, 26 Mar 2022 09:46:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qt-0007V8-5D for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:22 -0400 Received: from [2001:4860:4864:20::2a] (port=42179 helo=mail-oa1-x2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qm-0005O6-3p for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:14 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-de3ca1efbaso10716476fac.9 for ; Sat, 26 Mar 2022 06:26: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=srb8zYnrls4BFF2+J2DHCJQ2uN96wtiF9F7er96M9hY=; b=FX1UT3paPQJP0shwoIwQJ8m+73l3C5Deh02NEOi5L2qAXv4ozTmaj4w1H2j05uNpAa EaGl5Rq/uLyjylw60X2rW2mTIggrX322x3J23Khs//Nb0Zhcnv4M6+ETCKR3TkNT9Dok hYUaWRJwrIiaPt1Es0usxiMmNRuTbd+jRSQvUSht+bpkqGJQzNd1TqyoM7xPFRAS8aZ7 1G3Qbct256VW8hA1bwudExbvS7/4dlQAAglQRfpOp1LbeGe8j2L5Tbs6EjurnDT74xgw 8JbrkYaBjjcnkfYOAcRuHUlsRvE5xAXxbJYJxiSBFkIuf2m3lj6L5iT2I4m3GZPJ/aSl e32w== 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=srb8zYnrls4BFF2+J2DHCJQ2uN96wtiF9F7er96M9hY=; b=z5JgtPunT+JyE+6f0p+2NPZaf+4kbHyZSpe2m+5UcvARvnDuxUVZnbcDk7xC1hnFMV 53TqvX1FIltTrx8UOyZp2EvWEiV1f4WoVGL83PzGBLk81Nuz+7sa/K96YQ+FK3SzqD8V KvODFF+irBdJXNUBpBuPUHXpMAM09ji8H+bOpptmpRT2shXY7AEL3QwsQnchL64PDTjO Ju+XV48z63mWnF/WgvFAW2x5yWTzhas6JFaOTOxjs3I6WzGdYHo3oAb7nlZQOLIdfZpb mZxuGquAIZe9VUqCmQX9HeAxSv/L5otwsGrg8DBs8wqR5uQ725QfcTpersrZil71hqGo fRcQ== X-Gm-Message-State: AOAM532URR9bvBZpSrHNq+9Kno/i8mdjmGyxwTtYMu1vpIVvj0OgDhVY jKIOtaWTPhJubHAmrGG6sClsJS5Zoud8I5cS X-Received: by 2002:a05:6870:4688:b0:dd:b535:f9c1 with SMTP id a8-20020a056870468800b000ddb535f9c1mr11291065oap.37.1648301164315; Sat, 26 Mar 2022 06:26:04 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 12/39] exec/translator: Pass the locked filepointer to disas_log hook Date: Sat, 26 Mar 2022 07:25:07 -0600 Message-Id: <20220326132534.543738-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2a (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2a; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2a.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, 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 Reviewed-by: Alex Bennée --- 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 af8798f98b..fe7af9b943 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_trylock(); 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 d71bd2b0f4..4659a212b2 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -8690,12 +8690,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 Sat Mar 26 13:25: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: 554359 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6429159mag; Sat, 26 Mar 2022 06:37:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcopByvuJ6f5gT5Z3bAZeOMgodfsJ9VMpSB6SA4WPlvY/XE+TfvDBxT0T7bWlullVyIZDx X-Received: by 2002:a05:6214:1cc2:b0:435:1c62:62cc with SMTP id g2-20020a0562141cc200b004351c6262ccmr13287436qvd.26.1648301840615; Sat, 26 Mar 2022 06:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648301840; cv=none; d=google.com; s=arc-20160816; b=fdDofkQtykLkpFITiUIBCUcHc2hy5R4c1aWEdCifAZTAIAlrrHRoNqfYXbmXR/lLbH e79wsWgqqoRK+SppWXSfmhDYkUOhtGaDQc8dXEE/aHzbo2ZbtH8EQxHINIMC1abp6BpJ RW1u++A39FQp7Acbp1lmOTfycqtluxysyxkEbJIBHb9XlRfwEMS+1c4TQ3O7HGl8eZIS 5oik4gF4FlXRlTJM+8qQd9TbP3SEmWoc/Z37il2lrRw5xQJPDxFidct+SWeU38BU3j98 y92gh2S/Dv/bXZ1AS0Gj3Bsegyj9yEvMupJSCjkT7yfoTsSNQelqOKOFN5Gdo2WvQweK wrng== 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=ehH7VDCeW4WIVxtWVdIPmUT3p2JNkhZIJXr8A+U3FbU=; b=MdIWEjB+iCxCoxvukV1btavMaKcgD36LJWXBmXJIrS4BPl+L4O0tRM9D2i0+gCqYf1 IpcWW0jSJYoYvf47XNGYFENJbAy50V7GXu0tGp2moWh76gJ6pGpu3Pa0xjXxa0/n6qPJ 261me//mDDfwCbAej16n1MAA2Bhnup7w3ecToXeIwsz64/xfyBiSREsHpD50uOXnWilq 48ni5KNG0LVF0fopZIO5WlHhmG6EkVFtyiI0J0Tx4Z9aMsjeIaCBzLP1NsI5JK6tePfq O+huVjqtrGYVIYvR+tFYwLGq7JcjT7j5tdD3aXMrerewC6OE9dHeyALRXTvV+LEXrWLB xC+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XlUfWle7; 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 e17-20020ac845d1000000b002e32632c8c9si2758208qto.560.2022.03.26.06.37.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:37: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=XlUfWle7; 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]:59442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6bY-0007ht-7s for patch@linaro.org; Sat, 26 Mar 2022 09:37:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qn-0007Ub-VT for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:20 -0400 Received: from [2607:f8b0:4864:20::332] (port=46628 helo=mail-ot1-x332.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qm-0005To-Il for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:13 -0400 Received: by mail-ot1-x332.google.com with SMTP id z9-20020a05683020c900b005b22bf41872so7440111otq.13 for ; Sat, 26 Mar 2022 06:26:12 -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=ehH7VDCeW4WIVxtWVdIPmUT3p2JNkhZIJXr8A+U3FbU=; b=XlUfWle768YnLvhEfaiOFzfGBUbIrB5d1sgNsEMx6n0gxra81GShAMGC8tNYIjRXg0 sFVaN/hj+cmcIcrcNlefDwGcUd4nU5d0oh7Ox8RLO6i2K0cjNaMZw4B24XTcjPJ5nKL8 +ui7qDppQdU1Glsel0GMYPMuLgZHOkd4V25qq1SVtsNA+F/jhRYshrtmunIQSt+bnbRt QLG7egn9x7NtonrsQDgj1VzIarBNaUfKHBeApQcARTTJaXuukvwxlisa+Sqem7sXVkfP eviuMYsqIGJ15oq7vAnNZU2jdLdLiHwjfINUOZHY4PEu9q8ESGqLlRTsPpyuneTsN4OI IisA== 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=ehH7VDCeW4WIVxtWVdIPmUT3p2JNkhZIJXr8A+U3FbU=; b=SK+3JoVYpZjAsqP89C+QQcGdhySxRFBZOtFv/USSDLGuf0JKAoZoAhAes3j7Q34rIY FKWDGXFEfnkYDmQvxtQYjM76VEXe0Tv7sRSGdJOKgJVkV0GS0sM1ZRDhD1L6Ox51BTG8 hrdz2KtUSz1D2bKQahQEkqBYaJ+/oBSUf9CmAkbj7CkIV8wfqKbd/MTLsPi6OkGOOa2f UqsTfaUVqs9IRPj0/Posg3qj9mdkwXGAFhfh/27Kfe4YU+z81mWvOfQaGqlF9J1kXet+ Yxmocbjf7VxO6sLnJAO7CL/ptP9eW3gqDvID2pMnvM61ABzLFlyOI8gEtPqootYQwQhn 0jNw== X-Gm-Message-State: AOAM533bzNLPh+0lEYKguuHBlyslePvA+xms2gLcJxIh4Ywqm+FmXeUo /Y7vOXxt9/8J7uF/AQ6QS8O/64mvR7QeATvb X-Received: by 2002:a9d:7751:0:b0:5b2:49ae:76c6 with SMTP id t17-20020a9d7751000000b005b249ae76c6mr6272485otl.18.1648301171448; Sat, 26 Mar 2022 06:26:11 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 13/39] exec/log: Remove log_disas and log_target_disas Date: Sat, 26 Mar 2022 07:25:08 -0600 Message-Id: <20220326132534.543738-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::332 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.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 Reviewed-by: Alex Bennée --- include/exec/log.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index 648f4d2263..06ab9841ee 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 Sat Mar 26 13:25:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554362 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6431523mag; Sat, 26 Mar 2022 06:41:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfXZwovWWzeA+qW2E/DbxbxPtWC2eyxx9uULxcBKKj57IexuEJn5ez8C/9Bk+bNi+9mlao X-Received: by 2002:ac8:7a90:0:b0:2e1:d84f:1164 with SMTP id x16-20020ac87a90000000b002e1d84f1164mr13914432qtr.314.1648302064921; Sat, 26 Mar 2022 06:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302064; cv=none; d=google.com; s=arc-20160816; b=mj4x/m23l8Ap0VNHxk+1PYOkGKnTKL021hDStZftMGA9bIDLAOX0cXxc8M1GLcqawB VLfE32qqSEmCAZOh6EJQW2TNxiIPvTzx7CdQBRZBspXnpdwBb52mA52dJ364K5lOZ+hF xpYLrnRYYQoq5EfAI2NHv0cofIHt4rwRHI8Cukq2Tuy96Hls8v/K22XKA8iJf7Ec2ERP vU09t2542LL8rQuLo+2CtiRIUwzkuzldyZNdjbQNjutBVipYOkRBf+2oydYNrQB/TA8S I9MMLqMh8xkepxdpnrtAj5BLu2xNs40YhDoC4YvQ56+yEpjkzybV00V3UPYBg6b8JerR P7XQ== 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=L2qbFaN7OaGfKK0O5CG7ZbPVEQZ58wXHUVGPEOy9UfM=; b=ygLprcRz4QGb5AXWpic83Vyzi+LofwRECCzpyBEnvmDhcKQGXtgRb/V3z2/0iC2kAr w+VKP/0CXohScC1CRNbKnedSYCtMuqY4y/7gFbX8+B5uWSCT5wWA+cGNzzkfwhq0SzOT eb2TFTvbIc6XqbGYCrBbD1VP2Yitg1+JgtUln/LA9WEyQEDWRu9k5nFZhY1Ivx3LUbU3 E/1j5qO1N0mIrPoMcUGuwVk6i0DF9o18eRNN8U1ZnGSY6wuahEOfbmHpyWEUXc9nfB7w bYke4inuRBAi4blUkl+dOr1QzohNbSbYQ8nhCLvbCiE9P3OSqcHS8cCdr9DzkGGOLsrG zGdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oHKAD+8l; 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 bp19-20020a05620a459300b0067e4be238a9si3752093qkb.238.2022.03.26.06.41.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:41:04 -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=oHKAD+8l; 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]:39500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6fA-0004p1-EU for patch@linaro.org; Sat, 26 Mar 2022 09:41:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qv-0007VG-84 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:22 -0400 Received: from [2607:f8b0:4864:20::22d] (port=34575 helo=mail-oi1-x22d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qs-0005V3-Vt for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:20 -0400 Received: by mail-oi1-x22d.google.com with SMTP id v75so11116007oie.1 for ; Sat, 26 Mar 2022 06:26:14 -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=L2qbFaN7OaGfKK0O5CG7ZbPVEQZ58wXHUVGPEOy9UfM=; b=oHKAD+8lhiXdJD4nu6JXyrx/7AnFLCmFzjhSIJzeSxlijFVfN/hPIvIsoUCBiZT22k rRXSctSUD8wmr2lkJqk8Y3sK0zUIfL+WwfRDdlIoU4Pn5jYzrZLPUcK+MIxhUDvL9TtV wsJ3fe/JHBDUytggjSlo5J74imcEKkcULPgrK56Vw77JCAeIRC/M7+D6DElHZNMrdvj0 SmoMfr9KKxq8gxtaxvq5FXx+3D8N06EGOBjMwMpz5dtMXy2c83a8h7HcvHpFkQtStRfz E/NaJfRJ4erC36qJahK16MH6U/P8FPL0gDiVeygXjwd83315TqSyaSNmuc96Q0GZPyK7 Jriw== 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=L2qbFaN7OaGfKK0O5CG7ZbPVEQZ58wXHUVGPEOy9UfM=; b=mr4bdvFZoFRmIyLwrCC5FqDeDYcovANTLl9FxzZuLlliUDX08SSQg005TFA0MBHGlS K/ymnPKJFM0US2ilapzKr4pk/tN6CnI5k3RLFCTNdRJTegl4oFtV0dij3wwVeczmW9il nV/y9KSraxHmOJKi2u9v58Rv4W4DQf3WmfSS5BJZQEp7NpJRWo1uPQ7zl59t04iyUgwN VHnnpC3AXWwPNy1mIkOfcHbxmjSGhMRER6EafYqglVRn9vUrasGFyDeaNzsX9gSNS1cw t60KAntc24X49hvEWFsdHz2gNidxMc2xMRfRjO9pmIVis2IEcEbW/GM5fqEvE+D6vHiZ FgpA== X-Gm-Message-State: AOAM531Y1epzPdWNxiP0qdHKSM7b2A7l551mWgpM844ly1VlqJorKMmM gS38EHZdL3xtoRQQ1ZcpqDU4m+iUtTU0UudB X-Received: by 2002:a05:6808:1183:b0:2d4:5eeb:1ca3 with SMTP id j3-20020a056808118300b002d45eeb1ca3mr7997460oil.8.1648301173377; Sat, 26 Mar 2022 06:26:13 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/39] accel/tcg: Use cpu_dump_state between qemu_log_trylock/unlock Date: Sat, 26 Mar 2022 07:25:09 -0600 Message-Id: <20220326132534.543738-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22d.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_trylock/unlock, which need not be done if we have already performed the lock beforehand. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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 8a896e772d..931643a510 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 Sat Mar 26 13:25:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554375 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6442968mag; Sat, 26 Mar 2022 06:58:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOcyX99nhKSGZd+nKhrXNoLgqZvkY3jzoH9DrQTwj+f0byQt6CFZsnXKhIuYuCK4Xkvi0X X-Received: by 2002:a05:620a:1102:b0:680:ae2f:3deb with SMTP id o2-20020a05620a110200b00680ae2f3debmr7075685qkk.79.1648303115408; Sat, 26 Mar 2022 06:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303115; cv=none; d=google.com; s=arc-20160816; b=k1S1Xbk7+8gKGqqvlvSO2IPr6EHf1N0TO+HOnpbMrrJIBrt9eqC44Bt7pKi9qUNGKr CYKUflVXbouTH1Mv3WDjev+k6Up+UgRidfI3PyrKiSHtQCji7su4Uq/I6UGjpNAA+z0D UEYPEO65SNCBgJEdXT5CSr701UTu0LFN1+iyRq2iLp2JbqlUzxuyegfm5h6KhN07FWKq uQkXp0Ro3P4EdZNhrc4KsjiARcFVL2hqe6KZp3sc+6kOf+q6ldtd+e5r/uiofZeoarr9 tZwpwX/del1rEfth9XYn4KPBd1LPrmtfkzNJlgrqD2IbKZ2BpZ7fNCSOliZhmbfgdlDB WmiQ== 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=KChjyOMgpewWdFnPU3AHhb0wY0pkdi2s50pAiOY+Ng8=; b=cQINzJwujNpU5bBqH9fqdZHQrX7L/K3qBVRWjTuh+VyNnOA7Wic8yr8Yg/aATj3AfN hJDKHWMv/TQI9mNfEQeZJCP4k7sHTcX354ZYUgFQ3UTZ5vIqJ97X1VhHVQTHfS4b+mcb JisXVm/Njw/KQXTeAueiFCWeaeaPW/r5Wo4/uiNb7rVOUFS7FjxVisgguZtWU2y8L5Pe rjJNgUDOCwZ0LgaYbpB/WcF+2SsxLbz5R7PJpYPGfBItZ0E88TbqV7GdeuOyDppd1fNV NoJiN/cR/8UKc6YPpbVLGPOjgpgQcQt1kNoDuI9ApjtXxOpRylP+mlYhnz6iRQVixgqa Z96g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HHH80PaA; 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 b16-20020ac87550000000b002e22957adcesi3027695qtr.336.2022.03.26.06.58.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:58:35 -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=HHH80PaA; 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]:40588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6w7-0008I3-0W for patch@linaro.org; Sat, 26 Mar 2022 09:58:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qw-0007VS-Fe for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:24 -0400 Received: from [2607:f8b0:4864:20::22d] (port=36803 helo=mail-oi1-x22d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qt-0005VE-0b for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:22 -0400 Received: by mail-oi1-x22d.google.com with SMTP id z8so11090882oix.3 for ; Sat, 26 Mar 2022 06:26:15 -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=KChjyOMgpewWdFnPU3AHhb0wY0pkdi2s50pAiOY+Ng8=; b=HHH80PaAu3a6VUCSwDDLdmgo42fE5cIr7+YVCinZmBjrGUnOJq6A1KkI2zXZaRshTR QpkNbAx+01RauFbeL9Cx/7buc9S7BHxPgJZs4YBJjanz84ci/65XBXArDdHBY5N9egD7 pAZOKFBjpsflIa20pOhiXe18prOWj5tXfTQ2nZ9zGmJuSQFw94ZQaYZ0UDjAYe4rMNwd PvrQCtjgAoK8dgwGcDoJ0YItOGak/Xf/+HBPnZGVlVItMCq4PTQUcNoT2yYv7sSJkyfI f1FUKTDnHVkjAD8xfqllRsX3dtvSmAyBvI/WEE7Gt7PqvwX/ilQCBH7s85OlPStl5PLB 51XQ== 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=KChjyOMgpewWdFnPU3AHhb0wY0pkdi2s50pAiOY+Ng8=; b=7iFIeQtdWgWNPqNeDH1sMCSmAS2PMisSn7eLSvvYAtp1YFgSpbM8xRXts/on9TG3Tb oRAp/5j98jI4S36543VS5tF4SGmYA+9+6SNJJ8NRPD2ULSGF8TijaosA7wzYI6ml5Iuz YAGi5/OSbHsIFAG5bSSpJ7PI/Sub/SpX0ukJT4dwgQJW3RejH7w1UyG/ogwxkgkP2bep kqCN250eZT9j5o0FZvbpg5YHv+JQITbz1lh01DQtGWFIT6tCIfvICmORXowRva3+1D3U YEyZ6wgrCqrSe9UBcbCkShJZkwYMYhxPmCynl04RIusnAiu3bJy66Cv50if/Mkq8YRkN 4DCQ== X-Gm-Message-State: AOAM531VCuPTFy4Hn28F9m43mejw6xBZS4sC0dsSpAIkc25XTaV5WZs2 HtozD0L8BqP+zOVixfmjAkPJ/gI7w6XK5NsU X-Received: by 2002:aca:ad15:0:b0:2da:692e:fe97 with SMTP id w21-20020acaad15000000b002da692efe97mr12464292oie.26.1648301174616; Sat, 26 Mar 2022 06:26:14 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/39] target/nios2: Remove log_cpu_state from reset Date: Sat, 26 Mar 2022 07:25:10 -0600 Message-Id: <20220326132534.543738-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22d.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is redundant with the logging done in cpu_common_reset. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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 Sat Mar 26 13:25:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554376 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6445178mag; Sat, 26 Mar 2022 07:01:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh8+/GEVBw6ucpQiUpGgRxhnHI8Z5JMyQs3edpQHMhQ/VDOh/siNJpTwXJXw120DP60dQr X-Received: by 2002:a37:b4b:0:b0:67b:a6a6:b209 with SMTP id 72-20020a370b4b000000b0067ba6a6b209mr10239722qkl.286.1648303287279; Sat, 26 Mar 2022 07:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303287; cv=none; d=google.com; s=arc-20160816; b=ETIbqvK3KbpZphX2BL+dV5OxX3hIBWhk0Qnqs72SsRi63KXwfcMB1M4pIeLVsuhpG0 J4RMY7kgxw8+Pcr7DY76FssSXOkQyhrApIbBSJoUnlG/jU6dogufUvZvhutMHN6Lm9Dl 9IlbSSdat8vRYeVl50MF9jO9QiuHi5F+EOAyHY6KbncF6TQJ/TKYVqLldMCP4itAYztb Ug6UJfYPcYdOPD/8jsAH6mb37Wlfd67ReQ/az6emeXzqK6eD8QqENII2ZXUtjAY7FIYV O5gZtNjt4DurF9hxZxCjnKfyd1dxmtmFyjLbRn/gbxolwVtgQGTOJnB7gaO2/qaq3Qcn I+qQ== 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=aDLKHovI8bxO2d9YjJwk21iI6jYdGi7gzankaymnjFw=; b=D1oTSB03MWlkfINfUXCbHFMHGYOHS52FvSSRjg6VOMeKQeECFVAmIrNwDN94ts/qC8 5eULhdKg1JmHWzYz4a4fLbFNwf6FM20neWwmd8oRAmldO7LNUqSZvdfgWwQvCF7dFAZb olxkCb2u4G+ml0s0XtsDB3x4yHn0iOuE2xpMiKkF2b1HQOR3ExNxzTa7EgDTAZIJ901q WPvrVIx4s0gGEj7YCAzmVTCYlqj2+BLAsK077AWWFQVDk3jpjoT1LESWUti1L7WCgHKz eHjiK7Xsq26NEbGj+umukije6+/8CMynRfLZCE1GFJhiSjwQC5yfE+pnxSjwKcpg+2hp /PBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iJP4RDwE; 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 c6-20020a056214136600b00440fb2da63asi3672491qvw.509.2022.03.26.07.01.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:01:27 -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=iJP4RDwE; 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]:45212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6ys-00032R-OG for patch@linaro.org; Sat, 26 Mar 2022 10:01:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qw-0007VV-J4 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:24 -0400 Received: from [2001:4860:4864:20::2c] (port=45853 helo=mail-oa1-x2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qt-0005VM-0N for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:22 -0400 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-d6ca46da48so10699303fac.12 for ; Sat, 26 Mar 2022 06:26:16 -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=aDLKHovI8bxO2d9YjJwk21iI6jYdGi7gzankaymnjFw=; b=iJP4RDwEAHqJze+/ngkwoyGpNYqp9ae9Fq4hoWkXqnpIpHSZcUMrxAdKD9FTDHWRU8 s9NyOYP9LXk6AlIz8VZycYZvLtzbqKb4gW2M2yQsm0vbqtex141DxvRnZdJcSimClcBo THkfIeCnvo0AtpQRSOImXr2tJUo3PxjsGctk8yFzUoNYon+FJRNo0AHCCb//ZXO5ydiN zRhb/07rF2+f0dKT9m5BbY6ic2/s2S9Dvhx9wlODId8hS+O6SeR5UtM9Hv7uIse2IzfL r9RJ4ja7ThXCFQqjQgrl8Xk+v0mKCD2+gVlQ4lhy4O1A6j6/sg5AGMTN12qi8SZ933DJ nJbg== 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=aDLKHovI8bxO2d9YjJwk21iI6jYdGi7gzankaymnjFw=; b=O0IhjoA0goWHA4oQofncdxdYixXDUVxi2u7p161dQf0U7rzthZ8gVnoKSDEcthtaSs fpuBT1wxI0uHOAuCeYH3G3a88rZ2pWfQgG112HS3s+SLDCx4OsGq9scBOaUMzkrgUpJx 1AK5lJtcNwbR6DEihl1wcABaTvwvv0kAs14qymgLDZne4OM67GoPl/hWum+zPW/CCQ0Y gBhnICgijG6qMOVpNfQXoImrK4tnVWaV7yaqT5VvLZe1YzFBiSxGvBLDBMAqyVRxoBi8 g/1HUCxgyFlfHJY2BNNoIX5RNOqOW7I4ILvoQwCU/JBsvmi3kGaABR6ZfE2Ig5FxG/Qz QdeA== X-Gm-Message-State: AOAM532lVikDdgPbvpV1jbG32pLr0rxjdwR/SuzCaAvkfiaTk2hJMxwU 9MtucnMe7fU9YsTXc9UcoJTuyPYHV46xnqHa X-Received: by 2002:a05:6870:4341:b0:d3:1412:8ecb with SMTP id x1-20020a056870434100b000d314128ecbmr7282678oah.36.1648301175855; Sat, 26 Mar 2022 06:26:15 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 16/39] util/log: Use qemu_log_trylock/unlock in qemu_log Date: Sat, 26 Mar 2022 07:25:11 -0600 Message-Id: <20220326132534.543738-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2c (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2c; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2c.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, 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- util/log.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/util/log.c b/util/log.c index 6b7b358573..090bc3bc39 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_trylock(); 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 Sat Mar 26 13:25:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554378 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6447038mag; Sat, 26 Mar 2022 07:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR/E3V7aZvcD7qJfvJGox3t2Ak7rX44fV0MQMu7YI5jmBujVEW+9/w58Q6DPRe3kDP6eJm X-Received: by 2002:a05:620a:461e:b0:67e:c6fd:7c78 with SMTP id br30-20020a05620a461e00b0067ec6fd7c78mr10079763qkb.759.1648303398655; Sat, 26 Mar 2022 07:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303398; cv=none; d=google.com; s=arc-20160816; b=uDDnwYffDVNqq7dgE/s2OvnWM9vL48w7mSRJ4RxeSOmiNf50LyYb9AvGGmlAiehIwK GMKVtSJGuQx+YVZP+/nq25nuZbrAcseXEWxD9EO9M/byVuqbfXO/wffphnVASvsPheSc DQNTVvTJxCXQZqTMaXYrlh65fGo2TnMa+df1I4In54niSzVk0QoGm4Pru9kBwkW6uOqJ 1FiMj4PcqbNNH6CRszueRQgumFqBHXfG9rsA/KxQhuZ2Snw6rgRCKZvsHZt4iB6ACeVX Xp+CuwVAsgZmwfnvRZylYkq61OBWm0i2xLNy+mZdNhVwrzOr7cC0XbbYKc810XYwwBH4 EKGQ== 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=+xjD1qAJWzXfAAWXnNvtlNLURWCMMJVP8eMsZZN2BUQ=; b=YbGaY4yKVdTBjTEr0jkmgQsGdQQbJ3WAPnoE4ZPJ/Pn6XhBzr1iMgTarOpOesrZmd3 kNfHyvOegaEB5MId/3Ro3GY/YvDuDS6cF5A3rkRZH71I1bpkswxUP0jDQypk/B3Ug6Ey H8TsV1ZIUwRoPUvDTTYMw3Mst5mPo8bbgl4Zg/p9rWjUcfejJ8FR5+I017Bwgq9xvJ8E zzmTco4c/iLD78uEB9haroqwpQiZeR3md5IkeDJOwcmgkjM28PDlDwmAe59iiu2TH6bK GkYU83pph+kx6YhwaqLQDIHfj7FKVuFbFbV6bR/2NyKhqAUnKs78eK+3/HT5sF+WpK8+ LVwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qj0TLghB; 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 cl20-20020a05621404f400b00440e46a7bc0si2976716qvb.94.2022.03.26.07.03.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:03:18 -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=qj0TLghB; 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]:49002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY70g-0005eu-8p for patch@linaro.org; Sat, 26 Mar 2022 10:03:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qw-0007VW-Im for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:24 -0400 Received: from [2607:f8b0:4864:20::230] (port=33751 helo=mail-oi1-x230.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qt-0005VS-RX for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:22 -0400 Received: by mail-oi1-x230.google.com with SMTP id k10so11116612oia.0 for ; Sat, 26 Mar 2022 06:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+xjD1qAJWzXfAAWXnNvtlNLURWCMMJVP8eMsZZN2BUQ=; b=qj0TLghBoERWaS6lk9Z96whqdlYNurZOH9bzyGmBHP4YCaIKWRYlV5mVKzosuzBbdo rE3EdoX/PKoACqoi5j+KUlQfXAioQr0ulMntiaTBEe1K5Zba/CH0mmJ5ZWkCv2+YISmj JlDeB/EBV1mlHSS2N+kKrrvf+fyZaJyeoNuq+mwMr+qrSZgTIbMDQryUElBQFfV/Q3xv ibMeVEbZcsrITCwFz7pRkn2AS8fkpP4jon5xv9zCEBlTBoPV4vCTPmSJmbMAumixXRwk 5HPxXq865oq8Xbh5v5GblymRLHJ9SETw3/5HvTdZMDyD6a23AU5xYiijdt9jR0+tKCM4 qBZw== 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=+xjD1qAJWzXfAAWXnNvtlNLURWCMMJVP8eMsZZN2BUQ=; b=DHi5l84PKaE+vx8ac1bbFiKrvIUDN/TMF1qQrs1FoCUFNuFpiwu/72DM+TmzXg+etX kpDUgNXhxtWsMzWQ1eJoW4JJhana2LtYDxmdA30fSJyIq6b5zSUOPfcn01BvSPUfb+Ch y2+VQIFcVqaKvUlR0apWL9IOIRD5Sw0lIosLkfKd2xNviVDinIYDFZJbAcxQERuewDZV OVz/trBng5KhzSdVRRQdpgE//BVCWLWylzStZfq2hLHCyQ50kLRHzcDZEMJEBwhSeI6K Oj7tAzcbLOaAdt7sDDSazMPS49L58ncLv5Osd5g63544P7ipjXrtNLPLqZBGcG/HLPJu T8MA== X-Gm-Message-State: AOAM530Lw/NI+8CFE/4k6LcqvDoHpD7fgMiF6WbrC8VXqcYeS/I+Mf0P jCSpGth/bkaP1fBzfatxVvF+umSGoTLEj/KL X-Received: by 2002:a05:6808:164e:b0:2ef:8736:8eab with SMTP id az14-20020a056808164e00b002ef87368eabmr7735829oib.208.1648301177088; Sat, 26 Mar 2022 06:26:17 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 17/39] util/log: Drop return value from qemu_log Date: Sat, 26 Mar 2022 07:25:12 -0600 Message-Id: <20220326132534.543738-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::230 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::230; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x230.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 user of this feature, tcg_dump_ops, has been converted to use fprintf directly. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/qemu/log-for-trace.h | 2 +- util/log.c | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/include/qemu/log-for-trace.h b/include/qemu/log-for-trace.h index 5e41517227..d47c9cd446 100644 --- a/include/qemu/log-for-trace.h +++ b/include/qemu/log-for-trace.h @@ -30,6 +30,6 @@ static inline bool qemu_loglevel_mask(int mask) } /* main logging function */ -int G_GNUC_PRINTF(1, 2) qemu_log(const char *fmt, ...); +void G_GNUC_PRINTF(1, 2) qemu_log(const char *fmt, ...); #endif diff --git a/util/log.c b/util/log.c index 090bc3bc39..2bd4dfba1b 100644 --- a/util/log.c +++ b/util/log.c @@ -59,26 +59,17 @@ void qemu_log_unlock(FILE *fd) } } -/* Return the number of characters emitted. */ -int qemu_log(const char *fmt, ...) +void qemu_log(const char *fmt, ...) { FILE *f = qemu_log_trylock(); - int ret = 0; - if (f) { va_list ap; va_start(ap, fmt); - ret = vfprintf(f, fmt, ap); + vfprintf(f, fmt, ap); va_end(ap); qemu_log_unlock(f); - - /* Don't pass back error results. */ - if (ret < 0) { - ret = 0; - } } - return ret; } static void __attribute__((__constructor__)) qemu_logfile_init(void) From patchwork Sat Mar 26 13:25: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: 554371 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6440679mag; Sat, 26 Mar 2022 06:54:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0Z2wbOGTgcUARSKBykWcruT02xRp7811Kg6XLXqTtEPzMk3Yjenlt+WQldIeuz9ou540o X-Received: by 2002:a05:622a:1186:b0:2e1:b669:967 with SMTP id m6-20020a05622a118600b002e1b6690967mr13962388qtk.194.1648302896193; Sat, 26 Mar 2022 06:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302896; cv=none; d=google.com; s=arc-20160816; b=CBh8GYCojdv92GpKzyVhm+pwRpXoBheKgvI7rTIPFkuKw2HzpYu81pWH1V3SKH+oiy 8AezWDxYmwAyoI+CbeGyr4moqU6IOtaviWUnXUy81GoKvBJ/07WVrdsgg6G/feKZYko9 UVmxa7/Izi5EyfP882C/5RkpN/IM/ZdaKXTuEsNMd1ma4JyRAg1lBpiXIkf4JCK5wv6w wdFmTgVIw/8OtXIglPnWt4NKA24Hx54wC3sbW6kmHubpL9g8Rb8/fxiN7UCW6mF6vc5a xWiPAvuHGvkN18/o2fMrQ/rxwA3IUfjdzLYaoYkb1M11qAzMzRWosYqavMqixDgDolGS pdxA== 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=7UhpieTmtFS288gQ6ONEYE1O22i32fWGmp3rPIltdFw=; b=Uypcf3X8eK5JXST7tquvsiZfBGIOG1cHvNXhZKqkO4FGbQBQlOuCtLQQwPTT6Fn7Kx W2DTGt/fPdmHc6XQE9OhYqyEoY+xcVqofC5Mp85Pm2B/rXo1BTvtMDPxxrDzyA9EFIEZ s7cVrzzoLuUsmuWL9cym51t5LNr6j+GV3CnJgxxcbrW3pwSMn9eQSutlE4edMCPxHOI7 5yrI3IhVZfJLw0ilGxLCGshMHu+Wee6x1azr33/WrL5bDQ+1OxvW5KqcPfih2VqP678Z OzVpItChposfqip7LMbqSblJbNggCEpii2GEvim05V3dCk6zf2ziFSFO2MTprdgYuKjM 1uGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hQEOV8VF; 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 k11-20020ac8140b000000b002e1fbf3bf22si3131978qtj.275.2022.03.26.06.54.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:54:56 -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=hQEOV8VF; 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]:60312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6sZ-0002Jo-PF for patch@linaro.org; Sat, 26 Mar 2022 09:54:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qw-0007VQ-FG for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:24 -0400 Received: from [2001:4860:4864:20::2b] (port=41702 helo=mail-oa1-x2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qu-0005Ve-Hc for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:22 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-dd9d3e7901so10708454fac.8 for ; Sat, 26 Mar 2022 06:26:19 -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=7UhpieTmtFS288gQ6ONEYE1O22i32fWGmp3rPIltdFw=; b=hQEOV8VFb8U9KhfIMtbSVRjj4U8dQIg6g8SdNRWniBGSgJEbFp1ta/BicT2kRr6XKU QB7qn/cTuHEaOIdnfg/XifD1Ym44NxBCv7CRvUmBcsoK+4trJrlr048utnd54hU7GZOE rzNm/YrgNpYYYLnqwhRXbGiKlmv7kkoBTmrYaVGXn+nzjpN/mgBaSFE5VLg+14vqlxxB HvtvibTT82IGmSul/uxPxgBD8yYmy+IVdjazde6Ztp0vjQhFE5sBpTRWPVS6VN/aRh2A 2suEdU7cLxf22Mh3E3rLwK5WciIf0PvX/rmtYfnu+FMhw4wV48QufNaJ7DplQ/eSB3Lm ZDmw== 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=7UhpieTmtFS288gQ6ONEYE1O22i32fWGmp3rPIltdFw=; b=meTj54hABm2q7Ro7X9zme30V4YHszF73xVaytlVLL56lKqSS2Z8EYw54O63U5FFsUf FSNvVGgP8Db+jFay/nMsf/G+xEpkCXsLag0NDF2A+VrBRif63TrTmu8IjgFJqu36ceJS aDukJ75j/lkS5At6UUpZir61uYaSPJa2/Bl14d6OS+F48t9wf41B7BZILbG/XzAdrIsx uSQyani+IvhuuzNx88OoeX61EUgatGKye1LDN1Q5JWNUCxwMRA72T7RR/v51F8oFilvM wSy2HpOe6EsiHHReYhLV92TZ0E93CILtZz8e/bGj2Gdsbtxg1bbISMutV44LVv2LzYAf CiGA== X-Gm-Message-State: AOAM532zvIhLar7G4SoC4EfAiYO2lhZ1uC7jK9kn2sVo6p5tzLop0Ol8 XNodYXKys2ZresKjyXRKWmALZZgv0VH4z+IW X-Received: by 2002:a05:6870:204c:b0:de:10fe:ba3b with SMTP id l12-20020a056870204c00b000de10feba3bmr7190665oad.80.1648301178861; Sat, 26 Mar 2022 06:26:18 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 18/39] util/log: Mark qemu_log_trylock as G_GNUC_WARN_UNUSED_RESULT Date: Sat, 26 Mar 2022 07:25:13 -0600 Message-Id: <20220326132534.543738-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2b (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2b.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, 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 all uses have been updated, consider a missing test of the result of qemu_log_trylock a bug and Werror. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/qemu/log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 2d9455dc85..3a1f3a6020 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -67,7 +67,7 @@ static inline bool qemu_log_separate(void) /* Lock/unlock output. */ -FILE *qemu_log_trylock(void); +FILE *qemu_log_trylock(void) G_GNUC_WARN_UNUSED_RESULT; void qemu_log_unlock(FILE *fd); /* Logging functions: */ From patchwork Sat Mar 26 13:25: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: 554372 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6442419mag; Sat, 26 Mar 2022 06:57:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2poIZP8ov2qysgP36+fLaIgZRf9zWAVqmpxe2s1BjrfVAyYKVIN+zxdL4ylXyEdxTOh7S X-Received: by 2002:a37:6611:0:b0:67d:b78e:ea94 with SMTP id a17-20020a376611000000b0067db78eea94mr10318981qkc.122.1648303058278; Sat, 26 Mar 2022 06:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303058; cv=none; d=google.com; s=arc-20160816; b=DoYLRNLz8Gn1g/N1czvKzXpGjKinzT089xcrQd0z8y/38mcu4Utxce0E3zJS9IHur3 +VM+Lkl6/ZGeKSd5j0x823ncK5i/NWIT8ZR+lqaTe7Znh+GNNn5ffwfq0oGozMKDrpdy UU3PUZ/05DNlrKd8RDHI6iP2H1v6gDuX/iXXJ38bfAAegLp5CijHjTP8sfKMa2pkGGYR vww9DVg6R7WnpsXCrC1UPAICtFo4e0iZW7YtpcF011h4rfDJ6dRMhmzQR3dNgCBtLGB5 iM83TCHz0RpkIh8Qm50+MFl0IXmKvgkPEy3OJ4H3Aa6nQjO6R2Ve/coTVn4wOt4xv89Q uWrg== 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=HCB05Inte9LF7rNCvDwYZMk3/K4+jeUff4g5SjwTBWk=; b=v39Cl/0qEy19vBjfPLzGjGJJeBALpnLAXH9HcX0t6+gwJmYqXOYbxuXrcRKbYnpBz8 ua3JT+jJbpFHToifL4EWRw2twq/wxlAMKrTnjWZzx0ONb4e5LaHF+be6cqhx7z06aAuh pLh1vyIyz1ckle14a9sALRxGJq4F6HlnMDnW2Z709lDMQPv+U0k0Gtz23IdfCGpyfZ8s 8eq/Sp0NUPS2nGfj8/IK9NbBRu0Kixa87Re5c1JWYLqY1sKvb8fmaH6x8RxCtnHFDeUG nvVPgPr3Bu+vgjRGE4vWseWy9eWBkQeurIOXidzK2yyZOJ67vPxbdrrkXxQv+X6t/r2P OPgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="h/d1M3QX"; 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 a13-20020a05622a02cd00b002e1fbf3be9bsi3891971qtx.140.2022.03.26.06.57.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:57:38 -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="h/d1M3QX"; 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]:36790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6vB-0005aY-SB for patch@linaro.org; Sat, 26 Mar 2022 09:57:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qx-0007Va-Lc for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:24 -0400 Received: from [2001:4860:4864:20::2a] (port=43741 helo=mail-oa1-x2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qv-0005Vm-P4 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:23 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-de2cb87f6aso10702807fac.10 for ; Sat, 26 Mar 2022 06:26:21 -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=HCB05Inte9LF7rNCvDwYZMk3/K4+jeUff4g5SjwTBWk=; b=h/d1M3QX7NQyvcr60/4rpCWpZhAuc4mXqkIgy9Vxh9y7UP12aBI6sx9B6Edde0gJlU 2ABB8VVdxQD85FLUcg57poXkC8fdCIYAheQnXVzvysjJnGmFbNVJTvzoSm251HwDTolP uTOfIz66vjGJ7+ZJwDxVQ+Dd/K3ru18c7OG7s7SyZ6fgPRx0+JuL73UGWDtIMHVCb5cc WN27DI+EvLQOPBDIk1juOctUTlGreK0jYw7M7S/AjH6sQCXr0GoI/LpEd50CIVB/kag8 GqEpIOLHVrfEl/YE6qRcdriO8Q0+zJHQWBCtqxX5wtjL4PQg9JcDpzf3cgKhEHd3UCr/ tYVQ== 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=HCB05Inte9LF7rNCvDwYZMk3/K4+jeUff4g5SjwTBWk=; b=ptaA1IsEPyvv1DnJugR3SwFpv5L7A0bpAHhmrtAgYwOpb34+rEViA7EFy5xuTDsMl5 GPMOfumi9PrMs62x47XBsf6TV/pSiEs3gyWXmeNim/YkH1XRK4Xx+E87Y1k9vZpiBhNU LbrmEyBKnGNOo2e+csJW4Jna4iShQXBW5f8gIhkplqJb0AyCZ5y8+te+oYlrFeNbqeW/ hTmrnP2/o7EdhWdPvFVkkO95M0WXsyAwvRKTCOckEL1N3iJPigVl/y+3MyMV4vXS06CB SAf4MwKcK52gJ+G3Ou5jUegLNt89rUdlATzP8ajbT9NXRP4EBz7nv3o6CI0PewabF1PA qzuA== X-Gm-Message-State: AOAM5303pKSu9PECDd/iz2SwdGcbXaRSRLEq1reDz4QUnWGX6y++FVfo YwRF+7WqXGVZrGl4NTKwxafo0HpaX6P7jES0 X-Received: by 2002:a05:6870:a1a0:b0:dd:e471:8baf with SMTP id a32-20020a056870a1a000b000dde4718bafmr11195479oaf.40.1648301180369; Sat, 26 Mar 2022 06:26:20 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/39] util/log: Remove qemu_log_flush Date: Sat, 26 Mar 2022 07:25:14 -0600 Message-Id: <20220326132534.543738-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2a (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2a; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2a.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, 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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Alex Bennée --- 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 3a1f3a6020..75973111bb 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 4812619f00..6080ea997a 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 3340bb7538..bfa4db9cd8 100644 --- a/cpu.c +++ b/cpu.c @@ -406,7 +406,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 23d634af6f..e0f76d3eb3 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -261,7 +261,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 0423c61158..037152f063 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 a6388563c3..c1a1ad0563 100644 --- a/net/can/can_socketcan.c +++ b/net/can/can_socketcan.c @@ -89,7 +89,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 25e987d881..124d8be1a0 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 2bd4dfba1b..cab0642a7f 100644 --- a/util/log.c +++ b/util/log.c @@ -54,6 +54,7 @@ FILE *qemu_log_trylock(void) void qemu_log_unlock(FILE *fd) { if (fd) { + fflush(fd); qemu_funlockfile(fd); rcu_read_unlock(); } @@ -269,19 +270,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 Sat Mar 26 13:25: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: 554369 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6439434mag; Sat, 26 Mar 2022 06:53:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwT7mg8DG8h0X7o9M+nOaaRG3+tMQ8lnnw2Tdk/2c9z+Dkj6SMw8EIQ2vUywS54jB/ShV6 X-Received: by 2002:ac8:45d2:0:b0:2e2:70b:f887 with SMTP id e18-20020ac845d2000000b002e2070bf887mr13852149qto.272.1648302785476; Sat, 26 Mar 2022 06:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302785; cv=none; d=google.com; s=arc-20160816; b=H88ws+PxYI6a+jHhB4CTpiQS48gzK6n1KLlDo86pJUJWZxd4HB0qeQQ5W5TmuvugyS fiwsMLNQMufeg2x9tib931+eMVDTtQOWTMzDTreQ1py0e2s7i1K1tJrA0AZ89pAMPjLV eFHvCjN/B1iovMJTGtrISf6FbljE3X/lATZkvmqrBM/3qrmWtub46xF04In48LRDEklj Mhuchc5ppgzAe+MOQmnjRLOZdx3C/5iedVxIyG+GZvQ403VEMA5LcaJXfyvSz6NEtoL+ DiVD4qKOa07NZfI3bWavPDY9+wXLHyaO5Wi39APawEVUH9UVLj/SDWeKrQ7Z9PBgKvxJ QlPA== 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=i47bs5CBOE5da9L+yyKjt/bVgLDqpLar0tLDMlVsDtQ=; b=SSryy7A7cSMvmKLROMaUWu+2JQcOvReWJyxLBF+4o4XSCIAH2Ewndm6Vn4l2A7+D5i dUdOhdn4kz1vnIgwkLw6sq4pU0cP1FsPcNEgPUnS9z62GfYL05REhgVRKWH6CGNPLXXG QsJl/2IgvRK9ad0lqE820PUoUpzJq2X3lmJyy6sFBN13mPNqUCbEs2PtDuBjIicUto+f 9Hv27FnCBvv8g+bZeFiBl9xmk0mlQRZrSpY7RArpp5kCs/0HMbEerWphkc4+09EoZjTd 7DI1U8U4JXDyt0EGxh3iyQW3sgpmkeGBrfKjQKEzahoFi0xk5nF2vVFusO/r92kGsTLX KrBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NAu8kTcb; 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 g1-20020ac84b61000000b002e20db39c9bsi2756580qts.157.2022.03.26.06.53.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:53:05 -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=NAu8kTcb; 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]:56748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6qm-0008B7-Rg for patch@linaro.org; Sat, 26 Mar 2022 09:53:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qy-0007XU-GO for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:24 -0400 Received: from [2001:4860:4864:20::2e] (port=43745 helo=mail-oa1-x2e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qx-0005W3-5H for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:24 -0400 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-de2cb87f6aso10702848fac.10 for ; Sat, 26 Mar 2022 06:26:22 -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=i47bs5CBOE5da9L+yyKjt/bVgLDqpLar0tLDMlVsDtQ=; b=NAu8kTcbn09tztmTi28UI3LWvUPYTfZq37ZUq9q4LPv+l0pVnQ/KTxgivz/XmGxCty UaqslFrhY4pkVIWt1AVMRoBZljqKVi3RHVatcI0h63hxZPgbY76hjGXA2Omhk+OHmUo/ jx8B7u5ym1t9T/FVK23drvT2OJhviOv6qdKU61jytJu7yPg8rLR8PdUH08Rysruabc0V RV3j6wE00a7E8ttpAf9quEjgKvlaxvCVOm2QEv9sw/HPmAyP/SZdYOnQFsD/mS69ZlJs o/rDa2N8/i+r7xTnIF8AgCYeKdKoDiU0I9yI49sBgvHQ5vEOUmiVg3olhIalCg2ERhe+ W5qQ== 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=i47bs5CBOE5da9L+yyKjt/bVgLDqpLar0tLDMlVsDtQ=; b=DIlttt93rtG59rtg8jD1VOdQjMkVKg46ld/1FXEbIKVj9mc/G0rITZh+lWoIJIhywR ZZA8sPYjqxT4ZU8F7xdrFAoTjwGGiBO/Bbw3k83ieV4ldT/ImpwD4iUVvMUtSefFBj67 hs0T7i2ykO4wzbD8sZCTsSGV4BOFZjIv8vSp4zhqSp7BhRB6k9SjEifkaxv8WTVeY2jL jX64papRzLkmcjASCzdzGzcnketjx/Ij73HdoxPavDM27OQfPnaRGQVKXO/1SxIDtTQK hENpaJfTlOwZLe8gIs0yNhX8NOzIr9T4mGFt3Q0eVM08bbeqEvkimYMmoukL6/fxrkxx lSLQ== X-Gm-Message-State: AOAM532nB2/dRmyum+tjRZMzSMPaEod2lKwxV/ZgUgibLzgMew44dXTm Qk3BA7VCjU/Xtg25Fl9YU+8ZQGKPUd/vDl83 X-Received: by 2002:a05:6871:5c8:b0:de:75a7:1a45 with SMTP id v8-20020a05687105c800b000de75a71a45mr6907895oan.181.1648301181841; Sat, 26 Mar 2022 06:26:21 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 20/39] util/log: Drop call to setvbuf Date: Sat, 26 Mar 2022 07:25:15 -0600 Message-Id: <20220326132534.543738-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2e (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2e; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2e.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, 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 Reviewed-by: Alex Bennée --- util/log.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/util/log.c b/util/log.c index cab0642a7f..caa38e707b 100644 --- a/util/log.c +++ b/util/log.c @@ -136,12 +136,6 @@ bool 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 Sat Mar 26 13:25:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554382 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6450970mag; Sat, 26 Mar 2022 07:07:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrILAWeK6wlyD6x9gzLM/9945GMe8mdGu37Swyrn0EOMZnmJ+dE3xHR1CAMYY2wapUkj/a X-Received: by 2002:a05:6214:518b:b0:441:833:736c with SMTP id kl11-20020a056214518b00b004410833736cmr13284836qvb.95.1648303663776; Sat, 26 Mar 2022 07:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303663; cv=none; d=google.com; s=arc-20160816; b=uvTIUJuW8uakYBpCRZNrqfe/IKT+Cgx6dJ1piG8uS2StFx+OR322gg5FWGTQBCzdl8 i8x49RClFmz4qYEVyGXFSrY7a0u0s72J5rTn2ABVHbRItn0WqiSPPfigkzHiArsc0RNB OjC+1ilgdZmbipscLeBvIrYL7vqX3ulscKronYlr7TAABGIe+cN2Yaqb5leqjsAW2kRx xkd0DtI/ZLQbZw1oHU5SbAjVv+6DWoV3L+qbbDfiyEOTAgDaUjfqLAM+HjChdrm28G1t jd+tpm/RkUK14STtvdzbpwucakPzRlQ9N4jZvN3iqK340viNcHWr8uFNGY8UROCxhv6i JjFw== 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=m34esa3hgxLOFhKAAREVlVqf9cUjZXCYhsy9QojcN0M=; b=exss8hDhi6tCwfoMqPxh4dW2ONnjQI+2+MjLYThRgGgbwqZyUBmfC+mvFDslxXb+bZ 1UuVwmjxEf99biDdBRcrSbxDLY3HtEZXIh42jA16FX3lXsFz0qfJJZZIznv2p3VTuWeT 8JdvhlTbfahfhhkVx6dAIB+uSYtbybTbgYij2COb/myW33YfHhU0N6f6CubHldlXmGLn xEkNrNbb86QqHGwgctNt4TDIz0X+flyzUPWbv5kmKUrWmyt6GBbtUVl1QK0y2tvsczjw WF/VbQh94nyjIEiWD25FfH1ConvV43KyEQxaGPUJIqAMeO8XGmBeqE2c2rW7JP7GeWk0 8O8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="TRHgZ/oJ"; 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 cb6-20020ad45626000000b00440e46a7bc5si2991499qvb.99.2022.03.26.07.07.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:07: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="TRHgZ/oJ"; 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]:33946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY74x-0006KA-DL for patch@linaro.org; Sat, 26 Mar 2022 10:07:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Qz-0007Zl-M9 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:29 -0400 Received: from [2607:f8b0:4864:20::22e] (port=45694 helo=mail-oi1-x22e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6Qy-0005WR-4X for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:25 -0400 Received: by mail-oi1-x22e.google.com with SMTP id 12so11067460oix.12 for ; Sat, 26 Mar 2022 06:26:23 -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=m34esa3hgxLOFhKAAREVlVqf9cUjZXCYhsy9QojcN0M=; b=TRHgZ/oJCFEh5u52Hgg3SbEKowSq0DISpl9ug9e7+JsZm9zSjgNeMlt4eN78uAlh92 JWDVtXTHdxWsgxO3fpWpU9qZnB6gMFi8a+/Qp87JklqG9ovwqAYRqSYEN8n/H/g3wjGV vdSXA5Fvbg3G8xxadKiZNcdkbY7vaNJqhZ/9y9+XOcSEyTEMlnGtHx9ORRSBIcEaZCJ/ PwKf3/ux0uSWhijgPQ0HXHv/B2r700gnucYfCjiuUWP+0XvU1CoMHAhJW0p1Se259IUR Jl4XihDi0rGOToH8lzd2LiN7KPW/xm//qq2aI0DV0Oe5gIyp+rowZwMUxTiUOm80Cnys c2wg== 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=m34esa3hgxLOFhKAAREVlVqf9cUjZXCYhsy9QojcN0M=; b=E3vDnzaMj48gnaMDOBOv8RNpmuOyDcdsk55WXq0Lfgu+o37UmpF50DR3FHFZ1RF2+h YaXvin1wufN2Y8TjTTexzAP8KKxzMqrjeBXeVZ19c3qfsd2WvwcLtS0/5r5CXyRpB65E TJlwLOTwtDGSO6dZ47dWLp3hnFw63tPpHTz+aU2aiKvDV3CzjJ50FWe/n3TtFuyOwU8I /KhNbmyWtMuACUBs2yhEluWJ+EjR3s7IJgcp0HauDoBlOo3mA7PIljm86Yke4sDm83e9 fx35DdPm3xef/b8de9HYrOOzWcZqz3K3fIpFe/hoKQ9d/tPZ38DT6IAFMYhGc9AMxhkG 0GSQ== X-Gm-Message-State: AOAM530wM6vnktPvmfG15npHd6lNTP6NgPu6PcbjQC81DyFyZzdvwBxx JwTC5tYnugu94yyrzWmbhMfTrrKYSY9e5Aqf X-Received: by 2002:aca:2b0b:0:b0:2da:3ed3:f862 with SMTP id i11-20020aca2b0b000000b002da3ed3f862mr12544027oik.65.1648301183062; Sat, 26 Mar 2022 06:26:23 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 21/39] bsd-user: Expand log_page_dump inline Date: Sat, 26 Mar 2022 07:25:16 -0600 Message-Id: <20220326132534.543738-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22e.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_trylock/unlock to the caller and use fprintf. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- bsd-user/main.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0c8aa1ae90..ed26fc5acb 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -503,20 +503,29 @@ 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_trylock(); + 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); + 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); + + qemu_log_unlock(f); + } } /* build Task State */ From patchwork Sat Mar 26 13:25:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554374 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6442856mag; Sat, 26 Mar 2022 06:58:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrHflAQjtCf9beECCSPaOvqV2VJVJrpmwtQXlsLErPOXRBD/2Re0EtDvh/n08HHQxEpASG X-Received: by 2002:ac8:5ac3:0:b0:2e1:e117:b2ed with SMTP id d3-20020ac85ac3000000b002e1e117b2edmr13836819qtd.541.1648303104831; Sat, 26 Mar 2022 06:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303104; cv=none; d=google.com; s=arc-20160816; b=iVBlx05k1dkwDPGUzg8kDBYwaIhu9qZOTND92o0IXryuaDpz69UuTmfKMk45lzPRfB Ud/kofnu86lJNKQ3Jc0B/sruh4nayZQtiqbm31zea+EhSsgUV7MaUycJ0ZAW2k22QrXZ 6fYM5ndWs3s8AS8sIo6hvTJ3DYxIVIrwKDtTl5o3TJcw/ffXJIjn1Ds+bWDz/jsGlQIJ wEGYFBTyFdEzkSE63n1P8jJb7Da9QscjldTybuLo4hIoX6F/oVGHRHX8A4k++ZvmuqgA 5QNM98xmKQsB6v8LcwXzRsNDNHK0GkUZKMlneTcK3F63TzmLur5f4TCobTgfS6ftsV4H dsig== 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=UBUdVtyUYy7eWABhSXggubY5JYSwV4Dsg0nD3y0Kids=; b=D7jTGnOOGKCqWYToxQUEjWVP0wcp3b/nnZaOLr9ih+MF2RSW4CJCqTXIxs7ns/Mq1y i3ABMW4x8gZkO44Ks12hHmoTEobEH9DxufkryVBeLiJhGG1AZylgqyAR6/ghA0xxeBlU EbXi9enNpZrJ0iIhVjpTM+Sr+b0HG6h/rtg5zb8mXzSsrOMSm1IUsPT5bb46cSHxpgKW ja/l/SqfD5A2tmrYxeGRT9TFrwUAS+Y1ILlq5JmnnHgwBTsWm/EjyJVejvuNVtKGewOF mH9dhy8faAlktF0m7x/QN/kSW94RoFQ0YKt0weku+4o07kL5eQOQ08to/RsL5mvzbGro qWAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AvpCW/zW"; 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 c11-20020a05622a024b00b002e2350f1b07si3687284qtx.418.2022.03.26.06.58.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:58:24 -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="AvpCW/zW"; 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]:39854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6vw-0007o1-Ch for patch@linaro.org; Sat, 26 Mar 2022 09:58:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6R3-0007Zq-Bc for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:30 -0400 Received: from [2001:4860:4864:20::29] (port=36754 helo=mail-oa1-x29.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6R1-0005X0-DN for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:29 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-dda559a410so10744415fac.3 for ; Sat, 26 Mar 2022 06:26:25 -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=UBUdVtyUYy7eWABhSXggubY5JYSwV4Dsg0nD3y0Kids=; b=AvpCW/zWvmQyC8hmYLgUDJUqOXSmzDau5tDMvG8/dWPZtQ713EThwvN8xebcNxGcsn q9LLQ+Pvs+Fvom6xbZcVb4KVlkaIhZp96eyCZAcuy2RRLj4YuHLXJGuii/uwc4cqCjPu D6weYNq19yPZ1s0h2IJ5yIj93JXkaG7DkusNIZfLlMo3XewSOxZgJpPJy1CW8qZxASAm ePd/2Zi2c3Y5LGVJZkjRIMz5P3ubrIiCoZ3vaDa4OXkJPcC8g0GKCoqALD6kC16B15ao nJ1G0LyX5pQVmfcWY4yHn+RoJyWLXGRtC26Z4908nXPfMstaZU1ksdPiuBUE/eqREkUq 8KGw== 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=UBUdVtyUYy7eWABhSXggubY5JYSwV4Dsg0nD3y0Kids=; b=Qru9pu20KiqP4z8fjTHS6UjPH6WwHIdV8ffO4Jn2uVl8Pfc4yCBKeJLXCPjq0JTZMT o6o5MjiO1QaZh9KmACshMOdHz7M8dYoCvzIbgtxZBbP31Rbr7Ao/c8MWUjut11/V9yST u8vqBIAL754ildNS1V87Yl09TjprFuzpzTR317AKPxuzEBwy+IrGAF2wI1JjzraIrxop Wg+77N3R9kJnLRM/1sNPCUnEC3BlFY2Olal+V93L6m3LNyS0L+j0mVJXWKw08B6xr4E1 6icMcsxiWV2BGokjsEOr4JXAhHbVjbxUnaBwNC5/272SdPerwt1XKG29o0N6E96lf/B/ /wKQ== X-Gm-Message-State: AOAM530UIneXK217aZJARJjvHGbGJaO8LB0+ZjtTFXakfki+jHFTJ9xH AKFtTcfREsGETGDutBlLznY2uSIVTdj5K0bX X-Received: by 2002:a05:6870:14d6:b0:dd:9907:2c4c with SMTP id l22-20020a05687014d600b000dd99072c4cmr7201371oab.70.1648301184793; Sat, 26 Mar 2022 06:26:24 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 22/39] linux-user: Expand log_page_dump inline Date: Sat, 26 Mar 2022 07:25:17 -0600 Message-Id: <20220326132534.543738-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::29 (failed) Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x29.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, 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 Reviewed-by: Alex Bennée --- 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 06ab9841ee..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_trylock(); - 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..d263b2a669 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_trylock(); + 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..bbb2c2e178 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_trylock(); + 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 Sat Mar 26 13:25:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554379 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6448062mag; Sat, 26 Mar 2022 07:04:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0dJ9+8bTaSkix6vGtD6dp5wdiCJQn7B16Cl5or+rxZr9owgvODSVvG4zfq4JVfmGn+rpc X-Received: by 2002:a0c:fe47:0:b0:42d:f798:3da5 with SMTP id u7-20020a0cfe47000000b0042df7983da5mr13786655qvs.77.1648303465514; Sat, 26 Mar 2022 07:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303465; cv=none; d=google.com; s=arc-20160816; b=TJSAaMs1c/YK/1X2bf/jNaFCfqMLZwiUt7njeZqM1NQV/+ZiMZLcVWm3ssZw7zguI8 G8pEBfPJZz5QhDeNOJu/NPl8B2HVHG1ppILDiAaM9hLnnpfo8Yh1MxFtTMPXTmnbMgZg 16DytgdpPTd0cv0g6eRA2GG8lNzpemTV99xX2SUtra4ZUUa8LA7i0UnycXZsISDoTCSt pGRbfDBZXFRBJzIJPh6yGePx17A3tCzStkbx+WZaoYEDiOSPF1POOuWvhgEiXjcMRDhW GENNEckvvruJhBaEhXKgpMQ4YAzT89PEUN5rMjvbV/MO3go6g6UkVaPcMBviCfpuIZ6o 5T4g== 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=Xvpxj4nK9wpX7Z4tgHMyHFYd/y+hd6ZVPNnNHANWilg=; b=GEAndLGeSdxwGiDgOVj2w9RUNrEWkEaHg9dh5h6o3NpvdWF1qXrKQ2DySuQlaglOk3 23A7rKwWygWp9MGgzxqyJxBWlTlqjTC+VN4ZtJLq4IggwTkZGVVGA2ExPkSG5KhE53Om aa6FdvuS0buwk1wHvgxmNywM/Z4tF+b/NizpMRa0LC7qrHJ2V++vK/U3HBqNjgyjZzYP FRqNAFMsAAQ4VvcyUqwi2clc3zOSjbgNJnyuxNPEdHwhepBk9ePOI3mkyISccAEQOqD+ hRsxcM66pdnje2RmpKVw1fZghCDV3aoLhPjGzpvVOZcmkVcbn7yvTHSExfN2lqz0fpqq W33g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TgEJo57i; 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 98-20020a0c816b000000b00440e46a7d8dsi3838761qvc.555.2022.03.26.07.04.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:04: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=TgEJo57i; 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]:53642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY71l-0000Sn-3E for patch@linaro.org; Sat, 26 Mar 2022 10:04:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6R3-0007Zp-9B for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:30 -0400 Received: from [2607:f8b0:4864:20::234] (port=34583 helo=mail-oi1-x234.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6R1-0005X8-Og for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:29 -0400 Received: by mail-oi1-x234.google.com with SMTP id v75so11116308oie.1 for ; Sat, 26 Mar 2022 06:26:26 -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=Xvpxj4nK9wpX7Z4tgHMyHFYd/y+hd6ZVPNnNHANWilg=; b=TgEJo57iboti6CrVqfODuxx/cJ8iwhTI/hF+IObiEq38zwUhFdpf4IxOdTOIolQ4Ry 2MTO8/582lZkrfar8tv5ZYu8AtBQOUKrJjIFLnbWVvAIm3TGtIM15NhA9l2AC5ld2EI6 qmvPu16X/FzHK2xibb734uIJPPfNMftXmp7RB+V4zZdjyCqlg86m8i8aYzW8YugLr22Q nAzaPy67cZxD7veWqbioSTiF7Ex1ENdSJx29GQmt3sbFvbfm8bDdBCn0uPGl6jSbgA9r kV8MSbxsguMYsVWUULhPblC1Gc5mzjCcicZMtPOZboEhBLk+P4H9p6loDP9xqEAJPvq6 U+Og== 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=Xvpxj4nK9wpX7Z4tgHMyHFYd/y+hd6ZVPNnNHANWilg=; b=ntsfXHxiyevs9KMeOlohCGtkw6XdJNa0nmIqDiOFNd6v8mx+9QkiIaqB7IF9ey2hPG qyEyllt/DhLpU0RGdB9C7tIdgylA97wLhxT4SwypGqNrJToO2ywj4XsAEDKwytWJUL9W /r9mYZKNwHe7asXL5pS4VVhbTbZFmxU5dCCfFtxYDLn8X6D58UyyAzTFycd/YHIRzpZ3 faVNNmL1sSNh9cC06XBbxi1UZ9nM7crmratQqIrXiVm0nXmPB9aURqkbD0VXRXj9801N +zAokjDVY1Uk/SVMv4mEMha6GyKTjl93JQfAUqvWYDBWQaVA2iwkqRDZnzfA9ere+hnu tLuQ== X-Gm-Message-State: AOAM532YWVN2DjMVQPB8iSXjZYBxngp2ewuIZW1FTNB0CYAni2OeIZIU vIOMumAOi0k8ULrKbDyVDideGpPgcsv99eSI X-Received: by 2002:aca:4b88:0:b0:2d9:f709:2c07 with SMTP id y130-20020aca4b88000000b002d9f7092c07mr7339543oia.212.1648301186044; Sat, 26 Mar 2022 06:26:26 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 23/39] tests/unit: Do not reference QemuLogFile directly Date: Sat, 26 Mar 2022 07:25:18 -0600 Message-Id: <20220326132534.543738-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::234 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.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 Reviewed-by: Alex Bennée --- tests/unit/test-logging.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index 54d7e8e33b..dcb8ac70df 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -110,12 +110,10 @@ static void test_parse_path(gconstpointer data) 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_trylock(); + 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_trylock(); + 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 Sat Mar 26 13:25: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: 554385 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6452589mag; Sat, 26 Mar 2022 07:09:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZLe3fvKyC2ek3vCrIJQNt9X0krJunPUKrGpolaY7LACKOEdpQK5B/BX3GrEUCvTHongBM X-Received: by 2002:a05:622a:107:b0:2e1:d655:cc4c with SMTP id u7-20020a05622a010700b002e1d655cc4cmr14150256qtw.669.1648303774970; Sat, 26 Mar 2022 07:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303774; cv=none; d=google.com; s=arc-20160816; b=lfbj3fetsI8CjqHvL1HqkgryTpcXZ/EDeQ/dzqwmbEPBd6HZtAjGoEjhJjFg7aTgnb +c/k1I4dDuW0AqN8f1nykKFi84UIw97mJNaRl6K0wbhJdqxBaveIa1qMbQasY8eQQZsQ QRyWu66H+U0axLl2ZPEiW6EhiknxG1jEeGbLO23xYIHFas0PlyTW044dJw/3ItEYL2mc 5wRG2yGcHIpOixo05SJyD6oakXOoAPXXzVsCq6oZUnkS0MsHlpBQnsCN2vYCaFIfCm+Y Kdyj23aYcqGo5NQAFhrTUisiHtwn6Gp5oSstoNgL26Cbwy/Zj+LO1K3UQhXw3MGrGkSM J+jA== 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=8o87i5bNiHOl6x8JfiL+JMb4mpGfXlTZfUHEJQ6T1J8=; b=u35n/DvlYlHk4Rf6xP4OqBTGoMEHAuMJRvZRCRVdwZfYkOTLl/1fe1UDQ/7+4EhWNQ X7snbqtv0E5XMDR8l88hhtBAu8hoQeH/U7A4F+c67+0A5+D+E7I8NimZLFmSsHGAUHsy 6YtFEmau3+EF13y4oyuRhU7K8xKTDoMOIFehVbTYEBjZ+BdqfSTaBK0/a9Rswku125+o 7AVWiz/3zZjGNOZLWJ5GM2G1amsg5BeekRe34RuW0u1WTf61Js9tj60/DcFnYI1RqtMR ox9SyCM3Gtr3p2VTCegW+zIryJ9vQs5cH1FtXdZ8agqUo+rnDRZ3hBl7A35Qyqv9UlzC briw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GMUfV9LI; 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 m12-20020ac866cc000000b002e2028060e1si2903722qtp.385.2022.03.26.07.09.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:09: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=GMUfV9LI; 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]:40878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY76k-0002T4-HK for patch@linaro.org; Sat, 26 Mar 2022 10:09:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6R4-0007bE-Gj for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:30 -0400 Received: from [2001:4860:4864:20::2b] (port=46989 helo=mail-oa1-x2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6R2-0005XD-9k for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:30 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-d39f741ba0so10714425fac.13 for ; Sat, 26 Mar 2022 06:26:27 -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=8o87i5bNiHOl6x8JfiL+JMb4mpGfXlTZfUHEJQ6T1J8=; b=GMUfV9LIn5X04ckDRGKfffTTG6MFcPgZyf+hGkNjiO0WxgRNxFKRW4DZk5nlB6kPT+ IIuuoX6G4qK3IWr3fjdC5sq7juDqtqMeA/IXQmGx3A2mK1cC/PenWADP9PHkkp7zGPYu 8YvADF64DuSAIvJ7GErcXH08uzPtvsM31k17EPwhhB5WSX6Yl0ydFkG3cFb5twsTBW54 h9dQWERhrzfb4AYlSkjxjb+eq3N4oHf5VrqbL3BYX3eqlAyqvh9GQ+AgUje1I5rKNidk ENhTgLtdMdPsBScubniO35xW8hBJ/T+1O34tZHfvh113x/d1F8kya2A3dBOJrpG6fcxi Kpnw== 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=8o87i5bNiHOl6x8JfiL+JMb4mpGfXlTZfUHEJQ6T1J8=; b=2FHoNAZgW+tRk93Z5opZfRGiGlYkI8ApGY6QRjDkUsFYlODsBEBH/1s3kTmriLyzTP rVFA0d9wR0Y15CMC94NSra4Yr0cRWD5L0MZE9CmGYvQxKNpqPj8wE29dN9tV0yDs+2ZO TI0wCxsCCnVgcMfC2HchRR9fzN1FHTlPK/S7yPUAnJoAwcwzkxIlh9x8ruWEqXBkdWhB oI80ux0V6a0//Kd19vMW79gn+tbKyBZ8lKiKSdEb4hWojowF6O4RO3U4M3Y3bjLedrlc XlO9uPRhkUu+hb+e7wB9/xbkBLjs6SRS5O0iBL5hLRXb2gDa9EnL7JxiabQsbo8/ZW1w 7GEg== X-Gm-Message-State: AOAM5301DrSFcVNz4DTpDk9kU2HgIp+lUJ7l+saD3/yLC9i23IO9v4ML 5TipLQ+p+g8VaYT7znwQzb4wVs+w4dhWYk6h X-Received: by 2002:a05:6870:582:b0:d7:5fed:b7b1 with SMTP id m2-20020a056870058200b000d75fedb7b1mr7326769oap.78.1648301187346; Sat, 26 Mar 2022 06:26:27 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 24/39] include/exec/log: Do not reference QemuLogFile directly Date: Sat, 26 Mar 2022 07:25:19 -0600 Message-Id: <20220326132534.543738-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2b (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2b.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, 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_trylock/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..4a7375a45f 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_trylock(); + if (f) { + cpu_dump_state(cpu, f, flags); + qemu_log_unlock(f); } } From patchwork Sat Mar 26 13:25:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554377 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6446896mag; Sat, 26 Mar 2022 07:03:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa3T0QfIFPee57OsKI12igWEVL+qdKk97TNTZYkj+qnkZsm11oZah7QdSwJo1tPB068Ikg X-Received: by 2002:a05:620a:4711:b0:67e:6c24:2b2b with SMTP id bs17-20020a05620a471100b0067e6c242b2bmr10369467qkb.588.1648303389728; Sat, 26 Mar 2022 07:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303389; cv=none; d=google.com; s=arc-20160816; b=p+FBh+gvocrcEX1mQg+haiXMDujkME3kFXEmCgiYpxyyOS/RgB6dzAMzu2V/WvMWb8 Hcb0m+m7+hhR3+OxtEpUUpK295OBLnQloIl2VpMq3UrOhChjclIrHcJ+TEsDNIksoWmj ofRGKZRYvvVVWWq4pl3cFAIVjdVo+7dhDWRRm0L+wloVIOZul6540oUMKLf9GF/vWbYG MNyfuo29EDh/EdY8iSjI/LMkGkVTGvMRSmAZmnrk3K974JGHlulVOKje4yTQmv4IKc4U NWvVe9U4XXMbcfvjTmqw97QnrOVLl+cFbjbm9AOBjkgaR1v0th3bJpVAaJIJz3uOinY2 Tlgw== 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=kCBAoENAiY9tRs3tDbNuJNsMArF3Wl4ZlwA9j6bO048=; b=i04v9TWye7cp4QNpdJrmCdn4mVG2J4HeesZd/R7xFJE7wQYMtUbegS0hkQ9KNVAnyb MyKsq3JlLjOueg31cWW1doO4ovYCAXPrcd4qROxUL+9OUsTZgzX+SsBCZPc0khWEMgIm 6pZlcsdvVUHaMdhRnUreRSa4wtdxPhupyb23O1QcCMCgNRn0i53e9HbEQzwuIjluAFHb mLuoJ+y38iDLfJzl0hbvW7avvhY9kE9/DoQMQt34kLXixNT1Z7A3kwPneVzSXVwDUUW5 BT3Xl6enhtUm+mr9NyRhjjFxFuApVZ1U9KAyshfINjE6zXAao/x9LFBwJ24OE9AZRZsO cfWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qi3kLmiW; 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 d12-20020ac8544c000000b002e1fbf3bedbsi2742275qtq.204.2022.03.26.07.03.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:03:09 -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=Qi3kLmiW; 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]:48270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY70X-000591-5w for patch@linaro.org; Sat, 26 Mar 2022 10:03:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6R5-0007cH-TR for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:34 -0400 Received: from [2607:f8b0:4864:20::229] (port=41731 helo=mail-oi1-x229.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6R3-0005XW-U5 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:31 -0400 Received: by mail-oi1-x229.google.com with SMTP id e189so11079165oia.8 for ; Sat, 26 Mar 2022 06:26:29 -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=kCBAoENAiY9tRs3tDbNuJNsMArF3Wl4ZlwA9j6bO048=; b=Qi3kLmiWUXji1lVQ5t8FaRlLaxVjkvMMOQwv7qbEiqIQUwA4KaKrSSK/3Q0c5e2qXv jTvaBPKNgwMGFzcWP0sSNIWNzTf5WU6TaHLvgKlIvWPax7r2++4vpiRymaQHSDuDoId+ Xnfhh8TUqUo4N5WrWFCmpO0c1wm3D59PxsLuwIZkCmcC1s0LqD3DbTpxn5BXLI/Q2GjH IEwlxJhYjEyuYny+YRU8yXfhbpU1mDVO9r5t00QFo1thq4qHarR9Uxqo8zruLIrkNom5 /LQsN/LIjp64FjzAYcL7ulf1ociELXFDftiHQeA5OK/QlQUt4tXpLgMVutwT8XMVdV/o OWXA== 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=kCBAoENAiY9tRs3tDbNuJNsMArF3Wl4ZlwA9j6bO048=; b=YUgg7rChMZMaz2MaQCEGtUG/BcmQ0MwE/SXoosdiK78XyK3B4xGwGs+BKQATE0qCys hTsCRunQ6puuJFdcbN3D0oJyGY4zz9v8Dv3fwFXFcUxPe/O/23wC3AT6jv1zqVD9iY1W 1S48UiNxL+yTzv52SXYnzDbZZ5rUIX+TYVC6vgBrd5TP0MF3w5INhQJKWcWTPot9G+cA A0VQz/PcwVY+Muf12Qo4RT0garmggiVmUQ+AY9DYjrRMm5hy/1i1BmKLpvuRiW4jRSRQ EfEm5F0q9MCxWULGyNgU69pIVCJ1WHq0ibXrX0Gaya+GwVOUqRW1GjBhwQlo+1VBgysX o7lQ== X-Gm-Message-State: AOAM533BKWQ7RyZhB/zaWeEIUftaZItyeuvqXf0QwtUbQdDPeSKn27lR Hu0/xsjgH4qRaO1qiGBxbdfqzmFurA6i4AVP X-Received: by 2002:a05:6808:2204:b0:2da:30c1:dd4c with SMTP id bd4-20020a056808220400b002da30c1dd4cmr8000386oib.195.1648301188974; Sat, 26 Mar 2022 06:26:28 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 25/39] include/qemu/log: Move entire implementation out-of-line Date: Sat, 26 Mar 2022 07:25:20 -0600 Message-Id: <20220326132534.543738-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::229 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.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 Reviewed-by: Alex Bennée --- 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 75973111bb..42d545f77a 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 dcb8ac70df..9b87af75af 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 caa38e707b..8b8b6a5d83 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_trylock(void) From patchwork Sat Mar 26 13:25:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554381 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6449879mag; Sat, 26 Mar 2022 07:06:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS6pSkjYlTDWdIfYaJlCIxbjl+VSmlmSEtG3s46I3HbFjnJNCUz1l4oXRHotRxxjL8L2h9 X-Received: by 2002:ac8:5b0d:0:b0:2e2:2e4a:a5f7 with SMTP id m13-20020ac85b0d000000b002e22e4aa5f7mr13416045qtw.185.1648303584233; Sat, 26 Mar 2022 07:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303584; cv=none; d=google.com; s=arc-20160816; b=AZfqv17/J4G+u3kxMmvEfAYx//Gi+4mZZWAOyvSs2lpe7zIggIOauBsXO6WtL1UJx2 NXVAirO+3BetjbK2U8Iq8swTKcVe8SyCAS8aZhD+tGvvOt0ZisaFXYta9riJaQDKp+jP CuwEkeswv+3qN8MLEp4shYvpb6c8npCIvpFlzZA4D5j95sXZ+aEAWY2LWiH9VH4kIT2o WUFhRF9jZ1FBFXctxGiaaAjeBBqmHzpgNyFkobCPhDK2I2QAryHRWHEm4Pezu7aGBs8h YibcSd4Lpffe0Z7lYTCtXDGbp3HE6o0dJ29Q6PyYqPZkGY36MsWvnaGQlaMR/LofpoEq E4Mg== 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=jIFec7vua8qaqcC2DD7t6o1d/RYkHEXO2+luYM5xdxE=; b=dL4DeaCck23kdm9f/3FZ2XFdQybrGX/r4T1NxGIt1ZfnGktAyeGDQSLtfO9/Ybseim 7lZFdk4R/7MB0srLUEO7ap/4l2AwILdAeAIiBEfVQkX7x84VVbvKIPE05gbiuftbsXkJ +M74Zij2LMcsCIEBbGcJ5NjsMkeeI3oeWZfGw3CV5sbpeNxoLizDkYiHUU2F/J7/+PUw +X4EKJ1/cS3h6Geq0iZYjjwuZpYEO1FmBkJXA7Agwq9fA5OH9gmJFVsN0p0aATZ05EBW Mefh5z8RVGdZUcUVFDVj3wFw1nFxjvSkmP2o31KtA85s+Dka/Qdp/meTOctZjGuHOzhk Hadg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LJH1D9Db; 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 m8-20020a0c9d08000000b00440e46a7d5dsi2843231qvf.507.2022.03.26.07.06.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:06:24 -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=LJH1D9Db; 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]:57474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY73f-00030Y-P0 for patch@linaro.org; Sat, 26 Mar 2022 10:06:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6R7-0007cK-2x for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:34 -0400 Received: from [2001:4860:4864:20::2d] (port=40501 helo=mail-oa1-x2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6R5-0005Xk-Lk for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:32 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-d6e29fb3d7so10739419fac.7 for ; Sat, 26 Mar 2022 06:26:30 -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=jIFec7vua8qaqcC2DD7t6o1d/RYkHEXO2+luYM5xdxE=; b=LJH1D9DbfWNaHSJUKadfyGXds7LKEXGGGNMLTunGmKjnEJvEuQo6OIU5QKOgyVxMEg 95JWlPr2ItggpBb47HcR/A3PwDLfw1hpNlT5dHFAVHkI/mkeWf0CHMG3tgZ87u98/Lhh lo4c2afi1FoWpBMsR2md3duNM5YdiI6QX1k9oaZVqPLl5oeSHmGPLJ+fkYF8W0/M8jxp 9zQ30u00cof6XWbAQcnKdFquoYlZvbwg/vnR4K3CxXIrDUpD7juWB6kCozyhgCOzSI+2 jMkWBkL93zAIQwhZtKxKDm9l6gTBdmn158tSPSrrMRQVlY7LqzdSM5HCu3wH87w92Bd0 rISg== 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=jIFec7vua8qaqcC2DD7t6o1d/RYkHEXO2+luYM5xdxE=; b=OBBRxXA0WRe+ZpSjKeasREsTuNOUv1mvyYGtWTqM/V5UTB/fNp92uqOnOljWbzs60X n14B7/z8le9Xqz2l6VDQg9MmU/heA/+L9PDtKVkq09O8h+hDwwmVfZ3kcmZYPdH/PFxs dWWaoVG4A1lmf3vu3bkcHFYROhMdk00TMwmPKuFzKVroogStWnZ0jhOdfAJU9gyX0nt+ ScfaWb0rhnP3S/DGyu2qApB4wFbpXkzDVEskW7FPPwjxMfyXxAV46tJCWczvzG+lV1LS VkV+39KrK2u3663NjCsNRQY7HWDX8MH6Ujk9NWpcCoea9stvD0WCt3xQEJfrrdLiHYBS qCiQ== X-Gm-Message-State: AOAM533RTX7NheJuqKzeaG/2FRVPy2EMJlJkqKNpmev//0PHJ2oqMXiz 0MqLxuNGOgGEXVKP/oUJ0H8AqR6rXVDACqFA X-Received: by 2002:a05:6870:b623:b0:de:899:774 with SMTP id cm35-20020a056870b62300b000de08990774mr11583049oab.219.1648301190284; Sat, 26 Mar 2022 06:26:30 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 26/39] sysemu/os-win32: Test for and use _lock_file/_unlock_file Date: Sat, 26 Mar 2022 07:25:21 -0600 Message-Id: <20220326132534.543738-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2d (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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, 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 Reviewed-by: Alex Bennée --- 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 aef724ad3c..93a05b8e92 100644 --- a/meson.build +++ b/meson.build @@ -2054,6 +2054,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 Sat Mar 26 13:25: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: 554380 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6449751mag; Sat, 26 Mar 2022 07:06:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO4uTPkT1GKdp0eEe2KYema3hr+KZM+2ALocYY7KzXZPpDXfrdHTc4l1jkDes2QSYmj8HJ X-Received: by 2002:a05:620a:2413:b0:67e:d7be:348e with SMTP id d19-20020a05620a241300b0067ed7be348emr10477850qkn.252.1648303575713; Sat, 26 Mar 2022 07:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303575; cv=none; d=google.com; s=arc-20160816; b=pmPCxN9YpmJvxxXxtBQDDAmzHfmNgQRVwLR/p+W3sZU6BAy1xvLMcA4D8QeLa7beFZ 2Msy8DQoY0zUcCLAUslOBAmGON/RwCXdT8iDiA84rihr8tNkOqh/LnNH2qHHTsy5rQ5k V2xloVWdl+cDbOXXpr911xQId/IW/ZngXHi/Znp5F+mRgpGOpsZFeO0YGanlNRdfc7o1 nhVZCztiMkFPOgKvfLfCQC3r2PElWDC/I9nzuJk3aoFKS4vWjA4c3icKwKqR+kNEGx6j UiI9X5i3GWa1dfLNXS4m84ppmCcthZAWoCvfLlkJ1eA8O6Wf4HE/EJAZC/NQzxSSjIMp z82Q== 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=weAzEbOYWT6pn/rsG4fbAVbqxomesdIK5x2EPw6yBPM=; b=As3oizdRoeFhFzJKb/1Mq9Vip2EDXpezQALok4kcZ9GdE9Pbz5jmt9QHD6J0Ldml8e Bm6qgw6rMhKPuj3rSxha9pRXJVGAYNKlJRKeDfPc7ofNhvQoclevW8X7md9J2AUo2CCP GYoqpg2/pgzHw/TgX4e5Mm+rCp4WXain3QFYtQHF5mr+kmLB1c09ElJeFbSsR8/aqlHW 7oh1OcaT1dapub4IFrHnwA25UjeH4BC+UXhfpbGGjmpEs9oyAko4qL/bSGw3iFeFGLoP EWAz744YfNd2iDVfSxzzSkCPzQGuS8gi2EoKLMRd8IjpvISg1lNd6hcTdd9/R+SLpsDF A0YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bgVWVn6l; 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 h18-20020a0cffd2000000b00440e46a7d39si3163425qvv.471.2022.03.26.07.06.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:06:15 -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=bgVWVn6l; 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]:56806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY73X-0002Y8-8A for patch@linaro.org; Sat, 26 Mar 2022 10:06:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6R8-0007cj-Ii for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:39 -0400 Received: from [2001:4860:4864:20::36] (port=42193 helo=mail-oa1-x36.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6R6-0005Xt-OB for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:34 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-de3ca1efbaso10717206fac.9 for ; Sat, 26 Mar 2022 06:26:32 -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=weAzEbOYWT6pn/rsG4fbAVbqxomesdIK5x2EPw6yBPM=; b=bgVWVn6ltPSxghTpyzxRfQz3NDuoCM8EYLaToOhKzB7mDUAlos29tDqNayXj9wwySG 6fAKq0cDOQKd0uV+oed+OEbM4w+YtA0M8g/BnxlSgId9B2Y1GWVWB3Hi4m7vPD6sYFX/ VLyJWw40D6YechiQ+v7yrADrivyjB4Lq3oD0JoENDjOI+mTtsEEK6bZow9YcNr1uyxk4 0N3HOtMO0tnz8FSY/uNWDzgY+fiG6Hqjw1FYFQx6MDcbL31Yemo2sC3qgmmNLTh68mSv GOrCiH90Agqkp3xbuyfwYW3m0i5ALZjLDl6IjsCW4FqA+PBkZZJ89s9cEEPghbDczGRx BVRQ== 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=weAzEbOYWT6pn/rsG4fbAVbqxomesdIK5x2EPw6yBPM=; b=Qg+wpZ1EPPQmy/1W9MBUyqcfJOVOsryhDrUKEt4BqqouZDchHhr8t/IsAeERtrntDZ +M3sqkFMCoLvwnwuUDxvjuTuIfbGl2B9JB3/dPwrwrLeI36ZCLtO8C1XRk9QHSuFDywv iB/71Y92RzGBJixUF4+nGp3Kx7ZM+53vvKN4W9LVjEOZOusWmp1XqdBmJObrIPianR1P MbXkhEm0vyqnQ5MVyex5fhcAmSnPSMZ+x8jNhW4oPsmBJfWHp+YbMRBmgjG/VlDKNhwG xL67CC6CLNeYLtvCUrvub539I858cCVMb3BBC8VAK4R+aKHsnImJaeyobai4ZVWvaeAS paqA== X-Gm-Message-State: AOAM530ZSgKEa72q1CRsfotHPScMs0OQ8vZuUEpACujpLc8cK5tLAe1t nte6zPjWm+I/BBTFfYQYHAQolhAKHpqg9ybc X-Received: by 2002:a05:6870:785:b0:da:ac31:3e04 with SMTP id en5-20020a056870078500b000daac313e04mr10691756oab.270.1648301191725; Sat, 26 Mar 2022 06:26:31 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 27/39] util/log: Introduce qemu_set_log_filename_flags Date: Sat, 26 Mar 2022 07:25:22 -0600 Message-Id: <20220326132534.543738-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::36 (failed) Received-SPF: pass client-ip=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.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, 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 --- v2: Return bool, per recommendations in qapi/error.h (phil). --- 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 42d545f77a..b6c73376b5 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -82,6 +82,7 @@ extern const QEMULogItem qemu_log_items[]; bool qemu_set_log(int log_flags, Error **errp); bool qemu_set_log_filename(const char *filename, Error **errp); +bool 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 8b8b6a5d83..2152d5591e 100644 --- a/util/log.c +++ b/util/log.c @@ -117,15 +117,58 @@ static void qemu_logfile_free(QemuLogFile *logfile) } /* enable or disable low levels log */ -bool qemu_set_log(int log_flags, Error **errp) +static bool 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 false; + } + 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: @@ -134,71 +177,58 @@ bool 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 true; + } + 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 false; } /* 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); } return true; } -/* - * 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 - */ +bool qemu_set_log(int log_flags, Error **errp) +{ + return qemu_set_log_internal(NULL, false, log_flags, errp); +} + bool qemu_set_log_filename(const char *filename, Error **errp) { - g_free(logfilename); - logfilename = NULL; + return 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 false; - } else { - logfilename = g_strdup_printf(filename, getpid()); - } - } else { - logfilename = g_strdup(filename); - } - } - - qemu_log_close(); - return qemu_set_log(qemu_loglevel, errp); +bool qemu_set_log_filename_flags(const char *name, int flags, Error **errp) +{ + return qemu_set_log_internal(name, true, flags, errp); } /* Returns true if addr is in our debug filter or no filter defined From patchwork Sat Mar 26 13:25:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554388 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6455761mag; Sat, 26 Mar 2022 07:13:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT3X76p+EoXLo/imFU4qcJ7HbdnGi4IoQFLSaf9pr+TmjXk7ES281i7pLlqoj3g71dtKOI X-Received: by 2002:a05:620a:1426:b0:67b:467e:a626 with SMTP id k6-20020a05620a142600b0067b467ea626mr10206541qkj.261.1648304013677; Sat, 26 Mar 2022 07:13:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648304013; cv=none; d=google.com; s=arc-20160816; b=knk9sNt2/clcpW+4Wa3jT4HAsB8/mLP3ZuQCWWkzPMk/wPuMVNdciry70bAae7p3KL K94sxqBShYwA3Uk9SoUAp2r8iMhTOiV1Wyilfwf+AV5tJ/V72Wx79faaYJ27vszWLBA+ fcIcJ/13drD2U04syF+E73hmBtQULaHlvij6X+bntMCvEsJZPEbSRCJWXg/WV/NjH2nC SbfAhK/JPsvvsCWR5Oqnb4YENPQQf7LEG2dqp+A8cSD9MSVJu2xEqpgcUwSTl3XgENwQ qRNBGhlIdMKAcE6BfZPLZuOz8aQ/M3ENzslymhggY7YhxJh9asDJisyHWI2wwLQl4pdD 6ZTg== 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=jlMPZ5+ciovunZH+v/owH8Odf5O35GcMQuqFyPTC+AM=; b=qZBXtSvURtHuG6KLC/4EF/mDbSGv1r+sRF8SWH8uubv/+H6yjt3sFKrPe1J09tL5+G 0i4ogu+nnndKY2gDcvNfw30JLrHOzqfSHOHiKueBsA2y0BKRQ5QaLdnm+1KhX2kCTJno LVJX/7FlyY/46ACXiYr5GM6pXWgBQnYloMq7zXWY//IBpFa5egWPEFLqW5DndMDqP3qg 2VJyAikuyi8BF/R96ooI3/ZDy7JI/Any0F9RXxuPF9wg32MtEQPrgehF9mm9N0Q5lg9T Tab0fAXPrgmbFns7TWhuhBaHWVM01MCCCaqHb5tQ3npfCTnWEFdNuqdqVFJCPvSU12eO JSGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XfnJR1AF; 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 bs19-20020a05620a471300b0067e4be23931si3524784qkb.374.2022.03.26.07.13.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:13: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=XfnJR1AF; 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]:47334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY7Ab-0006rv-Al for patch@linaro.org; Sat, 26 Mar 2022 10:13:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6RA-0007dE-Cw for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:40 -0400 Received: from [2001:4860:4864:20::36] (port=45864 helo=mail-oa1-x36.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6R7-0005Y3-OH for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:35 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-d6ca46da48so10699744fac.12 for ; Sat, 26 Mar 2022 06:26:33 -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=jlMPZ5+ciovunZH+v/owH8Odf5O35GcMQuqFyPTC+AM=; b=XfnJR1AFNM+2CYc0XgXZ/qDrYf7l8Y5TX8rNg11+KAsASBSycNgeCmeXZEfBejPF9n 2DExRC6Di2Op4ZlwIRsalqnb9WKq5sPvey9wmRq8yQ0MQwrrVsKxL0MjTaD7Rug5pXDw zhIkfXTqiQjQCMj3YiGSUEBC3Arf5jyiiN6VTKzNQ30JoKFGzjIk+lQRHJqGHgGlHaPJ eOfn81QApvnAQ5dNUcCTQL7MDHdxW1AhDHaNS1AurynO8HTuPBAeIaPbvgG/Z5NXuQOd Ts/wuBu1Bn87jb/S7iFK1AdBMV8tGt+p//PE01w1b9g5xx/4/i0zn0VgaU69OXbiFb0o jquA== 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=jlMPZ5+ciovunZH+v/owH8Odf5O35GcMQuqFyPTC+AM=; b=GW0RGMXlDqPJenZtly2lvUrjI7TAsnoImgpPn8GDv59p4xeZaVP32VMOhLNR/Ukfgw savTD+gvLHCvfGS9kaqByzt7w+NfxibhyFZfJX14iG6W/YPEC8qkBXKbiPzDkIX0pbzj 1w0HsMu1olTlXoSRJS7um8Pu/4Qs5FIJp40VXl2lKJ/CPrwRgkRGCC3XMDTai0Ml9By3 hGS/EyhWFj9cgE/rHMzZfSb7bExhKOe2R34PEAPwTw9PWTv1b/Ir7b3jifvneNPIexex KPBFKb5xNWrRl53TWfx5R/MtqyLMHPsHOVI+1I5mhwFN6/QikLiHk96ClMT1umgiHvHF WE2A== X-Gm-Message-State: AOAM530p+CkjWbyjyJMy8P84l2VNuqpzPSZXaRrC7qGCAGv8UfSlyL90 bl+NcpRWXXMqaWhhxMtItRaFZN4hcOKIyarz X-Received: by 2002:a05:6870:3394:b0:dd:cfdd:34c9 with SMTP id w20-20020a056870339400b000ddcfdd34c9mr11507614oae.31.1648301192843; Sat, 26 Mar 2022 06:26:32 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 28/39] bsd-user: Use qemu_set_log_filename_flags Date: Sat, 26 Mar 2022 07:25:23 -0600 Message-Id: <20220326132534.543738-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::36 (failed) Received-SPF: pass client-ip=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.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, 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 Reviewed-by: Alex Bennée --- 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 ed26fc5acb..aa13eae7f3 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 Sat Mar 26 13:25:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554386 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6453791mag; Sat, 26 Mar 2022 07:11:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypFrSrCmSPzPP9grZo+i/3m1Nhu+OviBzJRlsazzl9qOp3AnoZvEhpZ8b5ZnwUS3y7duSD X-Received: by 2002:a0c:c38d:0:b0:42c:1a57:24d2 with SMTP id o13-20020a0cc38d000000b0042c1a5724d2mr13288265qvi.1.1648303862326; Sat, 26 Mar 2022 07:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303862; cv=none; d=google.com; s=arc-20160816; b=WrsWCqjz9YuxSW71gV+oq/SD28GTuMoxejXpTH3Q39j+p1anoM44rHPk6mAFqbLbTV sVEC5tcBIoG5nlzLulZWMjMYo+02vMgatnnBs6iaWWd+eM7niZJOGPvEtf84yPQOEf/+ onMSOQQNE9hrCMi++gp4TDj/YN6LGFz8ney8kfQQzG/8SdT5KwiQsYHvuPXwsaSI21q2 ppOGXpzK2EuhlXGjIjBORlNKImKyrLG1a5dzoOMXYyzgtctCI+HVnvXPjgDLfMcqw2su 6Vxhq51y/9HzYb2ZvTxHTPJeOcl5dEDG8qMDHCbyHJIIJoX/20gsrVPKTJI+rJWFN4FO um+w== 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=lb1+Il1eKojAxX+nWwkLAHUYjVhh/WZK+1C1/5aXdGI=; b=dlrSRGGs/fs/mqt3XNkl+oGjr6IYCej0xQduO9daHovN29GwEeU55voS69w8brK1nD ky8FvCjl1WlET692z1azj+hftciI81l5ODZJdZ0RMwLWeci8R2zJhRkjMUZs6zAD+Gwm CTx/El+/EalnZKWulbsqOmlxKcYZvf/WRTI0o0EWhgTjVkn0gpwFF2KBOej4bXxRMmYE mW5XYXg0pJvyBmIpnBeD9BLAhWl4RohcAj0Xq1K0V+yQ5NtyNh2F3bpXu6nhnNaC9huB 3CY9YTobfHQmJp4NAQtTwuP9kt9BAQvVPs/dwY4BrXdMOK2n4CshUzl5l5BWXUZk9YtV Pw6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ntkMSatQ; 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 q6-20020ae9dc06000000b0067e4be23ab0si2986189qkf.757.2022.03.26.07.11.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:11: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=ntkMSatQ; 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]:43296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY789-00046I-Ug for patch@linaro.org; Sat, 26 Mar 2022 10:11:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Ra-0007sC-Cu for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:27:02 -0400 Received: from [2001:4860:4864:20::2b] (port=45854 helo=mail-oa1-x2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6RS-0005YH-QE for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:56 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-d6ca46da48so10699819fac.12 for ; Sat, 26 Mar 2022 06:26:35 -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=lb1+Il1eKojAxX+nWwkLAHUYjVhh/WZK+1C1/5aXdGI=; b=ntkMSatQNWi3Iw6d9a742+4oLl0NPa/m6t0X6VAgU+/za/OGHh5/ThztlcIj2w5Qhm w9JIKTPe9yoqEqcz6jVH0XQUjapx2/OKb/bda4VVx+OJ+CX9zrDvHUp/HrGFc0aLaML8 GbSfX+fWpKm7Mmxrc8Pw0N1RTkJGKOFb1TGNHUixs1w1Rq1JwyiigKgcTA2J7Cu3MM+L rGotRTOvQlX+sUGJsSBFdHWAHrSubqwTKxTfzFxjdWSd/B6YGWZQhunpCd80xhE2aY+o 8xGb+Kf6CbRotUwluGMtiZuPt+6OHQyzAGsAtoQNiLck2FpAMfnuKzcdWDwN3B1peQ/p rE2A== 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=lb1+Il1eKojAxX+nWwkLAHUYjVhh/WZK+1C1/5aXdGI=; b=kZ8bdYhqiT3P6+CjgJDkxMLxaLcVLcGSFn1Pj24ygFMsA4f/gmWzoHd5y7J6aYLbTY pKq3eaWrhC9aSyEeHlGVy1E31/4RHNIVcdAVRCGIyKEou0ETD++hPe2o+sZCKVk2nFV3 OsA4i0P5I/7Pa71PSZD0zmTwf5aicCMq+NFVrfysU0+DnLs6zJ/WQwHBk9gEL8snySdM O/6nnAHHkV7bBdrsOna/rcO2bsPHLpxhlFk4vi+9VIJrr84MzEy8QT2AwThjKt1/s8CV xnDFXELr0HalxsoaFAQiBLipELej4NUxaSaMBG2rwNB4wrXq/H2K41T5RHR8RC3Bo1v8 JpFA== X-Gm-Message-State: AOAM533JlCpf1QEoZA7VheleCRjxQmamTxJ/0jTvp1BTZvIrGoEKpQrL vF4522DMW4SvVUALokWAYuhTwIAUPjyexoda X-Received: by 2002:a05:6870:601b:b0:de:c5bd:e36b with SMTP id t27-20020a056870601b00b000dec5bde36bmr1946038oaa.89.1648301194946; Sat, 26 Mar 2022 06:26:34 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 29/39] linux-user: Use qemu_set_log_filename_flags Date: Sat, 26 Mar 2022 07:25:24 -0600 Message-Id: <20220326132534.543738-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2b (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2b.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, 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 Reviewed-by: Alex Bennée --- 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 d263b2a669..0297ae8321 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 Sat Mar 26 13:25:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554383 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6451385mag; Sat, 26 Mar 2022 07:08:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhQmiwUnsK+wRaLBSOn9noYfWqpXTT8wmsb4V0XRTR8hF+V0DpDy3E5JkU7Eeli8PwSlNL X-Received: by 2002:a05:620a:4691:b0:67d:9bab:33d7 with SMTP id bq17-20020a05620a469100b0067d9bab33d7mr10331765qkb.500.1648303694872; Sat, 26 Mar 2022 07:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303694; cv=none; d=google.com; s=arc-20160816; b=gxakC1uydDSTgBDhOtbR6cJheaxIqVcJ1kXHT6y7ie9vsCxgn8KRjRCcJl0dpW7Wjj VeRp4KQoMymLcV5+wN/Tk13Xxybm3aZIyHRKvoFTcidM9tUReLj52TrTjKRkNVzcB0AV UNvq//jn0VbkYNSvZe5HKItFx3i8dlVMdQJpG+58g20kyqAsdLk7S1S7mnMC5IVnZv00 f9tsdQbT8nyY/+oIPBqJBBrpTyFRR0CsltrOjCylZ+wBFoISrdWHN0J43bTnQVahxS96 dRscQe9LFZDYFQVvoIE4VzpMx+JM0CcUi1vt24GchrTpz/457uTfldf5YZw+5437W1qo WqbA== 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=jzU0lMIGHRXlXJG9JfTKmdopHzJcZP5ngZbLDRCyMfA=; b=w9ok34Ho2jchNX8JtkwM68iBbMIvTF9NAAMjcATCZU4l+NT+ACmT7c5/WVSQVETXWO LTvG2feC/Fh3QgNaIS+Gg4Qh9AKEnodHKMnESWyKSxINqYQ/X6ENE8YiiSkm9YB+PCLj QS4nl5uKv73fS5Xg5GkvQ/Puvwdw+TIgcpBjx2Q16pKVUQsbBJEafW3MSMZ2t8DJ2et+ /jTL+dYpevRLbPG3HbkSWduXdkO75yIbq04txpssER6Og8Fv0j8/UvRmL3B4zp/a6Rlk WfQMmPxXMYR4x8m36SN7AA2HiEYIGHD8mBrWQDVXMDxk5WSaml8zskdSSZZxhIuSbV9V 872Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e4AW8isi; 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 d9-20020ac800c9000000b002e20929c1basi2912911qtg.136.2022.03.26.07.08.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:08: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=e4AW8isi; 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]:36920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY75S-0008IE-EA for patch@linaro.org; Sat, 26 Mar 2022 10:08:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Ra-0007sH-8a for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:27:02 -0400 Received: from [2607:f8b0:4864:20::235] (port=39737 helo=mail-oi1-x235.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6RS-0005YR-Qo for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:56 -0400 Received: by mail-oi1-x235.google.com with SMTP id j83so11086126oih.6 for ; Sat, 26 Mar 2022 06:26:36 -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=jzU0lMIGHRXlXJG9JfTKmdopHzJcZP5ngZbLDRCyMfA=; b=e4AW8isiiagHmsxuBHXQJRphddATA9qjirymc9621qEcxML4m7wDMqI6yMQKusrrsf x/1yHYF+qoMDmi7lX6aaEL92DwTo+CHIGt5aBAyJl3QFu1+huCH6jYsBAUZvXa42til1 DAxD81Ame2GyAjN9v+RTjXUIPEAyXqBsoy3rWV3R1QUVfAGLa90XTr0GuDTNLS0hXKZK /6ehd5IUc9364xHEUoK61JA2JsLA0VmgPEc1VK1xY60TtB3DQqp6vRi40G4Uw32f1xZQ gmDHpE5SuNNy4vzaJXH1mD8F/RFPntPV9HaJDYCPs6LdTsi7ZvM4crwI8oEzcu+T5HTv 13iQ== 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=jzU0lMIGHRXlXJG9JfTKmdopHzJcZP5ngZbLDRCyMfA=; b=Cfny2DwTfG0O1GVHGo7r+SPE2N+j7FTPTEqyyUHQG0TaOdBfaJRmWQmoXMymDbj5Q0 /tTkvfosMSGamaNHREp7ngmvJm74spmOmJ009jdSnS2oq8wZESp0kjM0Iy6xq9oFR6b+ kQrjA+N+a+eTdVwZMkyFgtfz6PS+k/3XBb+76t1VI7hDiZxX4qRTMibUQ8L1MZxQtNMU PH+2wAdSo6dwxfTVMxMIZLufkg/fl1aqEgt/609icWbex4dgeHYjKdP9yPoXaj1DmAxL LRgsQwsifomvnojrfntjE45nrLsLaodKrL64kqmuPbM5V3o50nf2idvfSZt2IJhFW5Eq JomA== X-Gm-Message-State: AOAM530RrT1xDXyEqO6ACEZ75EGcGcRiD/AgggDYHe/xMuee64AkJk0O CPi9l1F84r/y33H1Ai/RWt5ImVnre5tidS9K X-Received: by 2002:aca:1817:0:b0:2ec:f542:c96c with SMTP id h23-20020aca1817000000b002ecf542c96cmr8117276oih.36.1648301196058; Sat, 26 Mar 2022 06:26:36 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 30/39] softmmu: Use qemu_set_log_filename_flags Date: Sat, 26 Mar 2022 07:25:25 -0600 Message-Id: <20220326132534.543738-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::235 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.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 Reviewed-by: Alex Bennée --- softmmu/vl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index a74d0a44a2..65c02963b6 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 Sat Mar 26 13:25:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554384 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6451486mag; Sat, 26 Mar 2022 07:08:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNLGaIGP7nif1GcKWZTB9wt6Ra6vwqu+NcxAhMbtpEOsfBH5O0TOTuxBfxe7Zak/C+ksKm X-Received: by 2002:ac8:5b8f:0:b0:2e2:72c:9af0 with SMTP id a15-20020ac85b8f000000b002e2072c9af0mr14141476qta.498.1648303700528; Sat, 26 Mar 2022 07:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303700; cv=none; d=google.com; s=arc-20160816; b=nSQuzTsSeykpZvbzmWLDmtJ7UfA3zJpL0RHFol+JGLGU9uGvIr4/kHTNJCCOqOjl+F Kwa4iSR/TI0n6soICg40ikMnZ91ST4pWxr2R0ljnfLarX2uCJbtNvUiUZnmjh7osBCyL uXBwgmC8LZ14gSJIXMrlT93J5IW0CAWlAHBaTJfzjMhK8ElkV0caLbbqKA2uV0B+719v CCSHziGLKEk0NevYYd7Lf5Pe6b1V7k0vTXtoyb1bxtyD+2bSudySlLKpewxT1NOj9WNE +xNFC/9EE5G5QuJVhVkLJ0XZjBrN7j/03HANbNDN0Il/uZxdEVlP+7nllZAreKIiYrBL +taw== 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=6RmSObI8TwqseZSqimQUfXxvb0G/cAqhY8HopOTgyxA=; b=jQKke2F64j8pegi6K55GNL00zwJTy97dkcZhVtCU0VXJyrpQOnTZxYCnk4scplufHK /YPOINrvuSlwAG49bQwOIf/lrr82OsQYSWNE4DmFvmZ5ifM7rXkx1TIXozZNdk/v1SeQ r2pM53PsAZIW5wrrmvhqWApRkrZ74b32QWbyycFWKwWbzcejoBs6HmL/aBeofve/Niyb rlaKLO6txyARhw+HnuI9MlPucsRWQi7LTAyrsBbz/N7NWCegohcIi2eRg1ZFnZLo8CuN Vmas766vJIKb7FiaA8zvXlUBPjFUQjmC47PW5Q60S67h5sIu5YvsaXDPNzwYnq2gaJ3h aA7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hvfVxFF4; 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 17-20020ac85751000000b002e1fbf3be7bsi3767030qtx.108.2022.03.26.07.08.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:08: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=hvfVxFF4; 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]:37354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY75Y-00008O-2K for patch@linaro.org; Sat, 26 Mar 2022 10:08:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6Ra-0007sG-8R for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:27:02 -0400 Received: from [2001:4860:4864:20::2d] (port=34147 helo=mail-oa1-x2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6RS-0005YV-Qp for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:57 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-de3f2a19c8so10758622fac.1 for ; Sat, 26 Mar 2022 06:26:37 -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=6RmSObI8TwqseZSqimQUfXxvb0G/cAqhY8HopOTgyxA=; b=hvfVxFF4zHagRIOIgbERJ3AIQx+eQbD+PtEcV7fE4yl07CxMwP+hkEVTWYja5erWSo Dsf+rTKOiX6ffufAgjoKe7EIOdRfKaBzPH+rnixbQ45+jJohNwYbcaM312nCMl/fIame pGd+HYyAOdUE5ywtE9+33XTsphjy3uvdRZNIgodhYQguBPR2XtAA+LzRTTLvxdA/sJf2 XVBQ15lYRtUq1itfnSKvU3QI0+V/OeBgu4T7Y8EI0zaJxEeTMgFzN9ry+FGhwM9tllFN t5Mqq4FLzwym9FzrDm3GQMptZt8Hfr1VPiuDu3HMZvM3iMw0GKHeQ2G5zEFWPPYwyM79 RrJQ== 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=6RmSObI8TwqseZSqimQUfXxvb0G/cAqhY8HopOTgyxA=; b=lfFQG9eygUROtSGWeLeThnaPpwAjfDqRRAUHaGlTwVa0/gOpJvazoNu4bvz2vT6bHr rfROKDPXC5tWk5jssp3RZRfHhFGHUN4CRnfGRlSKxuXNAPUF6GRKFqus3PigeOKWsodu mINao/+WHrBJHUJQdcNsa3vKAjE+sNhN5VOz8H6TNoEBdIQcb0fZiUzzFGYBw6GNJkkv GASA7HK5VZlBWVPyyw/GwYGuRBIPiorjwf3rVHtBANZnbyt2Vz7Z3of6kMjWsLC6ML75 CLESx8dFvfk1kH//lAQEptE4ZicttWSNmkc3lU4OpVIm4pDy5Mv0idEXSwrIJisSFVm+ z3HQ== X-Gm-Message-State: AOAM532BnmZmjCm9dwQtwHCrRApU2lr9CvKq4PXmyL5SuhR47l4jCXVk kL/bJwH3cie9x1PfChHuqnDECcMCGGhhRFwy X-Received: by 2002:a05:6870:4790:b0:dd:cd0f:e00b with SMTP id c16-20020a056870479000b000ddcd0fe00bmr11254147oaq.120.1648301197306; Sat, 26 Mar 2022 06:26:37 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 31/39] util/log: Remove qemu_log_close Date: Sat, 26 Mar 2022 07:25:26 -0600 Message-Id: <20220326132534.543738-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2d (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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, 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 Reviewed-by: Alex Bennée --- 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 b6c73376b5..a325bca661 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 bfa4db9cd8..7df12537d5 100644 --- a/cpu.c +++ b/cpu.c @@ -408,7 +408,6 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) 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 9b87af75af..74ec89f1a8 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 2152d5591e..491a8f97f9 100644 --- a/util/log.c +++ b/util/log.c @@ -198,7 +198,7 @@ static bool 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 { @@ -322,21 +322,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 Sat Mar 26 13:25:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554366 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6435989mag; Sat, 26 Mar 2022 06:47:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz95wjT6pDV9nFyKE5mZuuzRk0sVVEhNMvkxhbG5LfGVivPpZsCB0ANJdWL5NCj+jk0293z X-Received: by 2002:a05:6214:d6f:b0:440:ffe0:be96 with SMTP id 15-20020a0562140d6f00b00440ffe0be96mr13482805qvs.103.1648302472292; Sat, 26 Mar 2022 06:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302472; cv=none; d=google.com; s=arc-20160816; b=yfwbQVjIfV1sSwITDD2E+gNwejNajydg6mAwHrPyakq1BTJ2YyXejAyi12Pvh/eb4h tsmAL0O3t80iXxpVsMVfAWhNrKa7CJthJhOgL+5gBNShQvchws+HGHhGr8Y4mdxGKiWO W5dJ/S4HceDg+2606vZ5zTuxbRAaB7EovT+jSio1U2AAt9MpVcnhCDUY+JQR/mcYX3tF t7d9xvOSuTn9NF171/IoRZYfRMMfAcHIu0CkyJyOkqF4atV+M0uX0l8lW2CXCCV8/HPO FwbkUw28hB54FRqEc+Dy32EmOgiwvTWRfaMWF/JrTZfJa7ehr1xkzdYQw/g7nhiJRNZr wK8A== 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=tAM8l8umDTOu711aIMp31KRAq18xpQUFDBfm3PD7em4=; b=WpYz6ABQ/jN23+1s+1xDS9OH3MtDtJvoWGlbfTs9Aol2HzbMZaY/4R8Vp3gNVE2O+i cZWR8kKp//kGLNfyADyzpYiUDFSGSrQQhLayknRmogITblC0jNxQImiWmTn6YgXmY7o2 lPn+/IECh42j8edQwV8ItWi9eU1bUr13yjG1WySBHZw9/oVhF7HWmZTCwr2sr/Tkrbqw Nu+7Te5SMeK4E4UdmPW+Yy1yRD/DO+Aqka15y/c7/quFiwI9Y8q9D6az1PnGIn/WekWD uwJst+EcNZUGsRHKk1DEHUdpnX2ijJe851/akghTbiRiro9X+UBj4Bjqjlx5gkKL9ZJT 29kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BNQUIdUy; 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 g16-20020ac870d0000000b002e1fbf3bf93si2858583qtp.388.2022.03.26.06.47.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:47:52 -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=BNQUIdUy; 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]:50750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6lj-000410-P4 for patch@linaro.org; Sat, 26 Mar 2022 09:47:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6U9-0002ov-Tj for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:41 -0400 Received: from [2607:f8b0:4864:20::234] (port=45720 helo=mail-oi1-x234.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6U8-0005yS-EQ for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:41 -0400 Received: by mail-oi1-x234.google.com with SMTP id 12so11072747oix.12 for ; Sat, 26 Mar 2022 06:29: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=tAM8l8umDTOu711aIMp31KRAq18xpQUFDBfm3PD7em4=; b=BNQUIdUyW12rPVzyDZtNkkk27GgsLQDiq0rWh5/IsmhUcyQLn2lMCdiKExaECvNE1Y EhHVsLDhQhI1rtUEON3yuxufOH4wdIJTzGFmsTvCznYy6KhJXqIo8R9Ysw598Q+i8vNB Vw4iePBT8S8+HW98dZe4xwJf/iR8ZIRXWfUH+Qd7+DCdcini/+n5prIzEJ8+14CY/mxS XhrUe1FLPtshVU4qgEPKoi6h8yKeEFjijD68AUzEW97CuILFJwBfM61B/q94kQ4Od5N/ pt96y5lku82eAhRKLLn8n0vrk8o9VBnjJUvmP89MOc2gIbg3RuGSD4scYHsng1yL+mfU gK0g== 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=tAM8l8umDTOu711aIMp31KRAq18xpQUFDBfm3PD7em4=; b=ylSvkJrw9mlzEG0Xz7F+XN1pYv+bSle9PpiKbWYmnpKKyAIrQECI0uI8S6FqwDWDFu Yp/6IR/4wkCOJIo+pH7cCUGom7hSuaKa+LetzdiqoFr/7VGRBCM+boDZmupvuFA60MqQ 3Zk5a6ej+G9/Z2cpykVjBs9t9flxJAead7MYASCTBSomXJhBMWdOwtSCkjWvQIbMCn/H GC/Ia3ncQAXjezfRbaie/x5/PwqHT5gfqfN45CUzpyABKkk6Q7sIMDpZOJF6TaRlEhxr /7zdVik9htLGfHROXkrBlC28zazi3nKXM431QA9Yh12WbOrcd6CixxRUgEgiGLUca+4o PMtA== X-Gm-Message-State: AOAM532fuLxDEMiTjGVkh2wRWCrx68H5pj3e7xFcKDGz0AqwfgRrxsnw lHkqldKl+xZWXYNtaw+Ts8L5TtHb/6MO3JxM X-Received: by 2002:a05:6808:9b4:b0:2ef:9e41:4f6f with SMTP id e20-20020a05680809b400b002ef9e414f6fmr7752317oig.40.1648301379350; Sat, 26 Mar 2022 06:29:39 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 32/39] util/log: Rename logfilename to global_filename Date: Sat, 26 Mar 2022 07:25:27 -0600 Message-Id: <20220326132534.543738-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::234 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rename to emphasize this is the file-scope global variable. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- util/log.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/util/log.c b/util/log.c index 491a8f97f9..b3f79deb6c 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; @@ -151,8 +151,8 @@ static bool 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) { @@ -161,7 +161,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, logfile = NULL; } } else { - filename = logfilename; + filename = global_filename; } #ifdef CONFIG_TRACE_LOG @@ -173,9 +173,8 @@ static bool 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 Sat Mar 26 13:25: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: 554387 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6453889mag; Sat, 26 Mar 2022 07:11:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYbhu1jJ2nh1hZBDbhex2e3cQUIxv0IMoXXh04ngV6+yXJ7fyHmGzD+PUwpXsyL6TLKRq0 X-Received: by 2002:ac8:7d51:0:b0:2e1:c757:6d25 with SMTP id h17-20020ac87d51000000b002e1c7576d25mr14141913qtb.301.1648303868907; Sat, 26 Mar 2022 07:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303868; cv=none; d=google.com; s=arc-20160816; b=ew1FPCKWhl0/z4tWKm3Y9AEp9ZUuGoGkt3KmFmCWQqvRpOobcd4UCGynoRRB6pcSny EbYs49h+Vk8sblt7tX11diLgKEA2UkQSmXVtPdcQoywdfDAj0XA5xS0CPcMq1JwjOqNw RbA8BQiGmeg08GZyquX0ZWmnJaErTNvvsdzovLFty9NF5iY/0dnzFLD5j20DE/oUf0r9 ynzvgepJn4d3l59MULPZLLX+Q/SPr6ngoAi9CxJ3Ye50EqfYLps99qt8HFZVH49DKWBD lgle9bVlu/i7E7alv338vUbAk34tGasVoJJkjDhOtnXGDUvTHtZL30Z2icQFpJ4Gwq0c KG+w== 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=a5VbL0aLAFbBvi7mnSV6DMzP+5DCyDQb6KaEjRaA8Sc=; b=pGr947axzkPyKoDzbDtN+x9LT6PBFjfO8PYS/lMK/kzmVkLsBs9F+3p6Z22NlRMKrh kgpnLlTGaoTWS+XrIt2N4voTo8b2ajfbobIGwrqp38r96O0gAZJ1K8a41C7Yx+rrprH+ unsVg+6yGfTObWbgCGwsxqaXN9Qk5Cv9PT9QjWThjJEwmPAigzb1Mxn0cFobG0qrqrvd v8qDq4qHQAye608QH1v6bQvfVGo0LuedZl1HiQjg8bHH9P1EOnhuPvGJIxNyXadifupf vsfuzGu195HUnNUHTUGiqCl78HUeQ6p2ZM7ynTH59SfZ4FGnmKmPjhl8oq65IrUDbJP/ 9ASQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="t/wnCmSs"; 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 c5-20020ac81105000000b002e22bad42fesi2871851qtj.408.2022.03.26.07.11.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:11: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="t/wnCmSs"; 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]:43892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY78G-0004Tq-HP for patch@linaro.org; Sat, 26 Mar 2022 10:11:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6UA-0002qf-T2 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:43 -0400 Received: from [2607:f8b0:4864:20::22e] (port=34598 helo=mail-oi1-x22e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6U9-0005yX-FA for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:42 -0400 Received: by mail-oi1-x22e.google.com with SMTP id v75so11121451oie.1 for ; Sat, 26 Mar 2022 06:29: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=a5VbL0aLAFbBvi7mnSV6DMzP+5DCyDQb6KaEjRaA8Sc=; b=t/wnCmSsPWixkZqh01op/f9tlACDvGRWYzrDg6QTXXiGRNVTMIuaAawuxuStGWix12 C5RH9fdh7EsQ2NNqFc6+ugp5gko0JrtNbPCnMkt229NNfCVRteDcDt/xbbFoUfBbfzjt KnG4s6G+qJkGJZ99UW/F1EwAnX4eIPY2N1lBV2bsjItG5y2koE4AyGVYFvjFQGESv2sT RwAHOC/e1+TnpImPadqPFEdcZ2nAgnXjRjIIaO1ZCRZZ0v12+JqcCS9Qao0P03uYvGEa 2fhSKvGcDTU9b7M9n8ADZvFlEF/BgO84okuhnEgNn9+Tn4Rbx9lw/bbLgoBPstsJtIb3 7iIg== 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=a5VbL0aLAFbBvi7mnSV6DMzP+5DCyDQb6KaEjRaA8Sc=; b=LuwsVd4JhjWwDD/0T2mOUlr+Rx2qyfVLWZKrXc+hLD+7RHIwcHKzPZUnRn8v2m1Zax B7U7qg1xiTd0cGquqTPZf/PPbDkwjgzuePqiZCuP1WykOOT4+lhh3JvQzV+uwSGOsJav g+yqJ8nFWNX7DpOxKapTY/08iXSxOUCT49OJ2Z61dNepWdg9e90UXR5Hg/VjgoHpB21C l9BqRbtBd/sMZDOVwhaXQLBGFg5poRXTc7lgiB7vVjScsiQfD4C1vetpyC8qJ2u1vRTh PYCs5Q2f1ve4MwdDjcjm+iRcIflBxfQBAyhK7BJ4rfprHxn29UPeXizC7541pagbTZmR iUig== X-Gm-Message-State: AOAM5334qNOUsZM6uGwXcWocZvWXjQA8ypHyZUxaIPwcrfAVDrOUk0EX qi9WRFSSX6PIkb//Kwo+TIz7fDxShEWfCpno X-Received: by 2002:a05:6808:14ca:b0:2da:2fbd:ebad with SMTP id f10-20020a05680814ca00b002da2fbdebadmr12102815oiw.24.1648301380533; Sat, 26 Mar 2022 06:29:40 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 33/39] util/log: Rename qemu_logfile to global_file Date: Sat, 26 Mar 2022 07:25:28 -0600 Message-Id: <20220326132534.543738-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22e.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rename to emphasize this is the file-scope global variable. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- util/log.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/util/log.c b/util/log.c index b3f79deb6c..425f0064b0 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_trylock(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; @@ -124,7 +124,7 @@ static bool 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; @@ -156,7 +156,7 @@ static bool 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; } @@ -179,7 +179,7 @@ static bool 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 true; } @@ -210,7 +210,7 @@ static bool 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); } return true; } From patchwork Sat Mar 26 13:25: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: 554390 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6457955mag; Sat, 26 Mar 2022 07:16:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTzbjsxf1k6klQJw3s5itf/13Cv3/Kp1foYUrK4XcvvR/ddDkViyeFcyaFXNtZjZZZA2xJ X-Received: by 2002:a05:622a:1808:b0:2e0:6d99:a782 with SMTP id t8-20020a05622a180800b002e06d99a782mr13943622qtc.406.1648304207220; Sat, 26 Mar 2022 07:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648304207; cv=none; d=google.com; s=arc-20160816; b=ah+YovwTD0s8w62vlBHGoLA/qEFeczitvGklqEViGdgqVLWN3lp7U43cm1H7Zod/yZ 2x+hPAr9o3rsJC7R1427bZ+IzD9lXig6VqHzK6XhBPQt+/1AyLYYX+XfzBJhtQ1Ci3ms ysYnhOBZZikpAokd6GHsD7xFb+TDTFM/XvYtceGuq1bSyW1Nrit3smtnkyQQ//839qEZ 0lHk8eI05msPm+F6awSUNOZ0u8alG2wmM4A/Cl9d0NpbzWneob86hvEqwgah+VYrV7t1 v1pEVUh0j89gfM+SMmKyNYPQU1A8pYdv3mN/Bmpn70nUXdeRCWHIh7C6nFEJWJ9c13T9 mjVw== 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=31e7uABinGNdcjY/s1pEdjv5HJDeYHfqF6kH7oc0qxw=; b=rlHSUnIJ7XCMsdf11OGVchKWyiYRCxUhezMA9Cv6JHn0NLsH2CFGORT6HupGMTwBrN Ai2Qy2GkkYoaBUjOMTQrOxycftsdbrc2eGrSh4nyUhr9nNFOjQASujsNUEcUvhOnLB6x Xb7FHZjzf5At1iBvkhUX3S3E+uu8nZCHytjyvAsnjnzjyi9ByqaD9WB9qvNrnhybYBFh 39/ps1dD/j7frhvI81RYLJAxKjjJia3Ts8PH8p0ypAVzRHkwpaSN8fAYxAfieu5xadj1 qvErmF1vVrZzwYr7KnArls32PNG1j+DdAl4oDiFjA4MN0crLUv4mGLAnvZ6Ic/xC5dEQ NK5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BIMpVWQu; 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 j184-20020a3787c1000000b0067e4be23ab6si2985328qkd.763.2022.03.26.07.16.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:16:47 -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=BIMpVWQu; 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]:53904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY7Di-0002p2-HD for patch@linaro.org; Sat, 26 Mar 2022 10:16:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6UB-0002sZ-RE for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:44 -0400 Received: from [2607:f8b0:4864:20::22b] (port=35702 helo=mail-oi1-x22b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6UA-0005yh-Ft for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:43 -0400 Received: by mail-oi1-x22b.google.com with SMTP id e4so11104319oif.2 for ; Sat, 26 Mar 2022 06:29: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=31e7uABinGNdcjY/s1pEdjv5HJDeYHfqF6kH7oc0qxw=; b=BIMpVWQukU8Pz45UwKC45D0tSbdN+9fkit1+duChgFwIlSy1BSvsunRjaF7IAc3vTg yBwuKpUDPd6DMy1IMmMfYqgakXWcC0ipKsQuXG2GWvxEJBTJA/rpFhnJbdYLW6eVyM40 hujFFz2muIsa9/DvAtvoWNQ92HbhtWJIu5C2sI7y9aA+5SPWbGdG2YZjTORfHjsxOF3K nwFRDFcryVI9UeqrCDUeHvBAeDXPBhOvvuIAln1Q9f5MAzO1QfHUU3xssh9TKH66IgU8 d3VGBh9ZvsDeNQC6UC1HaD2yr5iLkOtOAXgdY1gJJXJktMr74dT1V4vQaOYgx8YZiFhw qPRA== 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=31e7uABinGNdcjY/s1pEdjv5HJDeYHfqF6kH7oc0qxw=; b=3AuPV+ed8SWRfogBXwAKCOGywoiAzx3ml+WEQyUqKQiw6FP0X+5LZe2DAtcptl3IkI 4WS9BlPdUQiL/1DwJL+lrlAsgmr4lSiH6nUQs7NWXU7kt1LgupwW3hzRgfAYMJF8rZMg pYjEsagXD1oWwDxlLWT3ofsAlQGD3BJKgNxsOqM9vJQKRL2/dArb2dWT+495D6ajMfku 6quC4GcffDJKQjZKj+rglZYBfM7uJocBKH9pdmwzx5JF4IJqs3IpPVvOURw3PGLkpVjw VWudRMhUNypyKEcC3i5tsWzRW1kxlbyfgr7VVB8B/hOOja5kByUonMNpzh5XNduJFT8o kbEg== X-Gm-Message-State: AOAM53327aTvgc3j2yK2XqgNajnzxlYInN/yfHq7y3A1X87VMwQZMbiv /nUB8TsGEvamXG6c1C3Yu+A/d/QHkCoj30ex X-Received: by 2002:a05:6808:7c2:b0:2d9:cf1b:bb2f with SMTP id f2-20020a05680807c200b002d9cf1bbb2fmr7880225oij.287.1648301381553; Sat, 26 Mar 2022 06:29:41 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 34/39] util/log: Rename qemu_logfile_mutex to global_mutex Date: Sat, 26 Mar 2022 07:25:29 -0600 Message-Id: <20220326132534.543738-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.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 Reviewed-by: Alex Bennée --- util/log.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/util/log.c b/util/log.c index 425f0064b0..bb201664ac 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; @@ -101,9 +103,9 @@ void qemu_log(const char *fmt, ...) } } -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) @@ -123,7 +125,7 @@ static bool 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 Sat Mar 26 13:25:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554389 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6456233mag; Sat, 26 Mar 2022 07:14:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDhVa4zulMcefCOTw6pk/gFo9ojy0QTkV81/Lt90tC4hTxmKdLBwzvht7uC8ZIuT9iJ9lu X-Received: by 2002:a05:622a:507:b0:2e2:3401:49e3 with SMTP id l7-20020a05622a050700b002e2340149e3mr13847923qtx.560.1648304056215; Sat, 26 Mar 2022 07:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648304056; cv=none; d=google.com; s=arc-20160816; b=Gsfz8zz5MZDSbIX3V9yFyy4oZUKNRh2e+dw0LBbNb/NHjBYrXRHVeLmL3/TJlp32+q qzc4UqwpQz9r1Y04HfKLCMdnqKmsvvIBqCOAiDXHTyD+KGk61bs/d5WGkyKZBQ9oDVKS X85iWZgG7yKEtZb6E9GJ0qwxqm3wVqS+yL+Y2Sy2yVmdb99xuIbbyuQmkwbD8fyD4h58 PcqEDzzM0Fx/Kk/+GoBIgIrJVr5aSBxwTagTXXYlMwdyMxKHrjTk3hK68DgEfSEVPm54 SzvNc9DVEeS4nEMzIQ7J0mTj7gGPybVUgvQ3i1mxjHD00OvmZpYofJrvhRzZuWUjcYFi cTEA== 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=8IUyfSympPHVcXXqktu1H7rxzjIdvEh5QtmnECcsrkY=; b=gHzpAfqCp5zrl9KFw8WxXRJyk7UBYF+KhhCrZdhX8TR/M94F+DY2Dcr3tHknwzQbg+ NxITWpHfnTJRTwItxtR1WgOdlsFQryZu2/ZzH+4vNL2ye3A1gSWUcw0B1Y+OPXOKcTVd Hvtf52aM/KtxKrTxSRBUdtUNm2psvWIeUHEmnzxTtXOYo9tkaTteHyFf1jPJ/TcEMXaX 1AQXajP7pBBZaB8KrjSYBkD87yloGaIalBERU/HnF4sWap7uuPt3F1E7SFmaiSnx8i/0 p98nDLK6ykOjQhUA+08d27UG+4dhD/CYCzIFLLU1+214i70jNAXo709dpdbGVQV4jcni JbRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKlD8bVa; 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 t10-20020a05620a450a00b0067e4be238dcsi3950965qkp.289.2022.03.26.07.14.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:14:16 -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=IKlD8bVa; 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]:50462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY7BH-0000Ym-RA for patch@linaro.org; Sat, 26 Mar 2022 10:14:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6UD-0002uL-58 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:45 -0400 Received: from [2607:f8b0:4864:20::22a] (port=33767 helo=mail-oi1-x22a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6UB-0005yu-MU for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:44 -0400 Received: by mail-oi1-x22a.google.com with SMTP id k10so11121935oia.0 for ; Sat, 26 Mar 2022 06:29: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=8IUyfSympPHVcXXqktu1H7rxzjIdvEh5QtmnECcsrkY=; b=IKlD8bVa2Xe1puGxVnGrt5HiftufZ2/k0vjbvAfUVM8ff0BJmA+wnPVIVxz4OBrsmd 7LAy2v1kfhSSc40b9THPzYy8bXechskS+EpKDchFLL+XSgSSey2kFK4Yq77mmBSDbKO1 7NTMTXj6jJmUj/wWZko3+GuM6/JLXAgFZvhOSk2mXQSNB34Nzl3lSqBfZNwsAsNiFvDE UcMHtFFTKgzGVlP9X9kBYwUZOw0cTpFacO/v5jgkI57lvLWnHJAQBx40WHUsblE5OH3I SePoC4sf/P3eibo4ygpOU8MCrejIeNrWWCIUDmanjn/eP6rZanzPG1l2CKvfSL8netIp ok/g== 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=8IUyfSympPHVcXXqktu1H7rxzjIdvEh5QtmnECcsrkY=; b=FJiyzs+JeCGLH75y0CK+AzkPVZvO7z0w/IzuvX3xShVHshgjd9MD6rCL8EQHaZ21JO SDRBuvpy4Vbi/yEfOYeEN7QN2KcTFOE4ZdCu6oQM3KWw7mmfTNJyYIPNyETqrGsd+33X es7mAZ14GRmRgFGSPm9JEoOt1U9SI00zvx9yf4qVvAEDJeHj4zzqWCmqiu0iFJH+B/iH r7UA7AWp2JfUdiuYJ8dIl/3AWZ/7qZbZIdF9zLB5o+nqLY7rUEQR2RcJZPgIFYLbdMmL fKS7gCqV07Old2WPr6ZqgDs3KBrPY1MKnBDihHoNSPK4cLxan2nnGlEnSALldXtMiVfh 8EFw== X-Gm-Message-State: AOAM5304ELdRKg9+5g564Jj92YBrqkYBuNis6pglGWcSALLxrXmupOww 2k5VO7qmUfJY/5cDKKlsf1W+p5sEZy1mPjjx X-Received: by 2002:aca:b01:0:b0:2ee:bfb8:7312 with SMTP id 1-20020aca0b01000000b002eebfb87312mr7779732oil.22.1648301382714; Sat, 26 Mar 2022 06:29:42 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 35/39] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal Date: Sat, 26 Mar 2022 07:25:30 -0600 Message-Id: <20220326132534.543738-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22a.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- util/log.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/log.c b/util/log.c index bb201664ac..631856e231 100644 --- a/util/log.c +++ b/util/log.c @@ -123,6 +123,7 @@ static bool 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); @@ -178,7 +179,8 @@ static bool 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); @@ -196,7 +198,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, return false; } /* 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. */ @@ -204,7 +206,7 @@ static bool 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 Sat Mar 26 13:25: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: 554370 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6440266mag; Sat, 26 Mar 2022 06:54:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCc8RkBZCRyUgFkAp4qYBTmEOg5hVXcxWGwZUZQ5PstK2i0XhDajFy2MWoYCmY3VnC6xZj X-Received: by 2002:a05:620a:278d:b0:680:b3f0:3965 with SMTP id g13-20020a05620a278d00b00680b3f03965mr5331509qkp.713.1648302857669; Sat, 26 Mar 2022 06:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648302857; cv=none; d=google.com; s=arc-20160816; b=nSBFrGDTxxkBZphrqhHyxY2HzGu1D56czffZPVdXYhPNfkoqY4jPU6t3etpKyMbvaL AzWuzkgv2JnFKx2snBBGeGtN+fGwqB0KbDFzT87E8OE9qvBR7ROB9tZ3MPXKn20MewMm sWM4FhaMJuYoXBdABlfOsw8Lyxcc4YjQejRPA9uh7ggMHYxRU+LG8kLeRv15vK9BUkIg cXNgD4DCgup6UsNN2dk4QKEZE1oUROkcTcH0wxeS5PnakZdHfXtCJEAWq8035OhfPB1r sML7cmC+WwuWsrf2+kYQT2/2L4sYazytqwWYP83SfNdhslYt11iCuIWeghcm3oimsAG6 JQJQ== 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=go+GYnXGkWPQcv2j/hc2xPgBqJ1JmT544mDHf3z2u08=; b=V/xxIolGHSNwU0vI1owj48OZr1d3HV7ShShfOdIY/kVrpMDN/WB7JUVSrCBfp3ufmK D7TJ8Sp/qmEL0975KzA0DVZMa4P/XCSECdbNt4mMZ9ZMfOp9ZUSlU8ILfle+T/yJ1M5E x2jhDG9mXU+YN2YSkII3kqjm+PDd2b4rUr6gufn7b6bZK5kQ5jvInbB5X/PLAScsAvbJ 7Xs790sEXygQuHhjEcx1HIs689RA+nrwycqDT/8Q1QO2XIGoTLmC3azsj3CE49FI1CIf SDoKvTqrsRdHITlI0QcgRtWLjr2WbBSmZb6nqC/tLDJ+zfAfhHeDg9Hi8AcbVTL+zdb8 8irg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CCv+fh7Z; 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 x13-20020a0cda0d000000b00440e46a7cbbsi2994406qvj.345.2022.03.26.06.54.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:54:17 -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=CCv+fh7Z; 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]:59202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6rx-0001SX-6b for patch@linaro.org; Sat, 26 Mar 2022 09:54:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6UE-0002wP-7R for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:46 -0400 Received: from [2607:f8b0:4864:20::232] (port=46670 helo=mail-oi1-x232.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6UC-0005z6-RL for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:45 -0400 Received: by mail-oi1-x232.google.com with SMTP id b188so11067759oia.13 for ; Sat, 26 Mar 2022 06:29: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=go+GYnXGkWPQcv2j/hc2xPgBqJ1JmT544mDHf3z2u08=; b=CCv+fh7ZkpClVw+E0S4VVEZMtdFZr3mW+CJPCh2g7x3iI3TrxX46577jrrNa5W1qEp QVhZt1i07+mC4iCBRO9Wg27AFmel5m32WfR6Rf8jnQy/blT0bOgU9hfkhS8KxmP2pnr3 G8VhwPFrtCHAvWwQ3nirKhe3GLd3Epi0tAC+eUBX6vpSiYK5JU3yCYz8r5cKxD3/B1b9 Ky8mJ0qmwUdA2hOk2Ty/SsfscCoZQB48//8/BCAAyXv+gdapB8rlqYM+HZfR5N15M6US SmmC/HTkkQup3Hbux0E5vxrZu0W1oC/tuAJpe9DR4Y1x4557Bx/iLcnj3L0by+Ow0Ff0 MdeA== 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=go+GYnXGkWPQcv2j/hc2xPgBqJ1JmT544mDHf3z2u08=; b=yfX8rYkFLH6Jwogh2lOf7McKsYToXWFR75/zcREkriD5ykHFpChPCBu/QWiADvg3qc +hkkSvPLKGiliatfsxy/Kkk7EXdx4fRDt5spfxPcXll1GCufp+QvrsoQ8UCMauXSf+dx vTBm5/Yj/M/gXmaw3PjUNNpc9cjiaxAfeYNlN1nanZZrSOjRABg4zXZqwmH5IoooOsQN lGuIKo3t0c4eDS112SetscgccWt4OetLVqA47Ub9VL6XwtbkOoMRzo9fsuFAT2pubYJR 5KLxZyfGWKBUH+E6LSj1+gQBa+rI5i2v+HlABfjv3gM99KNQfN4vcXmiCBNDHGlt1+sX exmw== X-Gm-Message-State: AOAM5338BDzayLJzjrnFI2oTjb/EMADfpQb6QZZwVfQMk8OCggs9Dj1r nbUMpe5Su4xc27ouOV0zImWSRaM6cVAHcrp2 X-Received: by 2002:a05:6808:11cd:b0:2d9:a01a:4bc6 with SMTP id p13-20020a05680811cd00b002d9a01a4bc6mr8176506oiv.237.1648301383855; Sat, 26 Mar 2022 06:29:43 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 36/39] util/log: Combine two logfile closes Date: Sat, 26 Mar 2022 07:25:31 -0600 Message-Id: <20220326132534.543738-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::232 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x232.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 Reviewed-by: Alex Bennée --- util/log.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/util/log.c b/util/log.c index 631856e231..21da961d8d 100644 --- a/util/log.c +++ b/util/log.c @@ -157,12 +157,6 @@ static bool 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; } @@ -182,11 +176,12 @@ static bool 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 true; + logfile = NULL; } + if (!logfile && need_to_open_file) { FILE *fd; From patchwork Sat Mar 26 13:25:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554392 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6459729mag; Sat, 26 Mar 2022 07:18:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWv7sAwxutwNvZquYE4DK3zHf+cPpuFv80PGw/QXkh8kFYGp5+5VuLxZi8FaLRUCUhX6Wm X-Received: by 2002:a05:622a:508:b0:2e1:deae:22bd with SMTP id l8-20020a05622a050800b002e1deae22bdmr13721988qtx.597.1648304336560; Sat, 26 Mar 2022 07:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648304336; cv=none; d=google.com; s=arc-20160816; b=ttsJErWJk885k9U0BtuwS39S3MfpyA2+q7pxTJefu79qKBhzBWL69Zrdf15CwKB0Gu jaYHWzPLvtmCARAtvMbUG0baGeIDKu2l4C+Xx8+qf3UV9LA1+wpTnFsDcuAXk0NEmQbv Fs7MwslS6En/jSi9ts80EUE8NHgZHEexnLkhH6bhbTn4lirCK1FGOdifiPoznmzD0rfS 5gmZX7vZckI2veOM4fuU5ooemIkiT8lL1RkT1QZo98PPSmHhHcyuUoYJXtt2NaADYj/O ZLXqjS6lg6jxTAZWmFRKXXncxi84PO4Xjw6bDTeYl+eWUW6GMDomfNBsNw6UYGXpm0wW otUA== 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=7gCOVHpiUyMRDpJzcLkdT+SsxIqZ0YBDWLphLP/PUG0=; b=uyI/ux+QXEmKVup0uC+baInQvE6v5SSeclN0ladAafZQ3nOU6UGjjeyGj3MfuVAVbo hlmZ11Niz1nEj7mUpQMy0ipQwlvYkhFJLKPyvZfDTgGP8VjT9MAI9KbFQfdrECTTxJk7 NgWhCwr8oGEf0/tmVM0SWC7wtY/boK++ZAEJaTo77FkEJozzJ3Hc3/+XcUphkLu1nLTi AZiHuWdUyB033NcozSBL0bc9uw3of/9qAIprOY3mCSAfJLOi2t6uUrrb63Ex+NYlDPMQ FaiaKrsxTv4X3nW8y5u6i/uLBZd4d5na4u79wtmnfK3ccGacIxTVG19a+rSC8k7/+TxE ik7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=peStyffk; 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 c29-20020ac8009d000000b002e1fbf3bf4esi3557684qtg.319.2022.03.26.07.18.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:18:56 -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=peStyffk; 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]:60268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY7Fo-0007EA-5l for patch@linaro.org; Sat, 26 Mar 2022 10:18:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6UF-0002yS-GT for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:49 -0400 Received: from [2607:f8b0:4864:20::22c] (port=33769 helo=mail-oi1-x22c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6UD-0005zH-VU for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:47 -0400 Received: by mail-oi1-x22c.google.com with SMTP id k10so11121997oia.0 for ; Sat, 26 Mar 2022 06:29: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=7gCOVHpiUyMRDpJzcLkdT+SsxIqZ0YBDWLphLP/PUG0=; b=peStyffkPKLqPkMkPjdm7qjkhZ7J5paLvW4tPuX1EREkbJUD+JMsMPFc+S2ENBlV52 TZCuTfPo+s7u2d8vlTtuVKQzgmxibuX1Ma6i2nk3Ss9PaBzfr6gJXsKkqRZyx+ssWWDw kZb23B3o851ZuDV1aiA9dHwzh3I2O9o5zYnRHPTqDee/yo9S6+DyZ0LNFF230dmGhAwL 8jggsj3d7FxWAqwVBaiyhZANgyu/NX7rZcrEurcjgEApDCFrgmmhf/SRATxhheoX2vAP AqJljjcKTZl/SkKp4dc9EpTRY+9kpJup9Bb2BORF8Zvtnp+ZDVceHpbVIpgcRLZRSR7o L2xA== 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=7gCOVHpiUyMRDpJzcLkdT+SsxIqZ0YBDWLphLP/PUG0=; b=YnDMs+x04XLFYeAuJobb8J7kJH4JrhY6SeRxtnXY51BC1ejdPb+fEwAr0gS1nM5oLz p1pRwnVrQ7bSz04XwYzoayzPYs9e3mlpg2rh6nJuAxj6RaWz8sbHtszKUGmWgYRcwIdd xSp0aDc86ld2Bq5TJrzmwNkzHPqWpZ2wPwqPvaf5uZuEPqwO0WGVLA+n8nm/3C0Xz3c5 fGvOJ9Gn2qgiIFwnH15UhxE/xXUgeBvcs0SBmhzNT9luysuC8obO7CDKmwm0n0dClzxF HgHKDR3NJDc8K2algOf7K6wOUxemXQg8XHTP7dkDix8fuZ3UOwAu4lFIWv6OrLIzkyoU Yw4g== X-Gm-Message-State: AOAM5319VoWEL0Xa+Cp2nTDjYv+aAi/DwYPr1gNvEWxVPHyfFnpBvSdl bW/J6100pkdB+JZTsx+0dc61peW7EjBw4442 X-Received: by 2002:aca:aa55:0:b0:2ee:e8e8:cf80 with SMTP id t82-20020acaaa55000000b002eee8e8cf80mr12641473oie.64.1648301384947; Sat, 26 Mar 2022 06:29:44 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 37/39] util/log: Rename QemuLogFile to RCUCloseFILE Date: Sat, 26 Mar 2022 07:25:32 -0600 Message-Id: <20220326132534.543738-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22c; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22c.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- util/log.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/util/log.c b/util/log.c index 21da961d8d..eb6e85b2f0 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_trylock(void) { - QemuLogFile *logfile; + RCUCloseFILE *logfile; rcu_read_lock(); logfile = qatomic_rcu_read(&global_file); @@ -108,14 +108,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 */ @@ -124,7 +122,7 @@ static bool 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; @@ -178,7 +176,7 @@ static bool 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; } @@ -196,7 +194,7 @@ static bool 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 { @@ -207,7 +205,7 @@ static bool 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 Sat Mar 26 13:25: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: 554373 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6442807mag; Sat, 26 Mar 2022 06:58:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk7P2t1EIRi5aEMc0NLpU5L4pNO/LZN3cvnDubWlBsHo97Vmn7Stx3f8E9gdvvvquHpFrp X-Received: by 2002:a05:622a:8b:b0:2e0:75f0:c18d with SMTP id o11-20020a05622a008b00b002e075f0c18dmr14101261qtw.488.1648303100744; Sat, 26 Mar 2022 06:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303100; cv=none; d=google.com; s=arc-20160816; b=U3ZhRLXoe0kFCkdi+vxzVrIi9tPd4E65YmjudtDugY21WvIqY01bXikkh6a76oeZqO PQIGcftgEZHobBWXFO4Up1mr33nTJGA/354gtcAVxNkVPlWxw4kRFrzJbCyeTY8vYeh4 dvvkyLLrYcbr23SFw08ZzxhUPutPCdgpPLpfv8jswdOBTnlofcx1FJfrj16uuLevctfi 6Lh4s87u/EqKSKj7tZ8Qe4GYtNofy2jr+kElzG+iR1Xhgqzq3rzob7uJ8rNOiRFnirDi XoPn0V6ZE0vEBPtsps75cG98fQ4LPPolUwcK8EU3xcRCaCtSLDPhORivdswMlpmA4oNK WiEQ== 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=aXHC8lLdzIN7Te/CRAft3NVYbrUQIuuG52xMXpJ9gWU=; b=ylzqfj/ocHQKrf5hjG57k+baj74FIHya+H70bvjAXX0aeq0yu0OjtCUdx+4AmEV8+h WUK9a4FFPtlvqdWkSvesDhGpnxmS7UiDdbt//4AS7cyOQ/J53b0ah7nnJon3zGHWfhSP Lf1nH36N42fZ7Y+2bu3P6gzykJWnY4dgU6tEQrT7pIK4RJ/vLOD+9uKv04zfPLBAenmX UBbY5GgbUV/ZnASXawPdZC246sCdOC7jfkIcLVj+t9vW9Hv6YZtekkIEv/hdEu/7/wDn ub/ulmX3TXPBAzJNxq39B1oIFarVcyQc+wNgBuhvG5hljmHRBBNYJE7bBAtSy03wwzvF 6dlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lunsatfu; 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 by1-20020a05621405a100b00440e46a7b7asi3372019qvb.24.2022.03.26.06.58.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 06:58: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=Lunsatfu; 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]:39402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY6vs-0007UY-8x for patch@linaro.org; Sat, 26 Mar 2022 09:58:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6UG-0002yt-Ev for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:49 -0400 Received: from [2001:4860:4864:20::2b] (port=43761 helo=mail-oa1-x2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6UE-0005zS-TC for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:48 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-de2cb87f6aso10708639fac.10 for ; Sat, 26 Mar 2022 06:29: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=aXHC8lLdzIN7Te/CRAft3NVYbrUQIuuG52xMXpJ9gWU=; b=LunsatfujAtg43ZGgevckQNX/CqHKuYL6aBGWGKcvEyz+MoX5JaM7kUf+WTkIj5gx2 PE55uFgHMsL81mjt34cdgzxKJobhvCrDo0qUwjDMdPXG+MHW+gkVQintXOCF4eM7X8Rx VE/WJ84uGfAtPG92LUqP2+P59n33MgcyKIy45jfQn02ITZMQ6/BiEtbE79uorvH1r7CV naxJDtz78LKu+ksFWSWB5T7AeULZ++LgEfw3hkOKnbpoil6yarqW0KbhRcci1VsP1fI/ /oLHLAOqhjjZqvAWbta8A0tInF191bcnOva7lT03gawAWwJt9sjzDExj1lFMh0Sqo6r7 w5Bg== 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=aXHC8lLdzIN7Te/CRAft3NVYbrUQIuuG52xMXpJ9gWU=; b=5aH8eP0frvlQytiAA8Vgoe0z69PJ0EW6NxJufK8egGDpdqbimf7rlezH9PP9hla2cg SSy9ZVXvnOqFvNHjwvR0e4T4EwrMfRaUITgNW6MBSV/pxxV/9IKrkkauCSvDnyLKuCeK aMZGyYaIHxa/OgC4Cs5IyobHcwFnGFMgJfVfyYs8f8WE48wVlwx/Fy1ORvNOzNLoPUmS YXALvbQw84bwrj9WOZcSipnxyLx0JsGhl3ARmU3+JsqVhaA3Rh3xt9cNv1CFcypFj5ps Uu99ZzmESL7dpMWWOeEvTnXGYTZJgzGP45ObcBAfweYliygT0/aI4bJUpahYBImwhVTX zkrg== X-Gm-Message-State: AOAM532dYJ8F+xjm3PEkFenP54FkRlBXNPIacp2wmZGM2BSVTdSBINpe 82N26aQ99063HfAs0NxPSyMF5tV4LZ2KrB2m X-Received: by 2002:a05:6871:28b:b0:de:282:34ef with SMTP id i11-20020a056871028b00b000de028234efmr7076648oae.287.1648301385957; Sat, 26 Mar 2022 06:29:45 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 38/39] util/log: Limit RCUCloseFILE to file closing Date: Sat, 26 Mar 2022 07:25:33 -0600 Message-Id: <20220326132534.543738-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2b (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2b.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, 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 Reviewed-by: Alex Bennée --- v2: Work around problem with qatomic_rcu_read vs struct _IO_FILE on musl. --- util/log.c | 68 +++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/util/log.c b/util/log.c index eb6e85b2f0..df0710720f 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,44 @@ 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_trylock(void) { - RCUCloseFILE *logfile; + FILE *logfile; rcu_read_lock(); - logfile = qatomic_rcu_read(&global_file); + /* + * FIXME: typeof_strip_qual, as used by qatomic_rcu_read, + * does not work with pointers to undefined structures, + * such as we have with struct _IO_FILE and musl libc. + * Since all we want is a read of a pointer, cast to void**, + * which does work with typeof_strip_qual. + */ + logfile = qatomic_rcu_read((void **)&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(); } } @@ -110,9 +108,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); } @@ -122,7 +118,7 @@ static bool 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; @@ -176,37 +172,37 @@ static bool 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 false; } /* 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); } return true; From patchwork Sat Mar 26 13:25:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554391 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6459147mag; Sat, 26 Mar 2022 07:18:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdlCeugjFuwNXOEYCZQFBon0HVP4DdRQILyjjExzKmQv0yNJXv8z4xe8cNnbhfyJTAdBtm X-Received: by 2002:ac8:7d0a:0:b0:2e1:f657:a382 with SMTP id g10-20020ac87d0a000000b002e1f657a382mr13774694qtb.583.1648304290172; Sat, 26 Mar 2022 07:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648304290; cv=none; d=google.com; s=arc-20160816; b=kDIFtpQVTPkqOsByXTHkcTgmIrNTLGd8kcQ+oLUFajq5svSYVLv6k4MXuvA7dqiXe7 qadRcsKyQNRb6kB4nNoMSr56AyJUSxh8WO2q5nV2H57ZVkkjX2ydSqesHhr+7KTIJwVr L3h70rhoLsUGnOrJgCQDNaKrurMUZT8mSGTlTdlCITc1OUMlk/c4NAOendRCZ/Y4UaEq DXlCd6vd2wtpN2P/nVcc8AcMKjBavzfn4o6bVvhx6vKZEAkwjEkRSR5wUjARUrreLY++ MOwcLK23q1mDBVy5XcMZzACyUVeFok/wweu4F8b7veyMs12LVAHfhuGbaYFCysFq7fVq Yz5g== 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=kcCuxlkVT075lpymlA6JruiT9pScLcSGcIoU5KgWuJw=; b=bBwCMT+kFNTi4nwyUzXFFPFX/6L25Xx3qlYnu2IpWBrSTrsPhsRXVBu5y9vdmTfmRc iMS8ZJVihrurWyFr/1JlTBtJa+Me4OHLEC262Sanp7CPFZIu8xVXSPXhJgZnQRK/6YBk wMcjajPIviuBAtDEkv4Ozmonb8+jzopmYnCEJb7tswKNtBLghAL3WxTukkobbmpL1H/O GlMPpWlrgKWw00o8fn3EIbCw5W0qFXDlIfYZ+N4NEui60pIfCvV2U5mzIqJ8EKay3OZx oN42LI/0HyF2oYhJlOOSa13GQKYA+0kBtunQXwRvQa9giAmnqCkblQMEeHV8+rhZBHdG v6SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u4ZSZkxs; 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 c5-20020ac80085000000b002e1fbf3bfacsi2642449qtg.413.2022.03.26.07.18.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:18: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=u4ZSZkxs; 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]:56940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY7F3-0004yj-Me for patch@linaro.org; Sat, 26 Mar 2022 10:18:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6UI-00030M-DE for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:51 -0400 Received: from [2001:4860:4864:20::2d] (port=32816 helo=mail-oa1-x2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6UF-0005zb-Vy for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:49 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-de3eda6b5dso10779801fac.0 for ; Sat, 26 Mar 2022 06:29: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=kcCuxlkVT075lpymlA6JruiT9pScLcSGcIoU5KgWuJw=; b=u4ZSZkxsqAG1mYUX8YiHStfuMI9U7Bs+FMvrw/WlD5GAzWOp+5Q05v426CuKBZcyfJ uFl546MqcuAzz+eezB/HN5Y5Qfh0xGJUIdIYE/TGgcam8ncXXTGHeGlZO7sRShw9XZSR pBD43dnXthI9QrdRhz9fjeBPTFB9jTr18j7X2aaKC+5h2WRZ1Ca/LveXukY2liQ/aWQj dWdNtix2Dme7B/8Ld8jCPvcJEMuKNQ1v8Hb3vtkxUGdNjt257YBelC4yMt0tdOZJBzk0 lPwnN6S+nclZVNemy2nTSQcGniG6DA6EgvWpq+Dk5fhjeGOrpBENv1Gra7ewHXzzZvQE v8YA== 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=kcCuxlkVT075lpymlA6JruiT9pScLcSGcIoU5KgWuJw=; b=CkS3n6A4+2tuNtCoZAg3urOqsjeCmHsQbxTD2GGXfwGsi7Rm4o2ULIVtgDpg6W5aU8 HU6vW0PNuKIo+Ugj8Wejmi2HiqeZy6/Sx5giQkzt07wb03HPP0d/iXwfzYvhx023wvUP 1AvuNIt/97Px4MjxvPGCxjpH/lkGw9G1Dg9cTWTO0F+H29K+pZzHfPUm7wCS7kp6d0SJ yjFaTGgbRGBPwt9K325OI9SAD9BYjfbMtpK5vQrfi+7VKoCDxk7n+Mub6mSEeH1tRFyg SnTxAZOrk42zrSolod7YZwuliFomWJ+Wd5oOIvtVNu1ww1XAtYjfTvnH46/DL4dsRSI7 nUAw== X-Gm-Message-State: AOAM532KIk3Kz4RUeThFP0XXIsDLsRLDNoApKMKQ7aaCEvX3M5F2GpEI mQcy2NQ4ahnqTQDjsJ0dX91CGVAx8/ZO4j7/ X-Received: by 2002:a05:6870:6108:b0:dd:ca26:f135 with SMTP id s8-20020a056870610800b000ddca26f135mr6978707oae.22.1648301386934; Sat, 26 Mar 2022 06:29:46 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 39/39] util/log: Support per-thread log files Date: Sat, 26 Mar 2022 07:25:34 -0600 Message-Id: <20220326132534.543738-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:4860:4864:20::2d (failed) Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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, 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 Reviewed-by: Alex Bennée --- v2: Make use of CONFIG_GETTID, and fallback to SYS_gettid. --- include/qemu/log.h | 1 + util/log.c | 149 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 115 insertions(+), 35 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index a325bca661..c5643d8dd5 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 df0710720f..0bb2233788 100644 --- a/util/log.c +++ b/util/log.c @@ -27,6 +27,9 @@ #include "qemu/thread.h" #include "qemu/lockable.h" #include "qemu/rcu.h" +#ifdef CONFIG_LINUX +#include +#endif typedef struct RCUCloseFILE { @@ -38,22 +41,36 @@ 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 CONFIG_GETTID + return gettid(); +#elif defined(SYS_gettid) + return syscall(SYS_gettid); +#else + static int counter; + return qatomic_fetch_inc(&counter); +#endif } /* Lock/unlock output. */ @@ -62,20 +79,34 @@ FILE *qemu_log_trylock(void) { FILE *logfile; - rcu_read_lock(); - /* - * FIXME: typeof_strip_qual, as used by qatomic_rcu_read, - * does not work with pointers to undefined structures, - * such as we have with struct _IO_FILE and musl libc. - * Since all we want is a read of a pointer, cast to void**, - * which does work with typeof_strip_qual. - */ - logfile = qatomic_rcu_read((void **)&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(); + /* + * FIXME: typeof_strip_qual, as used by qatomic_rcu_read, + * does not work with pointers to undefined structures, + * such as we have with struct _IO_FILE and musl libc. + * Since all we want is a read of a pointer, cast to void**, + * which does work with typeof_strip_qual. + */ + logfile = qatomic_rcu_read((void **)&global_file); + if (!logfile) { + rcu_read_unlock(); + return NULL; + } + } } + + qemu_flockfile(logfile); return logfile; } @@ -84,7 +115,9 @@ void qemu_log_unlock(FILE *logfile) if (logfile) { fflush(logfile); qemu_funlockfile(logfile); - rcu_read_unlock(); + if (!log_per_thread) { + rcu_read_unlock(); + } } } @@ -112,40 +145,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 bool 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 false; + } - 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 false; - } - newname = g_strdup_printf(filename, getpid()); - } else { - newname = g_strdup(filename); - } + switch (valid_filename_template(filename, per_thread, errp)) { + case 0: + return false; /* 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); @@ -153,8 +220,17 @@ static bool 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 false; /* 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 @@ -163,12 +239,13 @@ static bool 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); @@ -354,6 +431,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 }, };