[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] io: add methods to set I/O handlers on AioC
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] io: add methods to set I/O handlers on AioContext |
Date: |
Wed, 4 Jan 2017 17:14:17 +0000 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Fri, Dec 23, 2016 at 07:26:39PM +0100, Paolo Bonzini wrote:
> This is in preparation for making qio_channel_yield work on
> AioContexts other than the main one.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> include/io/channel.h | 42 ++++++++++++++++++++++++++++++++++++++++++
> io/channel-socket.c | 16 +++++++++++-----
> io/channel-tls.c | 12 ++++++++++++
> io/channel-watch.c | 6 ++++++
> io/channel.c | 25 +++++++++++++++++++++++++
> 5 files changed, 96 insertions(+), 5 deletions(-)
>
> /**
> + * qio_channel_set_aio_context:
> + * @ioc: the channel object
> + * @ctx: the #AioContext to set the handlers on
> + *
> + * Request that qio_channel_yield() sets I/O handlers on
> + * the given #AioContext. If @ctx is %NULL, qio_channel_yield()
> + * uses QEMU's main thread event loop.
> + */
> +void qio_channel_set_aio_context(QIOChannel *ioc,
> + AioContext *ctx);
> +
> +/**
> * qio_channel_yield:
> * @ioc: the channel object
> * @condition: the I/O condition to wait for
> @@ -525,4 +548,23 @@ void qio_channel_yield(QIOChannel *ioc,
> void qio_channel_wait(QIOChannel *ioc,
> GIOCondition condition);
>
> +/**
> + * qio_channel_set_fd_handler:
> + * @ioc: the channel object
> + * @ctx: the AioContext to set the handlers on
> + * @io_read: the read handler
> + * @io_write: the write handler
> + * @opaque: the opaque value passed to the handler
> + *
> + * This is used internally by qio_channel_yield(). It can
> + * be used by channel implementations to forward the handlers
> + * to another channel (e.g. from #QIOChannelTLS to the
> + * underlying socket).
> + */
> +void qio_channel_set_fd_handler(QIOChannel *ioc,
> + AioContext *ctx,
> + IOHandler *io_read,
> + IOHandler *io_write,
> + void *opaque);
nitpick - could we call set '...set_aio_fd_handler' or '..set_aio_handler'
> diff --git a/io/channel-socket.c b/io/channel-socket.c
> index d7e03f6..4d5f180 100644
> --- a/io/channel-socket.c
> +++ b/io/channel-socket.c
> diff --git a/io/channel.c b/io/channel.c
> index 80924c1..9ef683c 100644
> --- a/io/channel.c
> +++ b/io/channel.c
> @@ -244,6 +255,20 @@ static gboolean qio_channel_yield_enter(QIOChannel *ioc,
> }
>
>
> +void qio_channel_set_aio_context(QIOChannel *ioc,
> + AioContext *ctx)
> +{
> + if (ioc->ctx == ctx) {
> + return;
> + }
> +
> + qio_channel_set_fd_handler(ioc,
> + ioc->ctx ? ioc->ctx :
> iohandler_get_aio_context(),
Max line length exceeded.
> + NULL, NULL, NULL);
> + ioc->ctx = ctx;
> + qio_channel_set_fd_handlers(ioc);
This method does not exist in this patch - only added by the next
patch.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|