@samitouri / QOSamiQemu / commits / 3aedf875ed

vhost: vhost_dev_init(): simplify features initialization

Drop extra variable and extra function parameter passing, initialize dev._features directly. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Daniil Tatianin <d-tatianin@yandex-team.ru> Reviewed-by: Raphael Norwitz <raphael.s.norwitz@gmail.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260420200339.708640-19-vsementsov@yandex-team.ru>

Vladimir Sementsov-Ogievskiy committed Apr 20, 2026 at 23:03 UTC 3aedf875edd5fd2d595b4f1755a8ef2830963612
1 file changed +5 -9
hw/virtio/vhost.c
+5 -9
@@ -1560,18 +1560,17 @@ static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq)
1560 }
1561 }
1562
1563 -static int vhost_dev_get_features(struct vhost_dev *hdev,
1564 - uint64_t *features)
1563 +static int vhost_dev_init_features(struct vhost_dev *hdev)
1564 {
1565 uint64_t features64;
1566 int r;
1567
1568 if (hdev->vhost_ops->vhost_get_features_ex) {
1570 - return hdev->vhost_ops->vhost_get_features_ex(hdev, features);
1569 + return hdev->vhost_ops->vhost_get_features_ex(hdev, hdev->_features_ex);
1570 }
1571
1572 r = hdev->vhost_ops->vhost_get_features(hdev, &features64);
1574 - virtio_features_from_u64(features, features64);
1573 + virtio_features_from_u64(hdev->_features_ex, features64);
1574 return r;
1575 }
1576
@@ -1579,7 +1578,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
1578 VhostBackendType backend_type, uint32_t busyloop_timeout,
1579 Error **errp)
1580 {
1582 - uint64_t features[VIRTIO_FEATURES_NU64S];
1581 unsigned int used, reserved, limit;
1582 int i, r, n_initialized_vqs = 0;
1583
@@ -1600,9 +1598,9 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
1598 goto fail;
1599 }
1600
1603 - r = vhost_dev_get_features(hdev, features);
1601 + r = vhost_dev_init_features(hdev);
1602 if (r < 0) {
1605 - error_setg_errno(errp, -r, "vhost_get_features failed");
1603 + error_setg_errno(errp, -r, "vhost_init_features failed");
1604 goto fail;
1605 }
1606
@@ -1628,8 +1626,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
1626 }
1627 }
1628
1631 - virtio_features_copy(hdev->_features_ex, features);
1632 -
1629 hdev->memory_listener = (MemoryListener) {
1630 .name = "vhost",
1631 .begin = vhost_begin,