qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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.

Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200529161338.456017-1-stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

authored by

Stefan Hajnoczi and committed by
Michael S. Tsirkin
a9a5c473 b650d5f4

+11 -3
+10
contrib/libvhost-user/libvhost-user.c
··· 498 498 vu_get_features_exec(VuDev *dev, VhostUserMsg *vmsg) 499 499 { 500 500 vmsg->payload.u64 = 501 + /* 502 + * The following VIRTIO feature bits are supported by our virtqueue 503 + * implementation: 504 + */ 505 + 1ULL << VIRTIO_F_NOTIFY_ON_EMPTY | 506 + 1ULL << VIRTIO_RING_F_INDIRECT_DESC | 507 + 1ULL << VIRTIO_RING_F_EVENT_IDX | 508 + 1ULL << VIRTIO_F_VERSION_1 | 509 + 510 + /* vhost-user feature bits */ 501 511 1ULL << VHOST_F_LOG_ALL | 502 512 1ULL << VHOST_USER_F_PROTOCOL_FEATURES; 503 513
+1 -3
contrib/vhost-user-blk/vhost-user-blk.c
··· 382 382 1ull << VIRTIO_BLK_F_DISCARD | 383 383 1ull << VIRTIO_BLK_F_WRITE_ZEROES | 384 384 #endif 385 - 1ull << VIRTIO_BLK_F_CONFIG_WCE | 386 - 1ull << VIRTIO_F_VERSION_1 | 387 - 1ull << VHOST_USER_F_PROTOCOL_FEATURES; 385 + 1ull << VIRTIO_BLK_F_CONFIG_WCE; 388 386 389 387 if (vdev_blk->enable_ro) { 390 388 features |= 1ull << VIRTIO_BLK_F_RO;