On Thu, Oct 22, 2026 at 03:47:23PM +0200, Tim Pambor wrote: > When a ring is started, it may already hold requests: ones the driver > queued while the back-end was away and ones the previous instance left > in flight. The spec says front-ends SHOULD send a kick after > SET_VRING_KICK and back-ends SHOULD NOT rely on it, so libvhost-user > kicks itself by writing to the kick fd it has received from the > front-end. With an eventfd that fd is writable, but when pipes are used > it is the read end and the write fails.
This was something we added to clarify the spec, not sure if it's worth to add all of this code for something like that. That said, what about only setting kick_pending in vu_set_vring_kick_exec(), and running the handler of the pending queues at the end of vu_dispatch(), after the reply is sent? > > Replace it with a notifier the library owns. vu_init() creates it, the > embedder watches its read end through set_watch() like a kick fd, and > the library writes it when a started ring has available entries or > in-flight requests to resubmit. The watch callback drains it and runs > the handler of every queue flagged kick_pending. This way the handler > still runs from the event loop after the reply to SET_VRING_KICK has > gone out, as with the kick-fd self-kick. > > Signed-off-by: Tim Pambor <[email protected]> > --- > subprojects/libvhost-user/libvhost-user.c | 145 > +++++++++++++++++++++++++++--- > subprojects/libvhost-user/libvhost-user.h | 10 +++ > 2 files changed, 141 insertions(+), 14 deletions(-) > > diff --git a/subprojects/libvhost-user/libvhost-user.c > b/subprojects/libvhost-user/libvhost-user.c > index 2fed792e85..e323e32cab 100644 > --- a/subprojects/libvhost-user/libvhost-user.c > +++ b/subprojects/libvhost-user/libvhost-user.c > @@ -23,6 +23,7 @@ > #include <unistd.h> > #include <stdarg.h> > #include <errno.h> > +#include <fcntl.h> > #include <string.h> > #include <assert.h> > #include <inttypes.h> > @@ -40,7 +41,6 @@ > > #if defined(__linux__) > #include <sys/syscall.h> > -#include <fcntl.h> > #include <sys/ioctl.h> > #include <linux/vhost.h> > #include <sys/vfs.h> > @@ -1305,6 +1305,7 @@ vu_get_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg) > vmsg->size = sizeof(vmsg->payload.state); > > dev->vq[index].started = false; > + dev->vq[index].kick_pending = false; > if (dev->iface->queue_set_started) { > dev->iface->queue_set_started(dev, index, false); > } > @@ -1440,6 +1441,121 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq) > return 0; > } > > +static bool > +vu_self_kick_init(VuDev *dev) > +{ > +#ifdef CONFIG_EVENTFD Can you check if CONFIG_EVENTFD is defined when building libvhost-user? IIRC I used it, but now I'm thinking if we really have it defined. Thanks, Stefano
