From patchwork Sun Mar 20 17:11:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553184 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp878470mag; Sun, 20 Mar 2022 10:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw374YongKiGJV4cYahzuhPSvgD0MSbZmuPWbtYiCxsYd+4PTSpmkmZJOaxGdtuEgt8dGUc X-Received: by 2002:a05:622a:1788:b0:2e1:cdb8:41f8 with SMTP id s8-20020a05622a178800b002e1cdb841f8mr13814230qtk.499.1647796922906; Sun, 20 Mar 2022 10:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796922; cv=none; d=google.com; s=arc-20160816; b=dGsegDNV2DTMLFGeOdMUcgGVazBf5pRF4XaK3mN/dODJEAtPwUG6mZv8GWxBYZeOe6 DQkCz9BTbi5U9C1cPxwGJ49R/8NlUIqUUjKepR03TkuY+dNcl2JN/IM4RAdptqHndRGw AC7UhlfHV4m4uAvc/ORGqFlVtxskcHJ6XUFp/qJ+SeLGCR8V34l7WgJ9nx9tCRutsBk/ TEOh7OZfMjJvEpB5yr+4JkZDYWZh5zpWavHb1OHMjyvTNA1cnR1AazV46jwxtxUuAeqQ dwRmSmgdoKxP0eU0o88sF8zK/vU9b9k4mH//uN62/CWjn5SQOGN1vx1XRcEtf2wSWwxs kMww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=J1dSl4TTW2l9haojZKtDE3xV0KCAHP/jmJTof7woW9Y=; b=WVGC9pOx6pvaoxGo5OczxxP7EKayxhp0k5PSuWtcGcgqQ4aF+1nAGd2OLEEuxWuRh4 AqnR8GCfgBKVkrPst/j/oCoHAb9DNdTzONcD7tO8lJ1mQIkkvBEo9jKNie+Lb13hHMzc 1E1KIqCiqDWr7z8LTVcCKHAczJVWKhR80+4X9QICaK9uMvSPLQRsnCYkNOPNifHrHJCn /TGJTuRm6AaJlDlgdHLQMqo9UeSsg0Ouyx8svmJkiu4IflETxA5CYm/g73zn2FxhBqBl +Ixn9MqFJDlZKEqWo7vOMRWHMMOvC8fbb/IWAzUPy6h8YNpn0fjSI5gprW4F4fzGqGCN wN3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G3Zx6dmW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w23-20020a05620a129700b0067e4be239f5si1244557qki.570.2022.03.20.10.22.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:22:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G3Zx6dmW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzFi-00035u-Dw for patch@linaro.org; Sun, 20 Mar 2022 13:22:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5n-0008Lk-IF for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:47 -0400 Received: from [2607:f8b0:4864:20::532] (port=35759 helo=mail-pg1-x532.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5l-0003Qn-K0 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:46 -0400 Received: by mail-pg1-x532.google.com with SMTP id e6so8737180pgn.2 for ; Sun, 20 Mar 2022 10:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J1dSl4TTW2l9haojZKtDE3xV0KCAHP/jmJTof7woW9Y=; b=G3Zx6dmWTDj3rdH7H5Zzsiei+VsMlRBdn5ump6JYSnDHw7m/W6ssIub/PxMwr20Zud yhJbqbnvQXxy0GyosxouG3qihWKYvoBPDMZPar/MGV2KJpty9jJUMzQbSVhuk7WL8jHW SIYRI+bc6qjcszOSKGah1fKXvwL9oEy5CUaYFg+MkSqhopNKoMsmKkmJFSbx+g5dhKZq o+0S0PehzgYmtYeSpvUuOpF/a8b4i6f2KDczyj1hE5Pa8BVmMVdxU7/PZ4N3u4AKZ1oc QVfCsgilgH9C+dDh9pC1cBaJ6OdYh8AhKjy1tEXwSAegoyCqCZuBtPRniVPQLqDj+yM8 9KEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J1dSl4TTW2l9haojZKtDE3xV0KCAHP/jmJTof7woW9Y=; b=qh5MvREFmkFuUrt80a6DH+8IOcnjfXctbm0PpX8VRQRrido/RkeUGVwliNxe/fWS3S ZIQ9BNn2Bv+qJ8AcvrJkocB71dA2VQ6mJnWmxOj3ni14wTZCX2QOG/tfyIA94Y4MpTzU 8ty//Iv7LzgUYf7KyyQYXXLCIqDojQnxBQGsQebI5XmWz+CVNQgO0pb1Rg8xBM5U8o1/ cOs+ppyZ/39/gh8UAqA2ckOdCAvjKLZvKWrbcf6QOu1WJr7AwblJwSNF4x8/8e+N6NLR hg64NNRed+UOJwmdw6JrE2/hlfQ1i6WtQBBm+Sj+5f27tvKucxarUPxrP6vzBNxdJsyT 4QOg== X-Gm-Message-State: AOAM532IDG/ifR0wyeYJGMkCjUMEZDuqPiZjqYBJ9f2c8zIii37iTDfD dk+pmX2yU1FcgTge3f5+bCHVU2LZWGAQYA== X-Received: by 2002:a63:4766:0:b0:382:6cc2:c0d3 with SMTP id w38-20020a634766000000b003826cc2c0d3mr3234343pgk.6.1647796303299; Sun, 20 Mar 2022 10:11:43 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id q12-20020a17090aa00c00b001bc6f1baaaesm17149697pjp.39.2022.03.20.10.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 07/36] hw/xen: Split out xen_pv_output_msg Date: Sun, 20 Mar 2022 10:11:06 -0700 Message-Id: <20220320171135.2704502-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220320171135.2704502-1-richard.henderson@linaro.org> References: <20220320171135.2704502-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::532 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not replicate the individual logging statements. Use qemu_log_lock/unlock instead of qemu_log directly. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- hw/xen/xen_pvdev.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index 8ab458922a..355bbda60d 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -196,34 +196,38 @@ const char *xenbus_strstate(enum xenbus_state state) * 2 == noisy debug messages (logfile only). * 3 == will flood your log (logfile only). */ +static void xen_pv_output_msg(struct XenLegacyDevice *xendev, + FILE *f, const char *fmt, va_list args) +{ + if (xendev) { + fprintf(f, "xen be: %s: ", xendev->name); + } else { + fprintf(f, "xen be core: "); + } + vfprintf(f, fmt, args); +} + void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level, const char *fmt, ...) { + FILE *logfile; va_list args; - if (xendev) { - if (msg_level > xendev->debug) { - return; - } - qemu_log("xen be: %s: ", xendev->name); - if (msg_level == 0) { - fprintf(stderr, "xen be: %s: ", xendev->name); - } - } else { - if (msg_level > debug) { - return; - } - qemu_log("xen be core: "); - if (msg_level == 0) { - fprintf(stderr, "xen be core: "); - } + if (msg_level > (xendev ? xendev->debug : debug)) { + return; } - va_start(args, fmt); - qemu_log_vprintf(fmt, args); - va_end(args); + + logfile = qemu_log_lock(); + if (logfile) { + va_start(args, fmt); + xen_pv_output_msg(xendev, logfile, fmt, args); + va_end(args); + qemu_log_unlock(logfile); + } + if (msg_level == 0) { va_start(args, fmt); - vfprintf(stderr, fmt, args); + xen_pv_output_msg(xendev, stderr, fmt, args); va_end(args); } qemu_log_flush();