qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] yield_until_fd_readable: make it work with any AioContect
@ 2019-10-24  4:56 Dietmar Maurer
  2019-10-25 12:38 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Dietmar Maurer @ 2019-10-24  4:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dietmar Maurer, stefanha

Simply use qemu_get_current_aio_context().

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
---
Changelog for v4:

- avoid unsafe cast and keep fd_coroutine_enter()

Changelog for v3:

- use (IOHandler *) instead of ((void (*)(void *))
- coding style: fix max line length

Changelog for v2:

- use correct read handler in aio_set_fd_handler (instead of write handler)

 util/qemu-coroutine-io.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/util/qemu-coroutine-io.c b/util/qemu-coroutine-io.c
index 44a8969a69..5b80bb416f 100644
--- a/util/qemu-coroutine-io.c
+++ b/util/qemu-coroutine-io.c
@@ -67,6 +67,7 @@ qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send)
 }
 
 typedef struct {
+    AioContext *ctx;
     Coroutine *co;
     int fd;
 } FDYieldUntilData;
@@ -74,7 +75,7 @@ typedef struct {
 static void fd_coroutine_enter(void *opaque)
 {
     FDYieldUntilData *data = opaque;
-    qemu_set_fd_handler(data->fd, NULL, NULL, NULL);
+    aio_set_fd_handler(data->ctx, data->fd, false, NULL, NULL, NULL, NULL);
     qemu_coroutine_enter(data->co);
 }
 
@@ -83,8 +84,10 @@ void coroutine_fn yield_until_fd_readable(int fd)
     FDYieldUntilData data;
 
     assert(qemu_in_coroutine());
+    data.ctx = qemu_get_current_aio_context();
     data.co = qemu_coroutine_self();
     data.fd = fd;
-    qemu_set_fd_handler(fd, fd_coroutine_enter, NULL, &data);
+    aio_set_fd_handler(
+        data.ctx, fd, false, fd_coroutine_enter, NULL, NULL, &data);
     qemu_coroutine_yield();
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] yield_until_fd_readable: make it work with any AioContect
  2019-10-24  4:56 [PATCH v4] yield_until_fd_readable: make it work with any AioContect Dietmar Maurer
@ 2019-10-25 12:38 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2019-10-25 12:38 UTC (permalink / raw)
  To: Dietmar Maurer; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 677 bytes --]

On Thu, Oct 24, 2019 at 06:56:10AM +0200, Dietmar Maurer wrote:
> Simply use qemu_get_current_aio_context().
> 
> Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
> ---
> Changelog for v4:
> 
> - avoid unsafe cast and keep fd_coroutine_enter()
> 
> Changelog for v3:
> 
> - use (IOHandler *) instead of ((void (*)(void *))
> - coding style: fix max line length
> 
> Changelog for v2:
> 
> - use correct read handler in aio_set_fd_handler (instead of write handler)
> 
>  util/qemu-coroutine-io.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-25 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24  4:56 [PATCH v4] yield_until_fd_readable: make it work with any AioContect Dietmar Maurer
2019-10-25 12:38 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).