From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Tony Krowiak" <akrowiak@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Farhan Ali" <alifm@linux.ibm.com>,
qemu-s390x@nongnu.org, "Eric Farman" <farman@linux.ibm.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Laurent Vivier" <laurent@vivier.eu>,
qemu-trivial@nongnu.org, "Juan Quintela" <quintela@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Michael Tokarev" <mjt@tls.msk.ru>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Pierre Morel" <pmorel@linux.ibm.com>,
"Boxuan Li" <liboxuan@connect.hku.hk>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Yuval Shaia" <yuval.shaia@oracle.com>
Subject: [Qemu-trivial] [PULL 1/9] hw/virtio/virtio-mmio: Convert DPRINTF to trace and log
Date: Wed, 22 May 2019 18:07:15 +0200 [thread overview]
Message-ID: <20190522160723.31484-2-laurent@vivier.eu> (raw)
In-Reply-To: <20190522160723.31484-1-laurent@vivier.eu>
From: Boxuan Li <liboxuan@connect.hku.hk>
Use traces for debug message and qemu_log_mask for errors.
Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Message-Id: <20190503154424.73933-1-liboxuan@connect.hku.hk>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
hw/virtio/trace-events | 7 +++++++
hw/virtio/virtio-mmio.c | 44 ++++++++++++++++++++---------------------
2 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index 60c649c4bc96..e28ba48da621 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -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(uint64_t offset) "virtio_mmio_read offset 0x%" PRIx64
+virtio_mmio_write_offset(uint64_t offset, uint64_t value) "virtio_mmio_write offset 0x%" PRIx64 " value 0x%" PRIx64
+virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" PRIx64 " shift %d"
+virtio_mmio_queue_write(uint64_t value, int max_size) "mmio_queue write 0x%" PRIx64 " max %d"
+virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d"
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index 5807aa87fe8e..96c762f0bf88 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -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(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(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(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);
}
--
2.20.1
next prev parent reply other threads:[~2019-05-22 16:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 16:07 [Qemu-trivial] [PULL 0/9] Trivial branch patches Laurent Vivier
2019-05-22 16:07 ` Laurent Vivier [this message]
2019-05-22 16:07 ` [Qemu-trivial] [PULL 2/9] roms: Correct the EDK2_BASETOOLS_OPTFLAGS variable description Laurent Vivier
2019-05-22 16:07 ` [Qemu-trivial] [PULL 3/9] roms: List and describe the Makefile 'clean' rule Laurent Vivier
2019-05-22 16:07 ` [Qemu-trivial] [PULL 4/9] migration: Fix typo in migrate_add_blocker() error message Laurent Vivier
2019-05-22 16:07 ` [Qemu-trivial] [PULL 5/9] configure: Fix spelling of sdl-image in --help Laurent Vivier
2019-05-22 16:07 ` [Qemu-trivial] [PULL 6/9] vfio: pci: make "vfio-pci-nohotplug" as MACRO Laurent Vivier
2019-05-22 16:07 ` [Qemu-trivial] [PULL 7/9] hw: vfio: drop TYPE_FOO MACRO in VMStateDescription Laurent Vivier
2019-05-22 16:07 ` [Qemu-trivial] [PULL 8/9] vfio: platform: fix a typo Laurent Vivier
2019-05-22 16:07 ` [Qemu-trivial] [PULL 9/9] pci: msix: move 'MSIX_CAP_LENGTH' to header file Laurent Vivier
2019-05-23 11:56 ` [Qemu-trivial] [Qemu-devel] [PULL 0/9] Trivial branch patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190522160723.31484-2-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=akrowiak@linux.ibm.com \
--cc=alex.bennee@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=alifm@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=dgilbert@redhat.com \
--cc=farman@linux.ibm.com \
--cc=liboxuan@connect.hku.hk \
--cc=marcel.apfelbaum@gmail.com \
--cc=mjt@tls.msk.ru \
--cc=mst@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=philmd@redhat.com \
--cc=pmorel@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=quintela@redhat.com \
--cc=yuval.shaia@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).