From: Philippe Mathieu-Daudé <phi...@redhat.com> The QEMU_VFIO_DEBUG definition is only modifiable at build-time. Trace events can be enabled at run-time. As we prefer the latter, convert qemu_vfio_dump_mappings() to use trace events instead of fprintf().
Reviewed-by: Fam Zheng <f...@euphon.net> Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> Message-id: 20201103020733.2303148-7-phi...@redhat.com Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> Tested-by: Eric Auger <eric.au...@redhat.com> --- util/vfio-helpers.c | 19 ++++--------------- util/trace-events | 1 + 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index c24a510df8..73f7bfa754 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -521,23 +521,12 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp) return s; } -static void qemu_vfio_dump_mapping(IOVAMapping *m) -{ - if (QEMU_VFIO_DEBUG) { - printf(" vfio mapping %p %" PRIx64 " to %" PRIx64 "\n", m->host, - (uint64_t)m->size, (uint64_t)m->iova); - } -} - static void qemu_vfio_dump_mappings(QEMUVFIOState *s) { - int i; - - if (QEMU_VFIO_DEBUG) { - printf("vfio mappings\n"); - for (i = 0; i < s->nr_mappings; ++i) { - qemu_vfio_dump_mapping(&s->mappings[i]); - } + for (int i = 0; i < s->nr_mappings; ++i) { + trace_qemu_vfio_dump_mapping(s->mappings[i].host, + s->mappings[i].iova, + s->mappings[i].size); } } diff --git a/util/trace-events b/util/trace-events index 08239941cb..61e0d4bcdf 100644 --- a/util/trace-events +++ b/util/trace-events @@ -80,6 +80,7 @@ qemu_mutex_unlock(void *mutex, const char *file, const int line) "released mutex qemu_vfio_dma_reset_temporary(void *s) "s %p" qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%zx" qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx" +qemu_vfio_dump_mapping(void *host, uint64_t iova, size_t size) "vfio mapping %p to iova 0x%08" PRIx64 " size 0x%zx" qemu_vfio_find_mapping(void *s, void *p) "s %p host %p" qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64 qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64 " size 0x%zx" -- 2.28.0