[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
- Re: [PATCH v3 03/12] vfio-user: define vfio-user-server object, (continued)
- [PATCH v3 04/12] vfio-user: instantiate vfio-user context, Jagannathan Raman, 2021/10/11
- [PATCH v3 05/12] vfio-user: find and init PCI device, Jagannathan Raman, 2021/10/11
- [PATCH v3 07/12] vfio-user: handle PCI config space accesses, Jagannathan Raman, 2021/10/11
- [PATCH v3 08/12] vfio-user: handle DMA mappings, Jagannathan Raman, 2021/10/11
- [PATCH v3 06/12] vfio-user: run vfio-user context, Jagannathan Raman, 2021/10/11
- [PATCH v3 10/12] vfio-user: handle device interrupts, Jagannathan Raman, 2021/10/11
- [PATCH v3 09/12] vfio-user: handle PCI BAR accesses, Jagannathan Raman, 2021/10/11
- [PATCH v3 11/12] vfio-user: register handlers to facilitate migration, Jagannathan Raman, 2021/10/11
- [PATCH v3 12/12] vfio-user: acceptance test, Jagannathan Raman, 2021/10/11
- Re: [PATCH v3 00/12] vfio-user server in QEMU, Stefan Hajnoczi, 2021/10/27