Reviewed-by: Raphael Norwitz <[email protected]>

On Mon, Jan 19, 2026 at 1:55 PM Vladimir Sementsov-Ogievskiy
<[email protected]> wrote:
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
> ---
>  hw/virtio/trace-events |  4 +--
>  hw/virtio/vhost-user.c | 63 ++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 63 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 aedd5a80ff..824943f1eb 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -119,6 +119,63 @@ typedef enum VhostUserBackendRequest {
>      VHOST_USER_BACKEND_MAX
>  }  VhostUserBackendRequest;
>
> +#define VHOST_USER_CASE(name) \
> +    case VHOST_USER_##name: \
> +        return #name;
> +
> +static const char *vhost_req_name(VhostUserRequest req)
> +{
> +    switch (req) {
> +    VHOST_USER_CASE(NONE)
> +    VHOST_USER_CASE(GET_FEATURES)
> +    VHOST_USER_CASE(SET_FEATURES)
> +    VHOST_USER_CASE(SET_OWNER)
> +    VHOST_USER_CASE(RESET_OWNER)
> +    VHOST_USER_CASE(SET_MEM_TABLE)
> +    VHOST_USER_CASE(SET_LOG_BASE)
> +    VHOST_USER_CASE(SET_LOG_FD)
> +    VHOST_USER_CASE(SET_VRING_NUM)
> +    VHOST_USER_CASE(SET_VRING_ADDR)
> +    VHOST_USER_CASE(SET_VRING_BASE)
> +    VHOST_USER_CASE(GET_VRING_BASE)
> +    VHOST_USER_CASE(SET_VRING_KICK)
> +    VHOST_USER_CASE(SET_VRING_CALL)
> +    VHOST_USER_CASE(SET_VRING_ERR)
> +    VHOST_USER_CASE(GET_PROTOCOL_FEATURES)
> +    VHOST_USER_CASE(SET_PROTOCOL_FEATURES)
> +    VHOST_USER_CASE(GET_QUEUE_NUM)
> +    VHOST_USER_CASE(SET_VRING_ENABLE)
> +    VHOST_USER_CASE(SEND_RARP)
> +    VHOST_USER_CASE(NET_SET_MTU)
> +    VHOST_USER_CASE(SET_BACKEND_REQ_FD)
> +    VHOST_USER_CASE(IOTLB_MSG)
> +    VHOST_USER_CASE(SET_VRING_ENDIAN)
> +    VHOST_USER_CASE(GET_CONFIG)
> +    VHOST_USER_CASE(SET_CONFIG)
> +    VHOST_USER_CASE(CREATE_CRYPTO_SESSION)
> +    VHOST_USER_CASE(CLOSE_CRYPTO_SESSION)
> +    VHOST_USER_CASE(POSTCOPY_ADVISE)
> +    VHOST_USER_CASE(POSTCOPY_LISTEN)
> +    VHOST_USER_CASE(POSTCOPY_END)
> +    VHOST_USER_CASE(GET_INFLIGHT_FD)
> +    VHOST_USER_CASE(SET_INFLIGHT_FD)
> +    VHOST_USER_CASE(GPU_SET_SOCKET)
> +    VHOST_USER_CASE(RESET_DEVICE)
> +    VHOST_USER_CASE(GET_MAX_MEM_SLOTS)
> +    VHOST_USER_CASE(ADD_MEM_REG)
> +    VHOST_USER_CASE(REM_MEM_REG)
> +    VHOST_USER_CASE(SET_STATUS)
> +    VHOST_USER_CASE(GET_STATUS)
> +    VHOST_USER_CASE(GET_SHARED_OBJECT)
> +    VHOST_USER_CASE(SET_DEVICE_STATE_FD)
> +    VHOST_USER_CASE(CHECK_DEVICE_STATE)
> +    default:
> +        return "<unknown>";
> +    }
> +}
> +
> +#undef VHOST_USER_CASE
> +
>  typedef struct VhostUserMemoryRegion {
>      uint64_t guest_phys_addr;
>      uint64_t memory_size;
> @@ -311,7 +368,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 +489,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.52.0
>
>

Reply via email to