[PATCH 19/33] vhost: vhost_dev_init(): drop extra features variable

Vladimir Sementsov-Ogievskiy posted 33 patches 3 months ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, Zhenwei Pi <pizhenwei@bytedance.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Raphael Norwitz <raphael@enfabrica.net>, Jason Wang <jasowang@redhat.com>, Fam Zheng <fam@euphon.net>, "Alex Bennée" <alex.bennee@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
[PATCH 19/33] vhost: vhost_dev_init(): drop extra features variable
Posted by Vladimir Sementsov-Ogievskiy 3 months ago
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 hw/virtio/vhost.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index f9163ba895..e796ad347d 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1596,7 +1596,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
                    VhostBackendType backend_type, uint32_t busyloop_timeout,
                    Error **errp)
 {
-    uint64_t features;
     int i, r, n_initialized_vqs = 0;
 
     hdev->vdev = NULL;
@@ -1616,7 +1615,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
         goto fail;
     }
 
-    r = hdev->vhost_ops->vhost_get_features(hdev, &features);
+    r = hdev->vhost_ops->vhost_get_features(hdev, &hdev->_features);
     if (r < 0) {
         error_setg_errno(errp, -r, "vhost_get_features failed");
         goto fail;
@@ -1631,8 +1630,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
         }
     }
 
-    hdev->_features = features;
-
     hdev->memory_listener = (MemoryListener) {
         .name = "vhost",
         .begin = vhost_begin,
-- 
2.48.1
Re: [PATCH 19/33] vhost: vhost_dev_init(): drop extra features variable
Posted by Raphael Norwitz 1 month ago
Looks like this patch no longer applies cleanly but looks like the
same cleanup to drop the local array may be fine?

On Wed, Aug 13, 2025 at 12:51 PM Vladimir Sementsov-Ogievskiy
<vsementsov@yandex-team.ru> wrote:
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  hw/virtio/vhost.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index f9163ba895..e796ad347d 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1596,7 +1596,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>                     VhostBackendType backend_type, uint32_t busyloop_timeout,
>                     Error **errp)
>  {
> -    uint64_t features;
>      int i, r, n_initialized_vqs = 0;
>
>      hdev->vdev = NULL;
> @@ -1616,7 +1615,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>          goto fail;
>      }
>
> -    r = hdev->vhost_ops->vhost_get_features(hdev, &features);
> +    r = hdev->vhost_ops->vhost_get_features(hdev, &hdev->_features);
>      if (r < 0) {
>          error_setg_errno(errp, -r, "vhost_get_features failed");
>          goto fail;
> @@ -1631,8 +1630,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>          }
>      }
>
> -    hdev->_features = features;
> -
>      hdev->memory_listener = (MemoryListener) {
>          .name = "vhost",
>          .begin = vhost_begin,
> --
> 2.48.1
>
>
Re: [PATCH 19/33] vhost: vhost_dev_init(): drop extra features variable
Posted by Vladimir Sementsov-Ogievskiy 1 month ago
On 09.10.25 22:06, Raphael Norwitz wrote:
> Looks like this patch no longer applies cleanly but looks like the
> same cleanup to drop the local array may be fine?

Yes, seems we can do simply

vhost_dev_get_features(hdev, hdev->features_ex)

without extra copying.

> 
> On Wed, Aug 13, 2025 at 12:51 PM Vladimir Sementsov-Ogievskiy
> <vsementsov@yandex-team.ru> wrote:
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> ---
>>   hw/virtio/vhost.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>> index f9163ba895..e796ad347d 100644
>> --- a/hw/virtio/vhost.c
>> +++ b/hw/virtio/vhost.c
>> @@ -1596,7 +1596,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>>                      VhostBackendType backend_type, uint32_t busyloop_timeout,
>>                      Error **errp)
>>   {
>> -    uint64_t features;
>>       int i, r, n_initialized_vqs = 0;
>>
>>       hdev->vdev = NULL;
>> @@ -1616,7 +1615,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>>           goto fail;
>>       }
>>
>> -    r = hdev->vhost_ops->vhost_get_features(hdev, &features);
>> +    r = hdev->vhost_ops->vhost_get_features(hdev, &hdev->_features);
>>       if (r < 0) {
>>           error_setg_errno(errp, -r, "vhost_get_features failed");
>>           goto fail;
>> @@ -1631,8 +1630,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>>           }
>>       }
>>
>> -    hdev->_features = features;
>> -
>>       hdev->memory_listener = (MemoryListener) {
>>           .name = "vhost",
>>           .begin = vhost_begin,
>> --
>> 2.48.1
>>
>>


-- 
Best regards,
Vladimir