Skip to contentSkip to conversation

hw/virtio/virtio-mmio: Convert DPRINTF to trace and log

PATCH Superseded Boxuan Li 3 participants 4 messages May 3, 2019

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Boxuan Li

author
#0 lore raw

PATCH v3 1/1 hw/virtio/virtio-mmio: Convert DPRINTF to trace and log

Use traces for debug message and qemu_log_mask for errors.

---
v1: https://patchew.org/QEMU/[email protected]/
v2: https://patchew.org/QEMU/[email protected]/
v3: Use qemu_log_mask for errors

---
 hw/virtio/trace-events  |  7 +++++++
 hw/virtio/virtio-mmio.c | 44 +++++++++++++++++++++-----------------------
 2 files changed, 28 insertions(+), 23 deletions(-)
hw/virtio/trace-events +7 -0
index 60c649c4bc..81cbe1c4b2 100644
@@ -46,3 +46,10 @@ virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s g
 virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: %d actual: %d"
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 0x%"PRIx64" num_pages: %d"
+
+# virtio-mmio.c
+virtio_mmio_read(int offset) "virtio_mmio_read offset 0x%x"
+virtio_mmio_write_offset(int offset, uint64_t value) "virtio_mmio_write offset 0x%x value 0x%" PRIx64
+virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" PRIx64 " shift %d"
+virtio_mmio_queue_write(int value, int max_size) "mmio_queue write %d max %d"
+virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d"
hw/virtio/virtio-mmio.c +21 -23

109 lines not on this page · raw message

Signature · 1 line
2.13.2
Reviewed-by on v3 1/1
#1 lore raw
Quoted 3 lines · Boxuan Li

Use traces for debug message and qemu_log_mask for errors.

Quoted 139 lines

---
v1: https://patchew.org/QEMU/[email protected]/
v2: https://patchew.org/QEMU/[email protected]/
v3: Use qemu_log_mask for errors

---
 hw/virtio/trace-events  |  7 +++++++
 hw/virtio/virtio-mmio.c | 44 +++++++++++++++++++++-----------------------
 2 files changed, 28 insertions(+), 23 deletions(-)
hw/virtio/trace-events +7 -0
index 60c649c4bc..81cbe1c4b2 100644
@@ -46,3 +46,10 @@ virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s g
 virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: %d actual: %d"
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 0x%"PRIx64" num_pages: %d"
+
+# virtio-mmio.c
+virtio_mmio_read(int offset) "virtio_mmio_read offset 0x%x"
+virtio_mmio_write_offset(int offset, uint64_t value) "virtio_mmio_write offset 0x%x value 0x%" PRIx64
+virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" PRIx64 " shift %d"
+virtio_mmio_queue_write(int value, int max_size) "mmio_queue write %d max %d"
+virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d"
hw/virtio/virtio-mmio.c +20 -22
index 5807aa87fe..c8a9d974b3 100644
@@ -27,16 +27,8 @@
 #include "sysemu/kvm.h"
 #include "hw/virtio/virtio-bus.h"
 #include "qemu/error-report.h"
-
-/* #define DEBUG_VIRTIO_MMIO */
-
-#ifdef DEBUG_VIRTIO_MMIO
-
-#define DPRINTF(fmt, ...) \
-do { printf("virtio_mmio: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while (0)
-#endif
+#include "qemu/log.h"
+#include "trace.h"
 
 /* QOM macros */
 /* virtio-mmio-bus */
@@ -107,7 +99,7 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
     VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
-    DPRINTF("virtio_mmio_read offset 0x%x\n", (int)offset);
+    trace_virtio_mmio_read((int)offset);
 
     if (!vdev) {
         /* If no backend is present, we treat most registers as
@@ -144,7 +136,9 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
         }
     }
     if (size != 4) {
-        DPRINTF("wrong size access to register!\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: wrong size access to register!\n",
+                __func__);
         return 0;
     }
     switch (offset) {
@@ -182,10 +176,12 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
     case VIRTIO_MMIO_QUEUE_ALIGN:
     case VIRTIO_MMIO_QUEUE_NOTIFY:
     case VIRTIO_MMIO_INTERRUPT_ACK:
-        DPRINTF("read of write-only register\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: read of write-only register\n",
+                __func__);
         return 0;
     default:
-        DPRINTF("bad register offset\n");
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", __func__);
         return 0;
     }
     return 0;
@@ -197,8 +193,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
     VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
-    DPRINTF("virtio_mmio_write offset 0x%x value 0x%" PRIx64 "\n",
-            (int)offset, value);
+    trace_virtio_mmio_write_offset((int)offset, value);
 
     if (!vdev) {
         /* If no backend is present, we just make all registers
@@ -226,7 +221,9 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
         return;
     }
     if (size != 4) {
-        DPRINTF("wrong size access to register!\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: wrong size access to register!\n",
+                __func__);
         return;
     }
     switch (offset) {
@@ -246,8 +243,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
         if (proxy->guest_page_shift > 31) {
             proxy->guest_page_shift = 0;
         }
-        DPRINTF("guest page size %" PRIx64 " shift %d\n", value,
-                proxy->guest_page_shift);
+        trace_virtio_mmio_guest_page(value, proxy->guest_page_shift);
         break;
     case VIRTIO_MMIO_QUEUE_SEL:
         if (value < VIRTIO_QUEUE_MAX) {
@@ -255,7 +251,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
         }
         break;
     case VIRTIO_MMIO_QUEUE_NUM:
-        DPRINTF("mmio_queue write %d max %d\n", (int)value, VIRTQUEUE_MAX_SIZE);
+        trace_virtio_mmio_queue_write((int)value, VIRTQUEUE_MAX_SIZE);
         virtio_queue_set_num(vdev, vdev->queue_sel, value);
         /* Note: only call this function for legacy devices */
         virtio_queue_update_rings(vdev, vdev->queue_sel);
@@ -303,11 +299,13 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
     case VIRTIO_MMIO_DEVICE_FEATURES:
     case VIRTIO_MMIO_QUEUE_NUM_MAX:
     case VIRTIO_MMIO_INTERRUPT_STATUS:
-        DPRINTF("write to readonly register\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: write to readonly register\n",
+                __func__);
         break;
 
     default:
-        DPRINTF("bad register offset\n");
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", __func__);
     }
 }
 

hw/virtio/virtio-mmio.c static void virtio_mmio_update_irq(DeviceState *opaque, uint16_t vector) · line 330

Quoted 7 lines
hw/virtio/virtio-mmio.c +1 -1
@@ -327,7 +325,7 @@ static void virtio_mmio_update_irq(DeviceState *opaque, uint16_t vector)
         return;
     }
     level = (atomic_read(&vdev->isr) != 0);
-    DPRINTF("virtio_mmio setting IRQ %d\n", level);
+    trace_virtio_mmio_setting_irq(level);
     qemu_set_irq(proxy->irq, level);
 }

--
Alex Bennée

Reviewed-by Tested-by on v3 1/1
#2 lore raw
In reply to Boxuan Li

Hi Li,

Quoted 17 lines · Boxuan Li

Use traces for debug message and qemu_log_mask for errors.

---
v1: https://patchew.org/QEMU/[email protected]/
v2: https://patchew.org/QEMU/[email protected]/
v3: Use qemu_log_mask for errors

---
 hw/virtio/trace-events  |  7 +++++++
 hw/virtio/virtio-mmio.c | 44 +++++++++++++++++++++-----------------------
 2 files changed, 28 insertions(+), 23 deletions(-)
hw/virtio/trace-events +0 -0
index 60c649c4bc..81cbe1c4b2 100644

hw/virtio/trace-events virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s g · line 52

Quoted 7 lines
hw/virtio/trace-events +4 -0
@@ -46,3 +46,10 @@ virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s g
 virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: %d actual: %d"
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 0x%"PRIx64" num_pages: %d"
+
+# virtio-mmio.c
+virtio_mmio_read(int offset) "virtio_mmio_read offset 0x%x"
+virtio_mmio_write_offset(int offset, uint64_t value) "virtio_mmio_write offset 0x%x value 0x%" PRIx64

If possible, use uint64_t/PRIx64 for offset (to avoid casting to int).

Quoted 36 lines
hw/virtio/trace-events +3 -0
+virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" PRIx64 " shift %d"
+virtio_mmio_queue_write(int value, int max_size) "mmio_queue write %d max %d"
+virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d"
hw/virtio/virtio-mmio.c +3 -11
index 5807aa87fe..c8a9d974b3 100644
@@ -27,16 +27,8 @@
 #include "sysemu/kvm.h"
 #include "hw/virtio/virtio-bus.h"
 #include "qemu/error-report.h"
-
-/* #define DEBUG_VIRTIO_MMIO */
-
-#ifdef DEBUG_VIRTIO_MMIO
-
-#define DPRINTF(fmt, ...) \
-do { printf("virtio_mmio: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while (0)
-#endif
+#include "qemu/log.h"
+#include "trace.h"
 
 /* QOM macros */
 /* virtio-mmio-bus */
@@ -107,7 +99,7 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
     VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
-    DPRINTF("virtio_mmio_read offset 0x%x\n", (int)offset);
+    trace_virtio_mmio_read((int)offset);
 
     if (!vdev) {
         /* If no backend is present, we treat most registers as

hw/virtio/virtio-mmio.c static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) · line 141

Quoted 7 lines
hw/virtio/virtio-mmio.c +3 -1
@@ -144,7 +136,9 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
         }
     }
     if (size != 4) {
-        DPRINTF("wrong size access to register!\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: wrong size access to register!\n",
+                __func__);

QEMU codying style is to indent the arguments aligned, after the caller parenthesis:

qemu_log_mask(LOG_GUEST_ERROR,
"%s: wrong size access to register!\n", __func__);

That said:

Thanks for the cleanup!

Quoted 84 lines
hw/virtio/virtio-mmio.c +15 -11
         return 0;
     }
     switch (offset) {
@@ -182,10 +176,12 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
     case VIRTIO_MMIO_QUEUE_ALIGN:
     case VIRTIO_MMIO_QUEUE_NOTIFY:
     case VIRTIO_MMIO_INTERRUPT_ACK:
-        DPRINTF("read of write-only register\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: read of write-only register\n",
+                __func__);
         return 0;
     default:
-        DPRINTF("bad register offset\n");
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", __func__);
         return 0;
     }
     return 0;
@@ -197,8 +193,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
     VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
-    DPRINTF("virtio_mmio_write offset 0x%x value 0x%" PRIx64 "\n",
-            (int)offset, value);
+    trace_virtio_mmio_write_offset((int)offset, value);
 
     if (!vdev) {
         /* If no backend is present, we just make all registers
@@ -226,7 +221,9 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
         return;
     }
     if (size != 4) {
-        DPRINTF("wrong size access to register!\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: wrong size access to register!\n",
+                __func__);
         return;
     }
     switch (offset) {
@@ -246,8 +243,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
         if (proxy->guest_page_shift > 31) {
             proxy->guest_page_shift = 0;
         }
-        DPRINTF("guest page size %" PRIx64 " shift %d\n", value,
-                proxy->guest_page_shift);
+        trace_virtio_mmio_guest_page(value, proxy->guest_page_shift);
         break;
     case VIRTIO_MMIO_QUEUE_SEL:
         if (value < VIRTIO_QUEUE_MAX) {
@@ -255,7 +251,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
         }
         break;
     case VIRTIO_MMIO_QUEUE_NUM:
-        DPRINTF("mmio_queue write %d max %d\n", (int)value, VIRTQUEUE_MAX_SIZE);
+        trace_virtio_mmio_queue_write((int)value, VIRTQUEUE_MAX_SIZE);
         virtio_queue_set_num(vdev, vdev->queue_sel, value);
         /* Note: only call this function for legacy devices */
         virtio_queue_update_rings(vdev, vdev->queue_sel);
@@ -303,11 +299,13 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
     case VIRTIO_MMIO_DEVICE_FEATURES:
     case VIRTIO_MMIO_QUEUE_NUM_MAX:
     case VIRTIO_MMIO_INTERRUPT_STATUS:
-        DPRINTF("write to readonly register\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: write to readonly register\n",
+                __func__);
         break;
 
     default:
-        DPRINTF("bad register offset\n");
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", __func__);
     }
 }
 
@@ -327,7 +325,7 @@ static void virtio_mmio_update_irq(DeviceState *opaque, uint16_t vector)
         return;
     }
     level = (atomic_read(&vdev->isr) != 0);
-    DPRINTF("virtio_mmio setting IRQ %d\n", level);
+    trace_virtio_mmio_setting_irq(level);
     qemu_set_irq(proxy->irq, level);
 }
 
#3 lore raw

Gotcha, thanks for the tip! I'll resend updated patch soon.

Quoted 194 lines · Philippe Mathieu-Daudé

Hi Li,

Quoted 5 lines · Boxuan Li

Use traces for debug message and qemu_log_mask for errors.

---
v1:

https://patchew.org/QEMU/[email protected]/

Quoted 1 line

v2:

https://patchew.org/QEMU/[email protected]/

Quoted 4 lines

v3: Use qemu_log_mask for errors

---
 hw/virtio/trace-events  |  7 +++++++
 hw/virtio/virtio-mmio.c | 44

+++++++++++++++++++++-----------------------

hw/virtio/trace-events virtio_balloon_handle_output(const char *name,

Quoted 7 lines
 2 files changed, 28 insertions(+), 23 deletions(-)
hw/virtio/trace-events +0 -0
index 60c649c4bc..81cbe1c4b2 100644
@@ -46,3 +46,10 @@ virtio_balloon_handle_output(const char *name,

uint64_t gpa) "section name: %s g

hw/virtio/trace-events virtio_balloon_handle_output(const char *name, · line 46

Quoted 1 line
hw/virtio/trace-events +0 -0
 virtio_balloon_get_config(uint32_t num_pages, uint32_t actual)

"num_pages: %d actual: %d"

hw/virtio/trace-events virtio_balloon_handle_output(const char *name, · line 47

Quoted 1 line
hw/virtio/trace-events +0 -0
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual:

%d oldactual: %d"

hw/virtio/trace-events virtio_balloon_handle_output(const char *name, · line 48

Quoted 1 line
hw/virtio/trace-events +0 -0
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon

target: 0x%"PRIx64" num_pages: %d"

hw/virtio/trace-events virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s g

Quoted 4 lines
hw/virtio/trace-events +4 -0
+
+# virtio-mmio.c
+virtio_mmio_read(int offset) "virtio_mmio_read offset 0x%x"
+virtio_mmio_write_offset(int offset, uint64_t value) "virtio_mmio_write

offset 0x%x value 0x%" PRIx64

If possible, use uint64_t/PRIx64 for offset (to avoid casting to int).

hw/virtio/trace-events virtio_balloon_handle_output(const char *name, · line 53

Quoted 1 line
hw/virtio/trace-events +1 -0
+virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%"

PRIx64 " shift %d"

hw/virtio/trace-events virtio_balloon_handle_output(const char *name, · line 54

Quoted 1 line
hw/virtio/trace-events +1 -0
+virtio_mmio_queue_write(int value, int max_size) "mmio_queue write %d

max %d"

hw/virtio/virtio-mmio.c static uint64_t virtio_mmio_read(void *opaque, hwaddr

Quoted 25 lines
hw/virtio/trace-events +1 -0
+virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d"
hw/virtio/virtio-mmio.c +2 -10
index 5807aa87fe..c8a9d974b3 100644
@@ -27,16 +27,8 @@
 #include "sysemu/kvm.h"
 #include "hw/virtio/virtio-bus.h"
 #include "qemu/error-report.h"
-
-/* #define DEBUG_VIRTIO_MMIO */
-
-#ifdef DEBUG_VIRTIO_MMIO
-
-#define DPRINTF(fmt, ...) \
-do { printf("virtio_mmio: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while (0)
-#endif
+#include "qemu/log.h"
+#include "trace.h"
 
 /* QOM macros */
 /* virtio-mmio-bus */
@@ -107,7 +99,7 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr

offset, unsigned size)

hw/virtio/virtio-mmio.c static uint64_t virtio_mmio_read(void *opaque,

Quoted 9 lines
hw/virtio/virtio-mmio.c +1 -1
     VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
-    DPRINTF("virtio_mmio_read offset 0x%x\n", (int)offset);
+    trace_virtio_mmio_read((int)offset);
 
     if (!vdev) {
         /* If no backend is present, we treat most registers as
@@ -144,7 +136,9 @@ static uint64_t virtio_mmio_read(void *opaque,

hwaddr offset, unsigned size)

hw/virtio/virtio-mmio.c static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) · line 141

Quoted 7 lines
hw/virtio/virtio-mmio.c +3 -1
         }
     }
     if (size != 4) {
-        DPRINTF("wrong size access to register!\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: wrong size access to register!\n",
+                __func__);

QEMU codying style is to indent the arguments aligned, after the caller parenthesis:

qemu_log_mask(LOG_GUEST_ERROR,
"%s: wrong size access to register!\n", __func__);

That said:

Thanks for the cleanup!

hw/virtio/virtio-mmio.c static uint64_t virtio_mmio_read(void *opaque,

Quoted 4 lines
hw/virtio/virtio-mmio.c +0 -0
         return 0;
     }
     switch (offset) {
@@ -182,10 +176,12 @@ static uint64_t virtio_mmio_read(void *opaque,

hwaddr offset, unsigned size)

hw/virtio/virtio-mmio.c static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)

Quoted 11 lines
hw/virtio/virtio-mmio.c +4 -2
     case VIRTIO_MMIO_QUEUE_ALIGN:
     case VIRTIO_MMIO_QUEUE_NOTIFY:
     case VIRTIO_MMIO_INTERRUPT_ACK:
-        DPRINTF("read of write-only register\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: read of write-only register\n",
+                __func__);
         return 0;
     default:
-        DPRINTF("bad register offset\n");
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n",

__func__);

hw/virtio/virtio-mmio.c static void virtio_mmio_write(void *opaque, hwaddr

Quoted 4 lines
hw/virtio/virtio-mmio.c +0 -0
         return 0;
     }
     return 0;
@@ -197,8 +193,7 @@ static void virtio_mmio_write(void *opaque, hwaddr

offset, uint64_t value,

hw/virtio/virtio-mmio.c static void virtio_mmio_write(void *opaque, hwaddr

Quoted 10 lines
hw/virtio/virtio-mmio.c +1 -2
     VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
-    DPRINTF("virtio_mmio_write offset 0x%x value 0x%" PRIx64 "\n",
-            (int)offset, value);
+    trace_virtio_mmio_write_offset((int)offset, value);
 
     if (!vdev) {
         /* If no backend is present, we just make all registers
@@ -226,7 +221,9 @@ static void virtio_mmio_write(void *opaque, hwaddr

offset, uint64_t value,

hw/virtio/virtio-mmio.c static void virtio_mmio_write(void *opaque, hwaddr

Quoted 11 lines
hw/virtio/virtio-mmio.c +3 -1
         return;
     }
     if (size != 4) {
-        DPRINTF("wrong size access to register!\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: wrong size access to register!\n",
+                __func__);
         return;
     }
     switch (offset) {
@@ -246,8 +243,7 @@ static void virtio_mmio_write(void *opaque, hwaddr

offset, uint64_t value,

hw/virtio/virtio-mmio.c static void virtio_mmio_write(void *opaque, hwaddr

Quoted 10 lines
hw/virtio/virtio-mmio.c +1 -2
         if (proxy->guest_page_shift > 31) {
             proxy->guest_page_shift = 0;
         }
-        DPRINTF("guest page size %" PRIx64 " shift %d\n", value,
-                proxy->guest_page_shift);
+        trace_virtio_mmio_guest_page(value, proxy->guest_page_shift);
         break;
     case VIRTIO_MMIO_QUEUE_SEL:
         if (value < VIRTIO_QUEUE_MAX) {
@@ -255,7 +251,7 @@ static void virtio_mmio_write(void *opaque, hwaddr

offset, uint64_t value,

hw/virtio/virtio-mmio.c static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,

Quoted 4 lines
hw/virtio/virtio-mmio.c +0 -1
         }
         break;
     case VIRTIO_MMIO_QUEUE_NUM:
-        DPRINTF("mmio_queue write %d max %d\n", (int)value,

VIRTQUEUE_MAX_SIZE);

hw/virtio/virtio-mmio.c static void virtio_mmio_write(void *opaque, hwaddr

Quoted 5 lines
hw/virtio/virtio-mmio.c +1 -0
+        trace_virtio_mmio_queue_write((int)value, VIRTQUEUE_MAX_SIZE);
         virtio_queue_set_num(vdev, vdev->queue_sel, value);
         /* Note: only call this function for legacy devices */
         virtio_queue_update_rings(vdev, vdev->queue_sel);
@@ -303,11 +299,13 @@ static void virtio_mmio_write(void *opaque, hwaddr

offset, uint64_t value,

hw/virtio/virtio-mmio.c static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,

Quoted 12 lines
hw/virtio/virtio-mmio.c +4 -2
     case VIRTIO_MMIO_DEVICE_FEATURES:
     case VIRTIO_MMIO_QUEUE_NUM_MAX:
     case VIRTIO_MMIO_INTERRUPT_STATUS:
-        DPRINTF("write to readonly register\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                "%s: write to readonly register\n",
+                __func__);
         break;
 
     default:
-        DPRINTF("bad register offset\n");
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n",

__func__);

hw/virtio/virtio-mmio.c static void virtio_mmio_update_irq(DeviceState

Quoted 4 lines
hw/virtio/virtio-mmio.c +0 -0
     }
 }
 
@@ -327,7 +325,7 @@ static void virtio_mmio_update_irq(DeviceState

*opaque, uint16_t vector)

Quoted 9 lines
hw/virtio/virtio-mmio.c +1 -1
         return;
     }
     level = (atomic_read(&vdev->isr) != 0);
-    DPRINTF("virtio_mmio setting IRQ %d\n", level);
+    trace_virtio_mmio_setting_irq(level);
     qemu_set_irq(proxy->irq, level);
 }