qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 06/12] vfio-user: run vfio-user context


From: John Levon
Subject: Re: [PATCH v3 06/12] vfio-user: run vfio-user context
Date: Thu, 28 Oct 2021 21:55:37 +0000

On Wed, Oct 27, 2021 at 05:21:30PM +0100, Stefan Hajnoczi wrote:

> > +static void vfu_object_ctx_run(void *opaque)
> > +{
> > +    VfuObject *o = opaque;
> > +    int ret = -1;
> > +
> > +    while (ret != 0) {
> > +        ret = vfu_run_ctx(o->vfu_ctx);
> > +        if (ret < 0) {
> > +            if (errno == EINTR) {
> > +                continue;
> > +            } else if (errno == ENOTCONN) {
> > +                qemu_set_fd_handler(o->vfu_poll_fd, NULL, NULL, NULL);
> > +                o->vfu_poll_fd = -1;
> > +                object_unparent(OBJECT(o));
> > +                break;
> > +            } else {
> > +                error_setg(&error_abort, "vfu: Failed to run device %s - 
> > %s",
> > +                           o->device, strerror(errno));
> > +                 break;
> > +            }
> 
> The libvfio-user.h doc comments say this function can return -1 (EAGAIN)
> when LIBVFIO_USER_FLAG_ATTACH_NB was used. Is the doc comment wrong
> since this patch seems to rely on vfu_run_ctx() returning 0 when there
> are no more commands to process?

 * @returns the number of requests processed (0 or more); or -1 on error,       
 
 *          with errno set as follows:

So in fact it does return 0. The EAGAIN line needs removing; I'll fix it
shortly.

> > +static void vfu_object_attach_ctx(void *opaque)
> > +{
> > +    VfuObject *o = opaque;
> > +    int ret;
> > +
> > +    qemu_set_fd_handler(o->vfu_poll_fd, NULL, NULL, NULL);
> > +    o->vfu_poll_fd = -1;
> > +
> > +retry_attach:
> > +    ret = vfu_attach_ctx(o->vfu_ctx);
> > +    if (ret < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
> > +        goto retry_attach;
> 
> Can we wait for the poll fd to become readable instead of spinning? I
> don't know the libvfio-user APIs so I'm not sure, but it would be nice
> to avoid a busy loop.

At this point, ->vfu_poll_fd is a listening socket, no reason why qemu couldn't
epoll on it.

regards
john


reply via email to

[Prev in Thread] Current Thread [Next in Thread]