[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 08/14] vhost: make sure call fd has been received
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [RFC 08/14] vhost: make sure call fd has been received |
Date: |
Sat, 4 Jun 2016 23:33:17 +0200 |
From: Marc-André Lureau <address@hidden>
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 <address@hidden>
---
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
- [Qemu-devel] [RFC 01/14] Add qemu_chr_open_socket(), (continued)
- [Qemu-devel] [RFC 01/14] Add qemu_chr_open_socket(), marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 07/14] misc: rename virtio-gpu.h header guard, marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 04/14] vhost-user: add vhost_user_input_get_config(), marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 09/14] qemu-char: use READ_RETRIES, marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 11/14] console: add dpy_gl_scanout2(), marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 05/14] Add vhost-user backend to virtio-input-host, marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 08/14] vhost: make sure call fd has been received,
marcandre . lureau <=
- [Qemu-devel] [RFC 06/14] contrib: add vhost-user-input, marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 10/14] qemu-char: block during sync read, marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 12/14] contrib: add vhost-user-gpu, marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 13/14] vhost-user: add vhost_user_gpu_set_socket(), marcandre . lureau, 2016/06/04
- [Qemu-devel] [RFC 14/14] Add virtio-gpu vhost-user backend, marcandre . lureau, 2016/06/04
- Re: [Qemu-devel] [RFC 00/14] vhost-user backends for gpu & input virtio devices, Marc-André Lureau, 2016/06/06