@@ -31,6 +31,8 @@ typedef struct vhost_vdpa {
bool iotlb_batch_begin_sent;
MemoryListener listener;
struct vhost_vdpa_iova_range iova_range;
+ /* VirtIO device features that can be emulated by qemu */
+ uint64_t added_features;
uint64_t acked_features;
bool shadow_vqs_enabled;
/* IOVA mapping used by the Shadow Virtqueue */
@@ -660,8 +660,8 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev,
v->acked_features = features;
- /* We must not ack _F_LOG if SVQ is enabled */
- features &= ~BIT_ULL(VHOST_F_LOG_ALL);
+ /* Do not ack features emulated by qemu */
+ features &= ~v->added_features;
}
trace_vhost_vdpa_set_features(dev, features);
@@ -1244,8 +1244,8 @@ static int vhost_vdpa_get_features(struct vhost_dev *dev,
int ret = vhost_vdpa_get_dev_features(dev, features);
if (ret == 0 && v->shadow_vqs_enabled) {
- /* Add SVQ logging capabilities */
- *features |= BIT_ULL(VHOST_F_LOG_ALL);
+ /* Add emulated capabilities */
+ *features |= v->added_features;
}
return ret;
@@ -600,6 +600,10 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
s->vhost_vdpa.index = queue_pair_index;
s->vhost_vdpa.shadow_vqs_enabled = svq;
s->vhost_vdpa.iova_tree = iova_tree;
+ if (svq) {
+ /* Add SVQ logging capabilities */
+ s->vhost_vdpa.added_features |= BIT_ULL(VHOST_F_LOG_ALL);
+ }
if (!is_datapath) {
s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
vhost_vdpa_net_cvq_cmd_page_len());
At this moment only _F_LOG is added there. However future patches add features that depend on the kind of device. In particular, only net devices can add VIRTIO_F_GUEST_ANNOUNCE. So let's allow vhost_vdpa creator to set custom emulated device features. Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com> --- include/hw/virtio/vhost-vdpa.h | 2 ++ hw/virtio/vhost-vdpa.c | 8 ++++---- net/vhost-vdpa.c | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-)