qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC 3/5] nbd: Use aio_set_fd_handler2()


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [RFC 3/5] nbd: Use aio_set_fd_handler2()
Date: Mon, 9 Jun 2014 15:35:18 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Sat, Jun 07, 2014 at 09:27:26PM +0200, Max Reitz wrote:
> On 06.06.2014 09:44, Paolo Bonzini wrote:
> >Il 05/06/2014 20:18, Max Reitz ha scritto:
> >>>
> >>>Why is this design cleaner?  Because NBD code doesn't have to worry
> >>>about fd handlers.  It uses straightforward coroutine send/recv for
> >>>socket I/O inside nbd_read_req() and nbd_write_resp().  It's easy to
> >>>see
> >>>that only one coroutine receives from the socket and that only one
> >>>coroutine writes to the socket.
> >>
> >>Yes, this sounds better. I'll take a look into it and see how far I can
> >>get.
> >
> >But it doesn't solve any problem, and requires rethinking the
> >aio_set_fd_handler API.
> 
> It might clean things up. :-)
> 
> On the other hand, you are right, it's probably too complicated right now.
> 
> >I suggest you just refactor all calls to qemu_set_fd_handler2 into a
> >function like
> >
> >    qemu_set_fd_handler2(fd, NULL,
> >                 nbd_can_read(client) ? nbd_read : NULL,
> >                 client->send_coroutine ?
> >                    nbd_restart_write : NULL,
> >                 opaque);
> >
> >and call this function every time the result of nbd_can_read() changes.
> >Then you can switch to aio_set_fd_handler easily.
> 
> Seems good, I'll do that.

Sounds fine to me.  Restructuring NBD can be done later, if desirable.

Stefan

Attachment: pgpkYSQVHrbfz.pgp
Description: PGP signature


reply via email to

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