qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] vsock: don't send messages when vsock device is not started
@ 2021-10-01 18:42 Jiang Wang
  2021-10-14 10:56 ` Stefano Garzarella
  0 siblings, 1 reply; 2+ messages in thread
From: Jiang Wang @ 2021-10-01 18:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: sgarzare

Added a check in vhost_vsock_common_send_transport_reset,
and only send messages on event queue when the vsock host
device is started.

Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>
---
 hw/virtio/vhost-vsock-common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
index 4ad6e234ad..64425719a2 100644
--- a/hw/virtio/vhost-vsock-common.c
+++ b/hw/virtio/vhost-vsock-common.c
@@ -138,8 +138,10 @@ static void vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
         goto out;
     }
 
-    virtqueue_push(vq, elem, sizeof(event));
-    virtio_notify(VIRTIO_DEVICE(vvc), vq);
+    if (vvc->vhost_dev.started) {
+        virtqueue_push(vq, elem, sizeof(event));
+        virtio_notify(VIRTIO_DEVICE(vvc), vq);
+    }
 
 out:
     g_free(elem);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] vsock: don't send messages when vsock device is not started
  2021-10-01 18:42 [PATCH v1] vsock: don't send messages when vsock device is not started Jiang Wang
@ 2021-10-14 10:56 ` Stefano Garzarella
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Garzarella @ 2021-10-14 10:56 UTC (permalink / raw)
  To: Jiang Wang, qemu-devel; +Cc: Michael S. Tsirkin

Please CC maintainers (MST in this case)

On Fri, 2021-10-01 at 18:42 +0000, Jiang Wang wrote:
> Added a check in vhost_vsock_common_send_transport_reset,
> and only send messages on event queue when the vsock host
> device is started.
> 
> Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
> Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>
> ---
>  hw/virtio/vhost-vsock-common.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-
> common.c
> index 4ad6e234ad..64425719a2 100644
> --- a/hw/virtio/vhost-vsock-common.c
> +++ b/hw/virtio/vhost-vsock-common.c
> @@ -138,8 +138,10 @@ static void
> vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
>          goto out;
>      }
>  
> -    virtqueue_push(vq, elem, sizeof(event));
> -    virtio_notify(VIRTIO_DEVICE(vvc), vq);
> +    if (vvc->vhost_dev.started) {
> +        virtqueue_push(vq, elem, sizeof(event));
> +        virtio_notify(VIRTIO_DEVICE(vvc), vq);
> +    }
>  
>  out:
>      g_free(elem);

I agree that we should avoid to enqueue reset messages if the device is
not started, but this change is wrong, because we are still doing
`virtqueue_pop()`.

I think we should skip vhost_vsock_common_send_transport_reset()
entirely.

Thanks,
Stefano






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-14 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 18:42 [PATCH v1] vsock: don't send messages when vsock device is not started Jiang Wang
2021-10-14 10:56 ` Stefano Garzarella

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).