[Qemu-devel] [PATCH] io: simplify qio_channel_attach_aio_context

Paolo Bonzini posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170526093641.7159-1-pbonzini@redhat.com
Test checkpatch passed
Test docker passed
Test s390x passed
io/channel.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
[Qemu-devel] [PATCH] io: simplify qio_channel_attach_aio_context
Posted by Paolo Bonzini 6 years, 11 months ago
If properly preceded by qio_channel_detach_aio_context, this function really
has nothing to do except setting ioc->ctx.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 io/channel.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/io/channel.c b/io/channel.c
index cdf74540c1..1cfb8b33a2 100644
--- a/io/channel.c
+++ b/io/channel.c
@@ -279,15 +279,9 @@ static void qio_channel_set_aio_fd_handlers(QIOChannel *ioc)
 void qio_channel_attach_aio_context(QIOChannel *ioc,
                                     AioContext *ctx)
 {
-    AioContext *old_ctx;
-    if (ioc->ctx == ctx) {
-        return;
-    }
-
-    old_ctx = ioc->ctx ? ioc->ctx : iohandler_get_aio_context();
-    qio_channel_set_aio_fd_handler(ioc, old_ctx, NULL, NULL, NULL);
+    assert(!ioc->read_coroutine);
+    assert(!ioc->write_coroutine);
     ioc->ctx = ctx;
-    qio_channel_set_aio_fd_handlers(ioc);
 }
 
 void qio_channel_detach_aio_context(QIOChannel *ioc)
-- 
2.13.0


Re: [Qemu-devel] [PATCH] io: simplify qio_channel_attach_aio_context
Posted by Daniel P. Berrange 6 years, 11 months ago
On Fri, May 26, 2017 at 11:36:41AM +0200, Paolo Bonzini wrote:
> If properly preceded by qio_channel_detach_aio_context, this function really
> has nothing to do except setting ioc->ctx.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  io/channel.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/io/channel.c b/io/channel.c
> index cdf74540c1..1cfb8b33a2 100644
> --- a/io/channel.c
> +++ b/io/channel.c
> @@ -279,15 +279,9 @@ static void qio_channel_set_aio_fd_handlers(QIOChannel *ioc)
>  void qio_channel_attach_aio_context(QIOChannel *ioc,
>                                      AioContext *ctx)
>  {
> -    AioContext *old_ctx;
> -    if (ioc->ctx == ctx) {
> -        return;
> -    }
> -
> -    old_ctx = ioc->ctx ? ioc->ctx : iohandler_get_aio_context();
> -    qio_channel_set_aio_fd_handler(ioc, old_ctx, NULL, NULL, NULL);
> +    assert(!ioc->read_coroutine);
> +    assert(!ioc->write_coroutine);
>      ioc->ctx = ctx;
> -    qio_channel_set_aio_fd_handlers(ioc);
>  }
>  
>  void qio_channel_detach_aio_context(QIOChannel *ioc)

Thanks, queued

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|