aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-17 11:29:48 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-04-20 10:51:11 -0700
commit6fef222971e1f77d1e7b6c218edce72ceb568126 (patch)
treeab9d789f32e5b69dc066e19a75b7e901ee709711
parentc60f599bcb9bf9256eb87c1c60add55d23f76de3 (diff)
downloadqemu-6fef222971e1f77d1e7b6c218edce72ceb568126.zip
qemu-6fef222971e1f77d1e7b6c218edce72ceb568126.tar.gz
qemu-6fef222971e1f77d1e7b6c218edce72ceb568126.tar.bz2
hw/xen: Split out xen_pv_output_msg
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> Message-Id: <20220417183019.755276-9-richard.henderson@linaro.org>
-rw-r--r--hw/xen/xen_pvdev.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c
index 8ab4589..0423c61 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();