[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 08/39] hw/xen: Split out xen_pv_output_msg
From: |
Richard Henderson |
Subject: |
[PATCH v2 08/39] hw/xen: Split out xen_pv_output_msg |
Date: |
Sat, 26 Mar 2022 07:25:02 -0600 |
Do not replicate the individual logging statements.
Use qemu_log_trylock/unlock instead of qemu_log directly.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <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();
--
2.25.1
- [PATCH v2 02/39] target/hexagon: Remove qemu_set_log in hexagon_translate_init, (continued)
- [PATCH v2 02/39] target/hexagon: Remove qemu_set_log in hexagon_translate_init, Richard Henderson, 2022/03/26
- [PATCH v2 03/39] util/log: Return bool from qemu_set_log_filename, Richard Henderson, 2022/03/26
- [PATCH v2 4/8] linux-user/nios2: Adjust error return, Richard Henderson, 2022/03/26
- [PATCH v2 05/39] os-posix: Use qemu_log_enabled, Richard Henderson, 2022/03/26
- [PATCH v2 5/8] linux-user/nios2: Handle special qemu syscall return values, Richard Henderson, 2022/03/26
- [PATCH v2 6/8] linux-user/nios2: Remove do_sigreturn, Richard Henderson, 2022/03/26
- [PATCH v2 04/39] util/log: Pass Error pointer to qemu_set_log, Richard Henderson, 2022/03/26
- [PATCH v2 06/39] util/log: Move qemu_log_lock, qemu_log_unlock out of line, Richard Henderson, 2022/03/26
- [PATCH v2 7/8] linux-user/nios2: Use QEMU_ESIGRETURN from do_rt_sigreturn, Richard Henderson, 2022/03/26
- [PATCH v2 07/39] util/log: Rename qemu_log_lock to qemu_log_trylock, Richard Henderson, 2022/03/26
- [PATCH v2 08/39] hw/xen: Split out xen_pv_output_msg,
Richard Henderson <=
- [PATCH v2 8/8] tests/tcg/nios2: Re-enable linux-user tests, Richard Henderson, 2022/03/26
- [PATCH v2 10/39] util/log: Remove qemu_log_vprintf, Richard Henderson, 2022/03/26
- [PATCH v2 09/39] *: Use fprintf between qemu_log_trylock/unlock, Richard Henderson, 2022/03/26
- [PATCH v2 11/39] tcg: Pass the locked filepointer to tcg_dump_ops, Richard Henderson, 2022/03/26
- [PATCH v2 13/39] exec/log: Remove log_disas and log_target_disas, Richard Henderson, 2022/03/26
- [PATCH v2 12/39] exec/translator: Pass the locked filepointer to disas_log hook, Richard Henderson, 2022/03/26
- [PATCH v2 19/39] util/log: Remove qemu_log_flush, Richard Henderson, 2022/03/26
- [PATCH v2 16/39] util/log: Use qemu_log_trylock/unlock in qemu_log, Richard Henderson, 2022/03/26
- [PATCH v2 25/39] include/qemu/log: Move entire implementation out-of-line, Richard Henderson, 2022/03/26
- [PATCH v2 24/39] include/exec/log: Do not reference QemuLogFile directly, Richard Henderson, 2022/03/26