qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: sgarzare@redhat.com, raphael@enfabrica.net,
	qemu-devel@nongnu.org, yc-core@yandex-team.ru,
	d-tatianin@yandex-team.ru,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Raphael Norwitz" <raphael.s.norwitz@gmail.com>
Subject: Re: [PATCH v3 21/23] vhost-user: make trace events more readable
Date: Mon, 3 Nov 2025 17:22:55 -0500	[thread overview]
Message-ID: <20251103172122-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20251015145808.1112843-22-vsementsov@yandex-team.ru>

On Wed, Oct 15, 2025 at 05:58:05PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Raphael Norwitz <raphael.s.norwitz@gmail.com>
> Reviewed-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> ---
>  hw/virtio/trace-events |  4 +-
>  hw/virtio/vhost-user.c | 94 +++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 94 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
> index 658cc365e7..aa1ffa5e94 100644
> --- a/hw/virtio/trace-events
> +++ b/hw/virtio/trace-events
> @@ -25,8 +25,8 @@ vhost_user_set_mem_table_withfd(int index, const char *name, uint64_t memory_siz
>  vhost_user_postcopy_waker(const char *rb, uint64_t rb_offset) "%s + 0x%"PRIx64
>  vhost_user_postcopy_waker_found(uint64_t client_addr) "0x%"PRIx64
>  vhost_user_postcopy_waker_nomatch(const char *rb, uint64_t rb_offset) "%s + 0x%"PRIx64
> -vhost_user_read(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32""
> -vhost_user_write(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32""
> +vhost_user_read(uint32_t req, const char *req_name, uint32_t flags) "req:%d (%s) flags:0x%"PRIx32""
> +vhost_user_write(uint32_t req, const char *req_name, uint32_t flags) "req:%d (%s) flags:0x%"PRIx32""
>  vhost_user_create_notifier(int idx, void *n) "idx:%d n:%p"
>  
>  # vhost-vdpa.c
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 23e7c12b16..e45b74eddd 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -119,6 +119,94 @@ typedef enum VhostUserBackendRequest {
>      VHOST_USER_BACKEND_MAX
>  }  VhostUserBackendRequest;
>  
> +static const char *vhost_req_name(VhostUserRequest req)
> +{
> +    switch (req) {
> +    case VHOST_USER_NONE:
> +        return "NONE";
> +    case VHOST_USER_GET_FEATURES:
> +        return "GET_FEATURES";
> +    case VHOST_USER_SET_FEATURES:
> +        return "SET_FEATURES";
> +    case VHOST_USER_SET_OWNER:
> +        return "SET_OWNER";
> +    case VHOST_USER_RESET_OWNER:
> +        return "RESET_OWNER";
> +    case VHOST_USER_SET_MEM_TABLE:
> +        return "SET_MEM_TABLE";
> +    case VHOST_USER_SET_LOG_BASE:
> +        return "SET_LOG_BASE";
> +    case VHOST_USER_SET_LOG_FD:
> +        return "SET_LOG_FD";
> +    case VHOST_USER_SET_VRING_NUM:
> +        return "SET_VRING_NUM";
> +    case VHOST_USER_SET_VRING_ADDR:
> +        return "SET_VRING_ADDR";
> +    case VHOST_USER_SET_VRING_BASE:
> +        return "SET_VRING_BASE";
> +    case VHOST_USER_GET_VRING_BASE:
> +        return "GET_VRING_BASE";
> +    case VHOST_USER_SET_VRING_KICK:
> +        return "SET_VRING_KICK";
> +    case VHOST_USER_SET_VRING_CALL:
> +        return "SET_VRING_CALL";
> +    case VHOST_USER_SET_VRING_ERR:
> +        return "SET_VRING_ERR";
> +    case VHOST_USER_GET_PROTOCOL_FEATURES:
> +        return "GET_PROTOCOL_FEATURES";
> +    case VHOST_USER_SET_PROTOCOL_FEATURES:
> +        return "SET_PROTOCOL_FEATURES";
> +    case VHOST_USER_GET_QUEUE_NUM:
> +        return "GET_QUEUE_NUM";
> +    case VHOST_USER_SET_VRING_ENABLE:
> +        return "SET_VRING_ENABLE";
> +    case VHOST_USER_SEND_RARP:
> +        return "SEND_RARP";
> +    case VHOST_USER_NET_SET_MTU:
> +        return "NET_SET_MTU";
> +    case VHOST_USER_SET_BACKEND_REQ_FD:
> +        return "SET_BACKEND_REQ_FD";
> +    case VHOST_USER_IOTLB_MSG:
> +        return "IOTLB_MSG";
> +    case VHOST_USER_SET_VRING_ENDIAN:
> +        return "SET_VRING_ENDIAN";
> +    case VHOST_USER_GET_CONFIG:
> +        return "GET_CONFIG";
> +    case VHOST_USER_SET_CONFIG:
> +        return "SET_CONFIG";
> +    case VHOST_USER_CREATE_CRYPTO_SESSION:
> +        return "CREATE_CRYPTO_SESSION";
> +    case VHOST_USER_CLOSE_CRYPTO_SESSION:
> +        return "CLOSE_CRYPTO_SESSION";
> +    case VHOST_USER_POSTCOPY_ADVISE:
> +        return "POSTCOPY_ADVISE";
> +    case VHOST_USER_POSTCOPY_LISTEN:
> +        return "POSTCOPY_LISTEN";
> +    case VHOST_USER_POSTCOPY_END:
> +        return "POSTCOPY_END";
> +    case VHOST_USER_GET_INFLIGHT_FD:
> +        return "GET_INFLIGHT_FD";
> +    case VHOST_USER_SET_INFLIGHT_FD:
> +        return "SET_INFLIGHT_FD";
> +    case VHOST_USER_GPU_SET_SOCKET:
> +        return "GPU_SET_SOCKET";
> +    case VHOST_USER_RESET_DEVICE:
> +        return "RESET_DEVICE";
> +    case VHOST_USER_GET_MAX_MEM_SLOTS:
> +        return "GET_MAX_MEM_SLOTS";
> +    case VHOST_USER_ADD_MEM_REG:
> +        return "ADD_MEM_REG";
> +    case VHOST_USER_REM_MEM_REG:
> +        return "REM_MEM_REG";
> +    case VHOST_USER_SET_STATUS:
> +        return "SET_STATUS";
> +    case VHOST_USER_GET_STATUS:
> +        return "GET_STATUS";
> +    default:
> +        return "<unknown>";
> +    }
> +}
> +

Please use a macro so we don't have this duplication.


E.g.

  #define VHOST_USER_CASE(name) \
      case VHOST_USER_##name: \
          return #name;



>  typedef struct VhostUserMemoryRegion {
>      uint64_t guest_phys_addr;
>      uint64_t memory_size;
> @@ -311,7 +399,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
>          return -EPROTO;
>      }
>  
> -    trace_vhost_user_read(msg->hdr.request, msg->hdr.flags);
> +    trace_vhost_user_read(msg->hdr.request,
> +                          vhost_req_name(msg->hdr.request), msg->hdr.flags);
>  
>      return 0;
>  }
> @@ -431,7 +520,8 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
>          return ret < 0 ? -saved_errno : -EIO;
>      }
>  
> -    trace_vhost_user_write(msg->hdr.request, msg->hdr.flags);
> +    trace_vhost_user_write(msg->hdr.request, vhost_req_name(msg->hdr.request),
> +                           msg->hdr.flags);
>  
>      return 0;
>  }
> -- 
> 2.48.1



  reply	other threads:[~2025-11-03 22:24 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 14:57 [PATCH v3 00/23] vhost refactoring and fixes Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 01/23] vhost-user: rework enabling vrings Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 02/23] vhost: drop backend_features field Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 03/23] vhost-user: introduce vhost_user_has_protocol_feature() helper Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 04/23] vhost: move protocol_features to vhost_user Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 05/23] vhost-user-gpu: drop code duplication Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 06/23] vhost: make vhost_dev.features private Vladimir Sementsov-Ogievskiy
2025-10-17 10:32   ` Daniil Tatianin
2025-10-17 17:02     ` Vladimir Sementsov-Ogievskiy
2025-10-31 17:31       ` Daniil Tatianin
2025-10-15 14:57 ` [PATCH v3 07/23] virtio: move common part of _set_guest_notifier to generic code Vladimir Sementsov-Ogievskiy
2025-11-07 13:01   ` Michael S. Tsirkin
2025-10-15 14:57 ` [PATCH v3 08/23] virtio: drop *_set_guest_notifier_fd_handler() helpers Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 09/23] vhost-user: keep QIOChannelSocket for backend channel Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 10/23] vhost: vhost_virtqueue_start(): fix failure path Vladimir Sementsov-Ogievskiy
2025-10-20 18:24   ` Raphael Norwitz
2025-10-15 14:57 ` [PATCH v3 11/23] vhost: make vhost_memory_unmap() null-safe Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 12/23] vhost: simplify calls to vhost_memory_unmap() Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 13/23] vhost: move vrings mapping to the top of vhost_virtqueue_start() Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 14/23] vhost: vhost_virtqueue_start(): drop extra local variables Vladimir Sementsov-Ogievskiy
2025-10-15 14:57 ` [PATCH v3 15/23] vhost: final refactoring of vhost vrings map/unmap Vladimir Sementsov-Ogievskiy
2025-10-15 14:58 ` [PATCH v3 16/23] vhost: simplify vhost_dev_init() error-path Vladimir Sementsov-Ogievskiy
2025-10-15 14:58 ` [PATCH v3 17/23] vhost: move busyloop timeout initialization to vhost_virtqueue_init() Vladimir Sementsov-Ogievskiy
2025-10-15 14:58 ` [PATCH v3 18/23] vhost: introduce check_memslots() helper Vladimir Sementsov-Ogievskiy
2025-11-03 22:19   ` Michael S. Tsirkin
2025-11-04 10:59     ` Vladimir Sementsov-Ogievskiy
2025-10-15 14:58 ` [PATCH v3 19/23] vhost: vhost_dev_init(): simplify features initialization Vladimir Sementsov-Ogievskiy
2025-10-15 14:58 ` [PATCH v3 20/23] hw/virtio/virtio-bus: refactor virtio_bus_set_host_notifier() Vladimir Sementsov-Ogievskiy
2025-10-15 14:58 ` [PATCH v3 21/23] vhost-user: make trace events more readable Vladimir Sementsov-Ogievskiy
2025-11-03 22:22   ` Michael S. Tsirkin [this message]
2025-10-15 14:58 ` [PATCH v3 22/23] vhost-user-blk: add some useful trace-points Vladimir Sementsov-Ogievskiy
2025-11-03 21:28   ` Michael S. Tsirkin
2025-11-04 11:08     ` Vladimir Sementsov-Ogievskiy
2025-10-15 14:58 ` [PATCH v3 23/23] vhost: " Vladimir Sementsov-Ogievskiy
2025-11-03 21:26   ` Michael S. Tsirkin
2025-10-18 15:33 ` [PATCH v3 00/23] vhost refactoring and fixes Lei Yang

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=20251103172122-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=d-tatianin@yandex-team.ru \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.s.norwitz@gmail.com \
    --cc=raphael@enfabrica.net \
    --cc=sgarzare@redhat.com \
    --cc=vsementsov@yandex-team.ru \
    --cc=yc-core@yandex-team.ru \
    /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).