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();