Skip to contentSkip to conversation

vsock: don't send messages when vsock device is not started

PATCH In review Jiang Wang 2 participants 2 messages Oct 1, 2021 – Oct 14, 2021

lore
Share & tools
lore

Jiang Wang

author
#0 lore raw

PATCH 1/1 vsock: don't send messages when vsock device is not started

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

---
 hw/virtio/vhost-vsock-common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/virtio/vhost-vsock-common.c +4 -2
index 4ad6e234ad..64425719a2 100644
@@ -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);
Signature · 1 line
2.20.1
#1 lore raw

Please CC maintainers (MST in this case)

Quoted 21 lines · Jiang Wang

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

---
 hw/virtio/vhost-vsock-common.c | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
hw/virtio/vhost-vsock- renamed from hw/virtio/vhost-vsock-common.c +0 -0

common.c
index 4ad6e234ad..64425719a2 100644

hw/virtio/vhost-vsock-common.c +0 -0
@@ -138,8 +138,10 @@ static void
 vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
          goto out;
      }


-    virtqueue_push(vq, elem, sizeof(event));

Quoted 8 lines

-    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