aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/net/can/can_sja1000.c29
-rw-r--r--hw/xen/xen_pvdev.c45
2 files changed, 39 insertions, 35 deletions
diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
index 3ba803e947..e0f76d3eb3 100644
--- a/hw/net/can/can_sja1000.c
+++ b/hw/net/can/can_sja1000.c
@@ -247,21 +247,22 @@ int can_sja_accept_filter(CanSJA1000State *s,
static void can_display_msg(const char *prefix, const qemu_can_frame *msg)
{
int i;
- FILE *logfile = qemu_log_lock();
-
- qemu_log("%s%03X [%01d] %s %s",
- prefix,
- msg->can_id & QEMU_CAN_EFF_MASK,
- msg->can_dlc,
- msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF",
- msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT");
-
- for (i = 0; i < msg->can_dlc; i++) {
- qemu_log(" %02X", msg->data[i]);
+ FILE *logfile = qemu_log_trylock();
+
+ if (logfile) {
+ fprintf(logfile, "%s%03X [%01d] %s %s",
+ prefix,
+ msg->can_id & QEMU_CAN_EFF_MASK,
+ msg->can_dlc,
+ msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF",
+ msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT");
+
+ for (i = 0; i < msg->can_dlc; i++) {
+ fprintf(logfile, " %02X", msg->data[i]);
+ }
+ fprintf(logfile, "\n");
+ qemu_log_unlock(logfile);
}
- qemu_log("\n");
- qemu_log_flush();
- qemu_log_unlock(logfile);
}
static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame)
diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c
index 8ab458922a..037152f063 100644
--- a/hw/xen/xen_pvdev.c
+++ b/hw/xen/xen_pvdev.c
@@ -196,37 +196,40 @@ 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();
}
void xen_pv_evtchn_event(void *opaque)