libvhost-user: advertise vring features
PATCH 1/1 libvhost-user: advertise vring features
libvhost-user implements several vring features without advertising them. There is no way for the vhost-user master to detect support for these features.
Things more or less work today because QEMU assumes the vhost-user backend always implements certain feature bits like VIRTIO_RING_F_EVENT_IDX. This is not documented anywhere.
This patch explicitly advertises features implemented in libvhost-user so that the vhost-user master does not need to make undocumented assumptions.
Feature bits that libvhost-user now advertises can be removed from vhost-user-blk.c. Devices should not be responsible for advertising vring feature bits, that is libvhost-user's job.
---
I have tested make check and virtiofsd.
--- contrib/libvhost-user/libvhost-user.c | 10 ++++++++++ contrib/vhost-user-blk/vhost-user-blk.c | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-)
contrib/libvhost-user/libvhost-user.c +10 -0
@@ -495,6 +495,16 @@ static bool vu_get_features_exec(VuDev *dev, VhostUserMsg *vmsg) { vmsg->payload.u64 = +/* +* The following VIRTIO feature bits are supported by our virtqueue +* implementation: +*/ +1ULL <<VIRTIO_F_NOTIFY_ON_EMPTY | +1ULL <<VIRTIO_RING_F_INDIRECT_DESC | +1ULL <<VIRTIO_RING_F_EVENT_IDX | +1ULL <<VIRTIO_F_VERSION_1 | + +/* vhost-user feature bits */ 1ULL <<VHOST_F_LOG_ALL |1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ;
contrib/vhost-user-blk/vhost-user-blk.c +1 -3
@@ -382,9 +382,7 @@ vub_get_features(VuDev *dev)1ull <<VIRTIO_BLK_F_DISCARD |1ull <<VIRTIO_BLK_F_WRITE_ZEROES | #endif -1ull <<VIRTIO_BLK_F_CONFIG_WCE | -1ull <<VIRTIO_F_VERSION_1 | -1ull <<VHOST_USER_F_PROTOCOL_FEATURES ; +1ull <<VIRTIO_BLK_F_CONFIG_WCE ;if (vdev_blk->enable_ro) { features |=1ull <<VIRTIO_BLK_F_RO ;
Signature · 1 line
2.25.4
Hi
Quoted 13 lines · Stefan Hajnoczi
libvhost-user implements several vring features without advertising them. There is no way for the vhost-user master to detect support for these features.
Things more or less work today because QEMU assumes the vhost-user backend always implements certain feature bits like
VIRTIO_RING_F_EVENT_IDX. This is not documented anywhere.This patch explicitly advertises features implemented in libvhost-user so that the vhost-user master does not need to make undocumented assumptions.
Quoted 8 lines
Feature bits that libvhost-user now advertises can be removed from
vhost-user-blk.c. Devices should not be responsible for advertising vring feature bits, that is libvhost-user's job.Cc Marc-André Lureau <[email protected]>Cc Jason Wang <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 46 lines
---
I have tested make check and virtiofsd.--- contrib/libvhost-user/libvhost-user.c | 10 ++++++++++ contrib/vhost-user-blk/vhost-user-blk.c | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-)contrib/libvhost-user/libvhost-user.c +10
-0@@ -495,6 +495,16 @@ static bool vu_get_features_exec(VuDev *dev, VhostUserMsg *vmsg) { vmsg->payload.u64 = +/* +* The following VIRTIO feature bits are supported by our virtqueue +* implementation: +*/ +1ULL <<VIRTIO_F_NOTIFY_ON_EMPTY | +1ULL <<VIRTIO_RING_F_INDIRECT_DESC | +1ULL <<VIRTIO_RING_F_EVENT_IDX | +1ULL <<VIRTIO_F_VERSION_1 | + +/* vhost-user feature bits */ 1ULL <<VHOST_F_LOG_ALL |1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ;contrib/vhost-user-blk/vhost-user-blk.c +1
-4@@ -382,9 +382,7 @@ vub_get_features(VuDev *dev)1ull <<VIRTIO_BLK_F_DISCARD |1ull <<VIRTIO_BLK_F_WRITE_ZEROES | #endif -1ull <<VIRTIO_BLK_F_CONFIG_WCE | -1ull <<VIRTIO_F_VERSION_1 | -1ull <<VHOST_USER_F_PROTOCOL_FEATURES ; +1ull <<VIRTIO_BLK_F_CONFIG_WCE ;if (vdev_blk->enable_ro) { features |=1ull <<VIRTIO_BLK_F_RO ; --2.25.4