@samitouri / QOSamiQemu / commits / 6fdb2219f4

vhost-user: make trace events more readable

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Raphael Norwitz <raphael.s.norwitz@gmail.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260420200339.708640-21-vsementsov@yandex-team.ru>

Vladimir Sementsov-Ogievskiy committed Apr 20, 2026 at 23:03 UTC 6fdb2219f46e39df9f4182e53e0f7f3e277e92f1
2 files changed +63 -4
hw/virtio/trace-events
+2 -2
@@ -25,8 +25,8 @@ vhost_user_set_mem_table_withfd(int index, const char *name, uint64_t memory_siz
25 vhost_user_postcopy_waker(const char *rb, uint64_t rb_offset) "%s + 0x%"PRIx64
26 vhost_user_postcopy_waker_found(uint64_t client_addr) "0x%"PRIx64
27 vhost_user_postcopy_waker_nomatch(const char *rb, uint64_t rb_offset) "%s + 0x%"PRIx64
28 -vhost_user_read(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32""
29 -vhost_user_write(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32""
28 +vhost_user_read(uint32_t req, const char *req_name, uint32_t flags) "req:%d (%s) flags:0x%"PRIx32""
29 +vhost_user_write(uint32_t req, const char *req_name, uint32_t flags) "req:%d (%s) flags:0x%"PRIx32""
30 vhost_user_create_notifier(int idx, void *n) "idx:%d n:%p"
31
32 # vhost-vdpa.c
hw/virtio/vhost-user.c
+61 -2
@@ -114,6 +114,63 @@ typedef enum VhostUserBackendRequest {
114 VHOST_USER_BACKEND_MAX
115 } VhostUserBackendRequest;
116
117 +#define VHOST_USER_CASE(name) \
118 + case VHOST_USER_##name: \
119 + return #name;
120 +
121 +static const char *vhost_req_name(VhostUserRequest req)
122 +{
123 + switch (req) {
124 + VHOST_USER_CASE(NONE)
125 + VHOST_USER_CASE(GET_FEATURES)
126 + VHOST_USER_CASE(SET_FEATURES)
127 + VHOST_USER_CASE(SET_OWNER)
128 + VHOST_USER_CASE(RESET_OWNER)
129 + VHOST_USER_CASE(SET_MEM_TABLE)
130 + VHOST_USER_CASE(SET_LOG_BASE)
131 + VHOST_USER_CASE(SET_LOG_FD)
132 + VHOST_USER_CASE(SET_VRING_NUM)
133 + VHOST_USER_CASE(SET_VRING_ADDR)
134 + VHOST_USER_CASE(SET_VRING_BASE)
135 + VHOST_USER_CASE(GET_VRING_BASE)
136 + VHOST_USER_CASE(SET_VRING_KICK)
137 + VHOST_USER_CASE(SET_VRING_CALL)
138 + VHOST_USER_CASE(SET_VRING_ERR)
139 + VHOST_USER_CASE(GET_PROTOCOL_FEATURES)
140 + VHOST_USER_CASE(SET_PROTOCOL_FEATURES)
141 + VHOST_USER_CASE(GET_QUEUE_NUM)
142 + VHOST_USER_CASE(SET_VRING_ENABLE)
143 + VHOST_USER_CASE(SEND_RARP)
144 + VHOST_USER_CASE(NET_SET_MTU)
145 + VHOST_USER_CASE(SET_BACKEND_REQ_FD)
146 + VHOST_USER_CASE(IOTLB_MSG)
147 + VHOST_USER_CASE(SET_VRING_ENDIAN)
148 + VHOST_USER_CASE(GET_CONFIG)
149 + VHOST_USER_CASE(SET_CONFIG)
150 + VHOST_USER_CASE(CREATE_CRYPTO_SESSION)
151 + VHOST_USER_CASE(CLOSE_CRYPTO_SESSION)
152 + VHOST_USER_CASE(POSTCOPY_ADVISE)
153 + VHOST_USER_CASE(POSTCOPY_LISTEN)
154 + VHOST_USER_CASE(POSTCOPY_END)
155 + VHOST_USER_CASE(GET_INFLIGHT_FD)
156 + VHOST_USER_CASE(SET_INFLIGHT_FD)
157 + VHOST_USER_CASE(GPU_SET_SOCKET)
158 + VHOST_USER_CASE(RESET_DEVICE)
159 + VHOST_USER_CASE(GET_MAX_MEM_SLOTS)
160 + VHOST_USER_CASE(ADD_MEM_REG)
161 + VHOST_USER_CASE(REM_MEM_REG)
162 + VHOST_USER_CASE(SET_STATUS)
163 + VHOST_USER_CASE(GET_STATUS)
164 + VHOST_USER_CASE(GET_SHARED_OBJECT)
165 + VHOST_USER_CASE(SET_DEVICE_STATE_FD)
166 + VHOST_USER_CASE(CHECK_DEVICE_STATE)
167 + default:
168 + return "<unknown>";
169 + }
170 +}
171 +
172 +#undef VHOST_USER_CASE
173 +
174 typedef struct VhostUserMemoryRegion {
175 uint64_t guest_phys_addr;
176 uint64_t memory_size;
@@ -308,7 +365,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
365 return -EPROTO;
366 }
367
311 - trace_vhost_user_read(msg->hdr.request, msg->hdr.flags);
368 + trace_vhost_user_read(msg->hdr.request,
369 + vhost_req_name(msg->hdr.request), msg->hdr.flags);
370
371 return 0;
372 }
@@ -428,7 +486,8 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
486 return ret < 0 ? -saved_errno : -EIO;
487 }
488
431 - trace_vhost_user_write(msg->hdr.request, msg->hdr.flags);
489 + trace_vhost_user_write(msg->hdr.request, vhost_req_name(msg->hdr.request),
490 + msg->hdr.flags);
491
492 return 0;
493 }