[PATCH v3] vhost-vsock: SOCK_SEQPACKET feature bit support

Arseny Krasnov posted 1 patch 2 years, 10 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210622144747.2949134-1-arseny.krasnov@kaspersky.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
hw/virtio/vhost-vsock.c                       | 12 ++++++++++--
include/standard-headers/linux/virtio_vsock.h |  3 +++
2 files changed, 13 insertions(+), 2 deletions(-)
[PATCH v3] vhost-vsock: SOCK_SEQPACKET feature bit support
Posted by Arseny Krasnov 2 years, 10 months ago
This adds processing of VIRTIO_VSOCK_F_SEQPACKET features bit. Guest
negotiates it with vhost, thus both will know that SOCK_SEQPACKET
supported by peer.

Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>
---
 hw/virtio/vhost-vsock.c                       | 12 ++++++++++--
 include/standard-headers/linux/virtio_vsock.h |  3 +++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index c8f0699b4f..e6339747b3 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -20,6 +20,11 @@
 #include "hw/virtio/vhost-vsock.h"
 #include "monitor/monitor.h"
 
+const int feature_bits[] = {
+    VIRTIO_VSOCK_F_SEQPACKET,
+    VHOST_INVALID_FEATURE_BIT
+};
+
 static void vhost_vsock_get_config(VirtIODevice *vdev, uint8_t *config)
 {
     VHostVSock *vsock = VHOST_VSOCK(vdev);
@@ -107,8 +112,11 @@ static uint64_t vhost_vsock_get_features(VirtIODevice *vdev,
                                          uint64_t requested_features,
                                          Error **errp)
 {
-    /* No feature bits used yet */
-    return requested_features;
+    VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
+
+    virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET);
+    return vhost_get_features(&vvc->vhost_dev, feature_bits,
+                                requested_features);
 }
 
 static const VMStateDescription vmstate_virtio_vhost_vsock = {
diff --git a/include/standard-headers/linux/virtio_vsock.h b/include/standard-headers/linux/virtio_vsock.h
index be443211ce..5eac522ee2 100644
--- a/include/standard-headers/linux/virtio_vsock.h
+++ b/include/standard-headers/linux/virtio_vsock.h
@@ -38,6 +38,9 @@
 #include "standard-headers/linux/virtio_ids.h"
 #include "standard-headers/linux/virtio_config.h"
 
+/* The feature bitmap for virtio vsock */
+#define VIRTIO_VSOCK_F_SEQPACKET       1       /* SOCK_SEQPACKET supported */
+
 struct virtio_vsock_config {
 	uint64_t guest_cid;
 } QEMU_PACKED;
-- 
2.25.1


Re: [PATCH v3] vhost-vsock: SOCK_SEQPACKET feature bit support
Posted by Stefano Garzarella 2 years, 10 months ago
On Tue, Jun 22, 2021 at 05:47:47PM +0300, Arseny Krasnov wrote:
>This adds processing of VIRTIO_VSOCK_F_SEQPACKET features bit. Guest
>negotiates it with vhost, thus both will know that SOCK_SEQPACKET
>supported by peer.
>
>Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>
>---
> hw/virtio/vhost-vsock.c                       | 12 ++++++++++--
> include/standard-headers/linux/virtio_vsock.h |  3 +++
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
>diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
>index c8f0699b4f..e6339747b3 100644
>--- a/hw/virtio/vhost-vsock.c
>+++ b/hw/virtio/vhost-vsock.c
>@@ -20,6 +20,11 @@
> #include "hw/virtio/vhost-vsock.h"
> #include "monitor/monitor.h"
>
>+const int feature_bits[] = {
>+    VIRTIO_VSOCK_F_SEQPACKET,
>+    VHOST_INVALID_FEATURE_BIT
>+};
>+
> static void vhost_vsock_get_config(VirtIODevice *vdev, uint8_t *config)
> {
>     VHostVSock *vsock = VHOST_VSOCK(vdev);
>@@ -107,8 +112,11 @@ static uint64_t vhost_vsock_get_features(VirtIODevice *vdev,
>                                          uint64_t requested_features,
>                                          Error **errp)
> {
>-    /* No feature bits used yet */
>-    return requested_features;
>+    VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
>+
>+    virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET);
>+    return vhost_get_features(&vvc->vhost_dev, feature_bits,
>+                                requested_features);
> }
>
> static const VMStateDescription vmstate_virtio_vhost_vsock = {
>diff --git a/include/standard-headers/linux/virtio_vsock.h b/include/standard-headers/linux/virtio_vsock.h
>index be443211ce..5eac522ee2 100644
>--- a/include/standard-headers/linux/virtio_vsock.h
>+++ b/include/standard-headers/linux/virtio_vsock.h
>@@ -38,6 +38,9 @@
> #include "standard-headers/linux/virtio_ids.h"
> #include "standard-headers/linux/virtio_config.h"
>
>+/* The feature bitmap for virtio vsock */
>+#define VIRTIO_VSOCK_F_SEQPACKET       1       /* SOCK_SEQPACKET supported */
>+
> struct virtio_vsock_config {
> 	uint64_t guest_cid;
> } QEMU_PACKED;
>-- 
>2.25.1
>

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>