On Thu, Feb 21, 2013 at 05:38:04PM -0600, mdroth wrote: > On Thu, Feb 21, 2013 at 11:12:01PM +0100, Paolo Bonzini wrote: > > Il 21/02/2013 22:07, mdroth ha scritto: > > >> > > > >> > 100% agree. In particular hw/dataplane/event-poll.c should be the > > >> > first > > >> > to go away, but AioContext provides the functionality that Ping Fan > > >> > needs. But hw/dataplane/vring.c will probably be here for a longer > > > Has there been any discussion around introducing something similar to > > > AioContexts for fd handlers? This would avoid the dataplane-specific hooks > > > needed for NetClients in this series. > > > > AioContext can include file descriptors on POSIX systems (used for NBD > > and other network backends), see aio_set_fd_handler. > > Sorry, was using "fd handlers" too generally. I mean specifically for > the qemu_set_fd_handler interfaces, where we currently rely on a single list > of IOHandlerRecords for registration and a single loop to drive them. Would > be nice if we could drive subsets of those via mini main loops, similar to the > way dataplane threads would with a particular AioContext via aio_poll (or > perhaps > the exact same way) > > Currently, Ping Fan's patches basically do this already by accessing a > global reference to the vnet worker thread and attaching events/handlers to > it's event loop via a new set of registration functions (PATCH 7). > > I think generalizing this by basing qemu_set_fd_handler() around > AioContext, or something similar, would help to extend support to other > NetClient implementations without requiring dataplane-specific hooks > throughout.
We used to have a nesting feature that we got rid of. I don't remember the details but basically a nesting level counter: aio_set_fd_handler(...); /* fd at level N */ aio_nesting_inc(); aio_set_fd_handler(...); /* fd at level N+1 */ aio_poll(); /* just this fd */ aio_nesting_dec(); aio_poll(); /* both fds */ Then aio_poll() only considers fds which are greater than or equal to the current nesting level. I remember disliking this feature but maybe it was just being used badly rather than the mechanism itself being bad. Stefan