From: Marc-André Lureau <marcandre.lur...@redhat.com> vhost switches between masked notifier and guest notifier when unmasking. virtio_pci_vq_vector_unmask() checks if there was pending notification, but at the time it is checked, vhost-user backend doesn't guarantee that the switch happened yet, so it may lose some events.
To solve this vhost-user race, I introduced an extra "sync" call (waiting for a reply). One may want to make all/many vhost-user replies mandatories by adding a new capability instead. Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- hw/virtio/vhost.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4400718..692c38f 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1181,6 +1181,7 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, struct VirtQueue *vvq = virtio_get_queue(vdev, n); int r, index = n - hdev->vq_index; struct vhost_vring_file file; + uint64_t features; if (mask) { assert(vdev->use_guest_notifier_mask); @@ -1192,6 +1193,10 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, file.index = hdev->vhost_ops->vhost_get_vq_index(hdev, n); r = hdev->vhost_ops->vhost_set_vring_call(hdev, &file); assert(r >= 0); + + /* silly sync call to make sure the call fd has been received */ + r = hdev->vhost_ops->vhost_get_features(hdev, &features); + assert(r >= 0); } uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bits, -- 2.7.4