From nobody Thu May 16 11:07:49 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1556873337; cv=none; d=zoho.com; s=zohoarc; b=A5MqTYLDr/wSLvnF4pgLm+gCDwDu8G738eJNQJ2U/0lWko6fwJi63qLJxDs+gD93YYA4EnPRhoz/wKlPPHrFN/Rw7gZMgsatyjeZy4CLuT1j7bEjJ23qUmJrrW30NWagsJ5y8VPN1hwG+L433nrw35FP4KqLC6eCRrWgR8ZMPes= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556873337; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=8owxu74GQscfy+KDdA+EV/u1JwaAWme0ev7CAE/LPZs=; b=O/HfEiPm3sMJE5AmymPFSJxyp1jpS/ddW86Kw2E1pTd8N00G4oXGnlUW0OAOL5wKjv0Gz8CLtjygXZ+kEy4DSgjggrBBvQV/nrFj5ePLL4wzdJ9wELPUqGuu+ERo9mmjX0Wua+IbydYSXW+IrxOLr4/nZAg6LkP312SWzlYaA1E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 155687333758174.83132528507667; Fri, 3 May 2019 01:48:57 -0700 (PDT) Received: from localhost ([127.0.0.1]:36717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMTs2-0007yT-8B for importer@patchew.org; Fri, 03 May 2019 04:48:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMTqq-0007Xo-6g for qemu-devel@nongnu.org; Fri, 03 May 2019 04:47:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hMTqo-0005Ck-AP for qemu-devel@nongnu.org; Fri, 03 May 2019 04:47:27 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:46745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hMTql-0005BO-0X for qemu-devel@nongnu.org; Fri, 03 May 2019 04:47:24 -0400 Received: by mail-pf1-x441.google.com with SMTP id j11so2543536pff.13 for ; Fri, 03 May 2019 01:47:22 -0700 (PDT) Received: from MBP.local.hk ([175.159.180.1]) by smtp.gmail.com with ESMTPSA id l26sm1980273pfb.20.2019.05.03.01.47.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 May 2019 01:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=connect-hku-hk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=8owxu74GQscfy+KDdA+EV/u1JwaAWme0ev7CAE/LPZs=; b=sRDZqjxhpWDynXbv4x4KXaqPM9tM7rSRHvDsh143QZ66HMboVVXnTrBm3e0RuGnLji //2vTT674viSgchypGPmlW41+ChJvkWVCay7cVlyr/B2mi7n4Z+78Nc486uyk0Ovzkgm RDH8PSWXOg2bO2ipZyd/TesuhmVjrH5SF0YU8WtqIvSooOMgAOoT1sz7ScZU6bywkeYk CxI0msEUE9Xb/5Nz31Py8oEA9u6iammXaipqVESq2uM1jiTFRPCHyhjZ8AV2goEx649b VHTFVt3x2BSR6stxBbnU12LmKfNO7qDWiutIW4lWdIPgySGD8Rzol+IskUFBTSBYK9A8 2faw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8owxu74GQscfy+KDdA+EV/u1JwaAWme0ev7CAE/LPZs=; b=BwxBTz6AoFcXc4p4MwvpwhjemJwwSEsZdWQiq7/7il/59UFMJFSo0MMHPh9DGUJfW5 Z9e35U+N7UtBi9rwSPyhFLOTwrEpPDKZaXEMJYSr4nitabPvJXrrSafKHsq+/68XlSJt L+ofqwqHQ0iPo/vqA4qhJ8CSKuVrcktGLwu9uVLRqsOfVb+fiqpFaZWPacws/PTUAGd6 +e5aGw+1zWp7hipqPkXtI+9f2v+U7ghyDtB3RB5flupCj+9zrXI/m+mEg8SocuZ+VGw5 f7WZcqQ9pOPDm4B737/Rq5MJQ54ycTfcFIWJsAFAtIXtkTkQSxvJK9NGoqxh8jxcMg4i YElg== X-Gm-Message-State: APjAAAX89kIOln0ItdEmx1FSVsl0tDm9vSjTUJMU/qcm3ozPtwPVQYL5 c82kpW/NIluu3UP2Bm/UUI4ImnHjxvzSuw== X-Google-Smtp-Source: APXvYqxlMR+vy7sIgeQGascmD01ZF4DpoOSl2t9DS/G2T9T3ELMPT8qvZfpnO+j51VKsREvWQZHxMg== X-Received: by 2002:a62:4e86:: with SMTP id c128mr9125752pfb.39.1556873241152; Fri, 03 May 2019 01:47:21 -0700 (PDT) From: Boxuan Li To: qemu-devel@nongnu.org Date: Fri, 3 May 2019 16:46:54 +0800 Message-Id: <20190503084654.18413-1-liboxuan@connect.hku.hk> X-Mailer: git-send-email 2.13.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v3] hw/virtio/virtio-mmio: Convert DPRINTF to trace and log X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , qemu-trivial@nongnu.org, yuval.shaia@oracle.com, alex.bennee@linaro.org, Boxuan Li , philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use traces for debug message and qemu_log_mask for errors. Signed-off-by: Boxuan Li Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- v1: https://patchew.org/QEMU/20190428110258.86681-1-liboxuan@connect.hku.hk/ v2: https://patchew.org/QEMU/20190501081039.58938-1-liboxuan@connect.hku.hk/ 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(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 60c649c4bc..81cbe1c4b2 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 tar= get: 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 of= fset 0x%x value 0x%" PRIx64 +virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" PRI= x64 " 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" diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 5807aa87fe..c8a9d974b3 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" =20 /* QOM macros */ /* virtio-mmio-bus */ @@ -107,7 +99,7 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr of= fset, unsigned size) VirtIOMMIOProxy *proxy =3D (VirtIOMMIOProxy *)opaque; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); =20 - DPRINTF("virtio_mmio_read offset 0x%x\n", (int)offset); + trace_virtio_mmio_read((int)offset); =20 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 o= ffset, unsigned size) } } if (size !=3D 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 offs= et, uint64_t value, VirtIOMMIOProxy *proxy =3D (VirtIOMMIOProxy *)opaque; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); =20 - DPRINTF("virtio_mmio_write offset 0x%x value 0x%" PRIx64 "\n", - (int)offset, value); + trace_virtio_mmio_write_offset((int)offset, value); =20 if (!vdev) { /* If no backend is present, we just make all registers @@ -226,7 +221,9 @@ static void virtio_mmio_write(void *opaque, hwaddr offs= et, uint64_t value, return; } if (size !=3D 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 offs= et, uint64_t value, if (proxy->guest_page_shift > 31) { proxy->guest_page_shift =3D 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 offs= et, 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 of= fset, 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; =20 default: - DPRINTF("bad register offset\n"); + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", __func= __); } } =20 @@ -327,7 +325,7 @@ static void virtio_mmio_update_irq(DeviceState *opaque,= uint16_t vector) return; } level =3D (atomic_read(&vdev->isr) !=3D 0); - DPRINTF("virtio_mmio setting IRQ %d\n", level); + trace_virtio_mmio_setting_irq(level); qemu_set_irq(proxy->irq, level); } =20 --=20 2.13.2