vhost-user injects a kick by writing to the fd it has just passed to the back-end. With an eventfd that fd is writable, but when pipes are used it is the read end and the write fails.
Instead, kick via event_notifier_set() on the queue's host notifier, which writes to the correct end in both cases. Signed-off-by: Tim Pambor <[email protected]> --- hw/virtio/vhost-user.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 65889b0776..b817b15d0b 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1527,16 +1527,9 @@ static int vhost_user_set_vring_kick(struct vhost_dev *dev, * receiving a kick. The spec suggests this to improve compatibility. */ if (file->fd != -1) { - uint64_t val = 1; - ssize_t nwritten; + VirtQueue *vq = virtio_get_queue(dev->vdev, file->index); - do { - nwritten = write(file->fd, &val, sizeof(val)); - } while (nwritten < 0 && errno == EINTR); - - if (nwritten < 0 && errno != EAGAIN /* back-end can already read */) { - return -errno; - } + return event_notifier_set(virtio_queue_get_host_notifier(vq)); } return 0; -- 2.55.0
