diff mbox series

[v2] vhost-vsock: SOCK_SEQPACKET feature bit support

Message ID 20210622121631.2916319-1-arseny.krasnov@kaspersky.com (mailing list archive)
State New, archived
Headers show
Series [v2] vhost-vsock: SOCK_SEQPACKET feature bit support | expand

Commit Message

Arseny Krasnov June 22, 2021, 12:16 p.m. UTC
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(-)

Comments

Stefano Garzarella June 22, 2021, 2:41 p.m. UTC | #1
On Tue, Jun 22, 2021 at 03:16:31PM +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..0406a5d3dc 100644
>--- a/hw/virtio/vhost-vsock.c
>+++ b/hw/virtio/vhost-vsock.c
>@@ -103,12 +103,20 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status)
>     }
> }
>

If you have to resend, better move this to the beginning of the file, 
right after the includes.

>+const int feature_bits[] = {
>+    VIRTIO_VSOCK_F_SEQPACKET,
>+    VHOST_INVALID_FEATURE_BIT
>+};
>+
> 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
>

LGTM:

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Arseny Krasnov June 22, 2021, 2:48 p.m. UTC | #2
On 22.06.2021 17:41, Stefano Garzarella wrote:
> On Tue, Jun 22, 2021 at 03:16:31PM +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..0406a5d3dc 100644
>> --- a/hw/virtio/vhost-vsock.c
>> +++ b/hw/virtio/vhost-vsock.c
>> @@ -103,12 +103,20 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status)
>>     }
>> }
>>
> If you have to resend, better move this to the beginning of the file, 
> right after the includes.
Done
>> +const int feature_bits[] = {
>> +    VIRTIO_VSOCK_F_SEQPACKET,
>> +    VHOST_INVALID_FEATURE_BIT
>> +};
>> +
>> 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
>>
> LGTM:
>
> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
>
>
diff mbox series

Patch

diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index c8f0699b4f..0406a5d3dc 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -103,12 +103,20 @@  static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status)
     }
 }
 
+const int feature_bits[] = {
+    VIRTIO_VSOCK_F_SEQPACKET,
+    VHOST_INVALID_FEATURE_BIT
+};
+
 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;