* [PATCH] vhost-user: add NEED_REPLY flag
@ 2024-08-04 15:48 luzhixing12345
2024-08-12 4:53 ` 陆知行
2024-09-10 15:23 ` Michael S. Tsirkin
0 siblings, 2 replies; 5+ messages in thread
From: luzhixing12345 @ 2024-08-04 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: luzhixing12345, Michael S. Tsirkin, Stefano Garzarella
Front-end message requests which need reply should set NEED_REPLY_MASK
in flag, and response from slave need clear NEED_REPLY_MASK flag.
---
hw/virtio/vhost-user.c | 2 +-
subprojects/libvhost-user/libvhost-user.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 00561daa06..edf2271e0a 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1082,7 +1082,7 @@ static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t *u64)
int ret;
VhostUserMsg msg = {
.hdr.request = request,
- .hdr.flags = VHOST_USER_VERSION,
+ .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK,
};
if (vhost_user_per_device_request(request) && dev->vq_index != 0) {
diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index 9c630c2170..40f665bd7f 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -667,6 +667,7 @@ vu_send_reply(VuDev *dev, int conn_fd, VhostUserMsg *vmsg)
{
/* Set the version in the flags when sending the reply */
vmsg->flags &= ~VHOST_USER_VERSION_MASK;
+ vmsg->flags &= ~VHOST_USER_NEED_REPLY_MASK;
vmsg->flags |= VHOST_USER_VERSION;
vmsg->flags |= VHOST_USER_REPLY_MASK;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] vhost-user: add NEED_REPLY flag
2024-08-04 15:48 [PATCH] vhost-user: add NEED_REPLY flag luzhixing12345
@ 2024-08-12 4:53 ` 陆知行
2024-08-27 13:29 ` Stefano Garzarella
2024-09-10 15:23 ` Michael S. Tsirkin
1 sibling, 1 reply; 5+ messages in thread
From: 陆知行 @ 2024-08-12 4:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael S. Tsirkin, Stefano Garzarella
[-- Attachment #1: Type: text/plain, Size: 1698 bytes --]
Hi, can someone review this patch?
I find requests which call vhost_user_get_u64 does not set NEED_REPLY flag
luzhixing12345 <luzhixing12345@gmail.com> 于2024年8月4日周日 23:50写道:
> Front-end message requests which need reply should set NEED_REPLY_MASK
> in flag, and response from slave need clear NEED_REPLY_MASK flag.
>
> ---
> hw/virtio/vhost-user.c | 2 +-
> subprojects/libvhost-user/libvhost-user.c | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 00561daa06..edf2271e0a 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -1082,7 +1082,7 @@ static int vhost_user_get_u64(struct vhost_dev *dev,
> int request, uint64_t *u64)
> int ret;
> VhostUserMsg msg = {
> .hdr.request = request,
> - .hdr.flags = VHOST_USER_VERSION,
> + .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK,
> };
>
> if (vhost_user_per_device_request(request) && dev->vq_index != 0) {
> diff --git a/subprojects/libvhost-user/libvhost-user.c
> b/subprojects/libvhost-user/libvhost-user.c
> index 9c630c2170..40f665bd7f 100644
> --- a/subprojects/libvhost-user/libvhost-user.c
> +++ b/subprojects/libvhost-user/libvhost-user.c
> @@ -667,6 +667,7 @@ vu_send_reply(VuDev *dev, int conn_fd, VhostUserMsg
> *vmsg)
> {
> /* Set the version in the flags when sending the reply */
> vmsg->flags &= ~VHOST_USER_VERSION_MASK;
> + vmsg->flags &= ~VHOST_USER_NEED_REPLY_MASK;
> vmsg->flags |= VHOST_USER_VERSION;
> vmsg->flags |= VHOST_USER_REPLY_MASK;
>
> --
> 2.34.1
>
>
[-- Attachment #2: Type: text/html, Size: 2134 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vhost-user: add NEED_REPLY flag
2024-08-12 4:53 ` 陆知行
@ 2024-08-27 13:29 ` Stefano Garzarella
2024-09-06 1:50 ` luzhixing12345
0 siblings, 1 reply; 5+ messages in thread
From: Stefano Garzarella @ 2024-08-27 13:29 UTC (permalink / raw)
To: 陆知行; +Cc: qemu-devel, Michael S. Tsirkin
On Mon, Aug 12, 2024 at 12:53:19PM GMT, 陆知行 wrote:
>Hi, can someone review this patch?
>I find requests which call vhost_user_get_u64 does not set NEED_REPLY flag
Can you provide an example to trigger this issue?
Also, with this change all calls to vhost_user_get_u64() will set that
flag, is that following the vhost-user user specification?
Please use `scripts/checkpatch.pl` before sending patches, this one for
example is missing SoB.
Thanks,
Stefano
>
>luzhixing12345 <luzhixing12345@gmail.com> 于2024年8月4日周日 23:50写道:
>
>> Front-end message requests which need reply should set NEED_REPLY_MASK
>> in flag, and response from slave need clear NEED_REPLY_MASK flag.
>>
>> ---
>> hw/virtio/vhost-user.c | 2 +-
>> subprojects/libvhost-user/libvhost-user.c | 1 +
>> 2 files changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
>> index 00561daa06..edf2271e0a 100644
>> --- a/hw/virtio/vhost-user.c
>> +++ b/hw/virtio/vhost-user.c
>> @@ -1082,7 +1082,7 @@ static int vhost_user_get_u64(struct vhost_dev *dev,
>> int request, uint64_t *u64)
>> int ret;
>> VhostUserMsg msg = {
>> .hdr.request = request,
>> - .hdr.flags = VHOST_USER_VERSION,
>> + .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK,
>> };
>>
>> if (vhost_user_per_device_request(request) && dev->vq_index != 0) {
>> diff --git a/subprojects/libvhost-user/libvhost-user.c
>> b/subprojects/libvhost-user/libvhost-user.c
>> index 9c630c2170..40f665bd7f 100644
>> --- a/subprojects/libvhost-user/libvhost-user.c
>> +++ b/subprojects/libvhost-user/libvhost-user.c
>> @@ -667,6 +667,7 @@ vu_send_reply(VuDev *dev, int conn_fd, VhostUserMsg
>> *vmsg)
>> {
>> /* Set the version in the flags when sending the reply */
>> vmsg->flags &= ~VHOST_USER_VERSION_MASK;
>> + vmsg->flags &= ~VHOST_USER_NEED_REPLY_MASK;
>> vmsg->flags |= VHOST_USER_VERSION;
>> vmsg->flags |= VHOST_USER_REPLY_MASK;
>>
>> --
>> 2.34.1
>>
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vhost-user: add NEED_REPLY flag
2024-08-27 13:29 ` Stefano Garzarella
@ 2024-09-06 1:50 ` luzhixing12345
0 siblings, 0 replies; 5+ messages in thread
From: luzhixing12345 @ 2024-09-06 1:50 UTC (permalink / raw)
To: sgarzare; +Cc: luzhixing12345, mst, qemu-devel
Signed-off-by: luzhixing12345 <luzhixing12345@gmail.com>
>On Mon, Aug 12, 2024 at 12:53:19PM GMT, 陆知行 wrote:
>>Hi, can someone review this patch?
>>I find requests which call vhost_user_get_u64 does not set NEED_REPLY flag
>
>Can you provide an example to trigger this issue?
>
>Also, with this change all calls to vhost_user_get_u64() will set that
>flag, is that following the vhost-user user specification?
It will not trigger a bug.
For each function that calls vhost_user_get_u64() like vhost_user_get_features/vhost_user_get_status, if you set a breakpoint in gdb at subprojects/libvhost-user/libvhost-user.c/vu_dispatch and you will find that
```
bool
vu_dispatch(VuDev *dev)
{
// ...
need_reply = vmsg.flags & VHOST_USER_NEED_REPLY_MASK; // 0
reply_requested = vu_process_message(dev, &vmsg); // 1
// ...
}
vhost-user protocol doc list some requests that need reply like VHOST_USER_GET_FEATURES/VHOST_USER_GET_PROTOCOL_FEATURES, the flag should be set with NEED_REPLY_MASK.
The current code does not raise an error because in libvhost-user(vu_process_message) it will not check this flag and always choose whether or not reply based on the request type.
So this patch fills the flag and make sure need_reply to 1 for the requests that need reply.
>Please use `scripts/checkpatch.pl` before sending patches, this one for
>example is missing SoB.
>
>Thanks,
>Stefano
>
>>
>>luzhixing12345 <luzhixing12345@gmail.com> 于2024年8月4日周日 23:50写道:
>>
>>> Front-end message requests which need reply should set NEED_REPLY_MASK
>>> in flag, and response from slave need clear NEED_REPLY_MASK flag.
>>>
>>> ---
>>> hw/virtio/vhost-user.c | 2 +-
>>> subprojects/libvhost-user/libvhost-user.c | 1 +
>>> 2 files changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
>>> index 00561daa06..edf2271e0a 100644
>>> --- a/hw/virtio/vhost-user.c
>>> +++ b/hw/virtio/vhost-user.c
>>> @@ -1082,7 +1082,7 @@ static int vhost_user_get_u64(struct vhost_dev *dev,
>>> int request, uint64_t *u64)
>>> int ret;
>>> VhostUserMsg msg = {
>>> .hdr.request = request,
>>> - .hdr.flags = VHOST_USER_VERSION,
>>> + .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK,
>>> };
>>>
>>> if (vhost_user_per_device_request(request) && dev->vq_index != 0) {
>>> diff --git a/subprojects/libvhost-user/libvhost-user.c
>>> b/subprojects/libvhost-user/libvhost-user.c
>>> index 9c630c2170..40f665bd7f 100644
>>> --- a/subprojects/libvhost-user/libvhost-user.c
>>> +++ b/subprojects/libvhost-user/libvhost-user.c
>>> @@ -667,6 +667,7 @@ vu_send_reply(VuDev *dev, int conn_fd, VhostUserMsg
>>> *vmsg)
>>> {
>>> /* Set the version in the flags when sending the reply */
>>> vmsg->flags &= ~VHOST_USER_VERSION_MASK;
>>> + vmsg->flags &= ~VHOST_USER_NEED_REPLY_MASK;
>>> vmsg->flags |= VHOST_USER_VERSION;
>>> vmsg->flags |= VHOST_USER_REPLY_MASK;
>>>
>>> --
>>> 2.34.1
>>>
>>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vhost-user: add NEED_REPLY flag
2024-08-04 15:48 [PATCH] vhost-user: add NEED_REPLY flag luzhixing12345
2024-08-12 4:53 ` 陆知行
@ 2024-09-10 15:23 ` Michael S. Tsirkin
1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2024-09-10 15:23 UTC (permalink / raw)
To: luzhixing12345; +Cc: qemu-devel, Stefano Garzarella
On Sun, Aug 04, 2024 at 11:48:59PM +0800, luzhixing12345 wrote:
> Front-end message requests which need reply should set NEED_REPLY_MASK
> in flag, and response from slave need clear NEED_REPLY_MASK flag.
neither this.
> ---
> hw/virtio/vhost-user.c | 2 +-
> subprojects/libvhost-user/libvhost-user.c | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 00561daa06..edf2271e0a 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -1082,7 +1082,7 @@ static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t *u64)
> int ret;
> VhostUserMsg msg = {
> .hdr.request = request,
> - .hdr.flags = VHOST_USER_VERSION,
> + .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK,
> };
>
> if (vhost_user_per_device_request(request) && dev->vq_index != 0) {
> diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
> index 9c630c2170..40f665bd7f 100644
> --- a/subprojects/libvhost-user/libvhost-user.c
> +++ b/subprojects/libvhost-user/libvhost-user.c
> @@ -667,6 +667,7 @@ vu_send_reply(VuDev *dev, int conn_fd, VhostUserMsg *vmsg)
> {
> /* Set the version in the flags when sending the reply */
> vmsg->flags &= ~VHOST_USER_VERSION_MASK;
> + vmsg->flags &= ~VHOST_USER_NEED_REPLY_MASK;
> vmsg->flags |= VHOST_USER_VERSION;
> vmsg->flags |= VHOST_USER_REPLY_MASK;
>
> --
> 2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-10 15:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-04 15:48 [PATCH] vhost-user: add NEED_REPLY flag luzhixing12345
2024-08-12 4:53 ` 陆知行
2024-08-27 13:29 ` Stefano Garzarella
2024-09-06 1:50 ` luzhixing12345
2024-09-10 15:23 ` Michael S. Tsirkin
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).