From patchwork Wed Apr 20 18:05:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563976 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4403775map; Wed, 20 Apr 2022 11:14:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQsDga1XKR5qCkfKhvL7+2LRDujnYWsLV+mqe72yOLiEr6m0nN9tZPUdsvZ1DUeoB/3tIi X-Received: by 2002:a25:9e81:0:b0:624:3b8a:514b with SMTP id p1-20020a259e81000000b006243b8a514bmr21313754ybq.266.1650478476640; Wed, 20 Apr 2022 11:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478476; cv=none; d=google.com; s=arc-20160816; b=Vuqiwqy4Pp58kNs0rUlDv96bCP43oHEqcz4xMrxD+8UP9QUnn0r9V3my1F0y/6C2me fJ6e0KNkkk4VpRoZ6FE9q/sKI49rcI4C8bbwW0FLtH/5k+HDcO6mosfn7NgDCFdlKEFX nRDThfBm9aH6/r61nguFaC7ioZtGAUHb92ecWIudtmNUIMWr7ZUr1QIM6FYcGdhOHCaC 7qj9tM4JS3gefbubflEmaK9JvKmmMCs9/acxfT2cH0acA7DOKtgujlUXCZazuuLJPocr Lp4OCLwSqQu6Nlltv1a/vDNZATjxqgKwNA+UkCXaEpIYFBpwm652z0Nfs2/h3QCxOwjb uITQ== 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=/7lsVTmyGDucjIzypVl9G9xgzg0WOWvjikiRtOmHVOc=; b=Nh+1jwA5zeX0+umPj8hQD/gguIJzX4kOGUbjQKDQhGZ6CPAeMWiErdhd3UmZh6oI4I Z7JB3/+26/n9TG8Ixs/ZXp2wm5BUXrwlFQ3QKD7NyLEcqQCzyuOa0ahSMCs7UZ8PCUyK iRbksd0wvMYXfXfrbLfzLykvqQgh74r3m9nI8PMor2MdIc0L5bgtOQyCmFlHBjYKtfYR wMMruwEnYLHjz+kow38hO4fTuaKZgPl3agDm2YLP2OswBiTqSbYPJtZYzp+k0j9uXZp5 L/ZEFytYkIsa268f4FXpS1J5E54L7iH9l3YvyqNdwpgJayCtcBGqlWmzMIPE25xBpQIZ 7bgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ySJ+ZUil; 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 e132-20020a251e8a000000b00641408b2069si637439ybe.297.2022.04.20.11.14.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:14:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ySJ+ZUil; 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]:47894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEqa-00051t-4Z for patch@linaro.org; Wed, 20 Apr 2022 14:14:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEil-0005M9-N2 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:31 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:51785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEij-0001Bm-VC for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:31 -0400 Received: by mail-pj1-x1031.google.com with SMTP id bg24so2681555pjb.1 for ; Wed, 20 Apr 2022 11:06:28 -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=/7lsVTmyGDucjIzypVl9G9xgzg0WOWvjikiRtOmHVOc=; b=ySJ+ZUilQ47RcPjl8V2CyNsUKb9kZZaJXdkWEjy+aYGBBQ6OvWSHWBjm4Z4JDHQ0Rs deb/KDcNbfOr7UPrOsota38sByvRIlJTKiIYr5J+XTZzBXxYyNgGqM9Wsk2qHi+21DuH 19vUBkEBikELxwSZLYkmAwzpyitPAdcI9p2jI02UQ3ds2j2XKF98uSgRuT0fXzPxvUWe Lz0QiGNxFdqXA4DDaQNaEdH2ypXDZLpPeTTrVbcbLGQyXw/+iXy1a6Nk9IXEJouFejLW ftOdX+DmQ0DrA8YA52Fa0xf+4PqJCIKI+cHkIs1Euhp1XN0OPWyohqE1SMXbNiA6OmOW P9+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=/7lsVTmyGDucjIzypVl9G9xgzg0WOWvjikiRtOmHVOc=; b=vMU+7uFfhFL1c6GWIxoPFKBs8wBq4FVNFeQ8NjFjLGkKLU/ilI7GmsXrBJlsoL4clS ata/4gp+SiRsCCmp9bNhTGopWWtjxw5/O2VUA341b4Kz5zeJOykR3HpEgwxjPpKn0fR9 gATLpRmKdcTRyXfkvNobwgu5St6yPvWjl7fLhS7ibJo7sUX0zhvv7rhmKf7HRGkkwqNJ 50rlfSAd0ATmejFmUmraESYOfBmKsfZcZ5cAJ+2vHCzk+Q4LUp/OMXi4G7WNSN+mbewf 8G+BbJEfUv2AE2O4S2Va/Ms4ofdQ2n2ABySz1TyfQbjdPzAw+qZeXpSxP2q/8XXWm4MZ 3enQ== X-Gm-Message-State: AOAM533CWKUBEWQkygXk6OBbUVujDGJG2xacXnIoW7VAoAen12k5mFlb 32hoKwK27uMmevA+nW354WlnKz3xEt1Grw== X-Received: by 2002:a17:902:7298:b0:158:3a08:3163 with SMTP id d24-20020a170902729800b001583a083163mr21475596pll.133.1650477987924; Wed, 20 Apr 2022 11:06:27 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/39] hw/xen: Split out xen_pv_output_msg Date: Wed, 20 Apr 2022 11:05:47 -0700 Message-Id: <20220420180618.1183855-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= 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 Message-Id: <20220417183019.755276-9-richard.henderson@linaro.org> --- 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();