All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] qmp: fix aio_poll() assertion failure on Windows
@ 2020-10-21  6:40 Volker Rümelin
  2020-10-21 14:51 ` Stefan Hajnoczi
  2020-11-02 12:50 ` Mark Cave-Ayland
  0 siblings, 2 replies; 3+ messages in thread
From: Volker Rümelin @ 2020-10-21  6:40 UTC (permalink / raw)
  To: Kevin Wolf, Markus Armbruster, Stefan Hajnoczi, Fam Zheng, Stefan Weil
  Cc: qemu-devel, qemu-block

Commit 9ce44e2ce2 "qmp: Move dispatcher to a coroutine" modified
aio_poll() in util/aio-posix.c to avoid an assertion failure. This
change is missing in util/aio-win32.c.

Apply the changes to util/aio-posix.c to util/aio-win32.c too.
This fixes an assertion failure on Windows whenever QEMU exits.

$ ./qemu-system-x86_64.exe -machine pc,accel=tcg -display gtk
**
ERROR:../qemu/util/aio-win32.c:337:aio_poll: assertion failed:
(in_aio_context_home_thread(ctx))
Bail out! ERROR:../qemu/util/aio-win32.c:337:aio_poll: assertion
failed: (in_aio_context_home_thread(ctx))

Fixes: 9ce44e2ce2 ("qmp: Move dispatcher to a coroutine")
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 util/aio-win32.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/util/aio-win32.c b/util/aio-win32.c
index e7b1d649e9..168717b51b 100644
--- a/util/aio-win32.c
+++ b/util/aio-win32.c
@@ -18,6 +18,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "block/block.h"
+#include "qemu/main-loop.h"
 #include "qemu/queue.h"
 #include "qemu/sockets.h"
 #include "qapi/error.h"
@@ -333,8 +334,13 @@ bool aio_poll(AioContext *ctx, bool blocking)
      * There cannot be two concurrent aio_poll calls for the same AioContext (or
      * an aio_poll concurrent with a GSource prepare/check/dispatch callback).
      * We rely on this below to avoid slow locked accesses to ctx->notify_me.
+     *
+     * aio_poll() may only be called in the AioContext's thread. iohandler_ctx
+     * is special in that it runs in the main thread, but that thread's context
+     * is qemu_aio_context.
      */
-    assert(in_aio_context_home_thread(ctx));
+    assert(in_aio_context_home_thread(ctx == iohandler_get_aio_context() ?
+                                      qemu_get_aio_context() : ctx));
     progress = false;
 
     /* aio_notify can avoid the expensive event_notifier_set if
-- 
2.26.2



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

* Re: [PATCH] qmp: fix aio_poll() assertion failure on Windows
  2020-10-21  6:40 [PATCH] qmp: fix aio_poll() assertion failure on Windows Volker Rümelin
@ 2020-10-21 14:51 ` Stefan Hajnoczi
  2020-11-02 12:50 ` Mark Cave-Ayland
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2020-10-21 14:51 UTC (permalink / raw)
  To: Volker Rümelin
  Cc: Kevin Wolf, Fam Zheng, qemu-block, Stefan Weil, qemu-devel,
	Markus Armbruster

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

On Wed, Oct 21, 2020 at 08:40:33AM +0200, Volker Rümelin wrote:
> Commit 9ce44e2ce2 "qmp: Move dispatcher to a coroutine" modified
> aio_poll() in util/aio-posix.c to avoid an assertion failure. This
> change is missing in util/aio-win32.c.
> 
> Apply the changes to util/aio-posix.c to util/aio-win32.c too.
> This fixes an assertion failure on Windows whenever QEMU exits.
> 
> $ ./qemu-system-x86_64.exe -machine pc,accel=tcg -display gtk
> **
> ERROR:../qemu/util/aio-win32.c:337:aio_poll: assertion failed:
> (in_aio_context_home_thread(ctx))
> Bail out! ERROR:../qemu/util/aio-win32.c:337:aio_poll: assertion
> failed: (in_aio_context_home_thread(ctx))
> 
> Fixes: 9ce44e2ce2 ("qmp: Move dispatcher to a coroutine")
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> ---
>  util/aio-win32.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Thanks, applied to my block-next tree:
https://gitlab.com/stefanha/qemu/commits/block-next

Stefan

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

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

* Re: [PATCH] qmp: fix aio_poll() assertion failure on Windows
  2020-10-21  6:40 [PATCH] qmp: fix aio_poll() assertion failure on Windows Volker Rümelin
  2020-10-21 14:51 ` Stefan Hajnoczi
@ 2020-11-02 12:50 ` Mark Cave-Ayland
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Cave-Ayland @ 2020-11-02 12:50 UTC (permalink / raw)
  To: Volker Rümelin, Kevin Wolf, Markus Armbruster,
	Stefan Hajnoczi, Fam Zheng, Stefan Weil
  Cc: qemu-devel, qemu-block

On 21/10/2020 07:40, Volker Rümelin wrote:

> Commit 9ce44e2ce2 "qmp: Move dispatcher to a coroutine" modified
> aio_poll() in util/aio-posix.c to avoid an assertion failure. This
> change is missing in util/aio-win32.c.
> 
> Apply the changes to util/aio-posix.c to util/aio-win32.c too.
> This fixes an assertion failure on Windows whenever QEMU exits.
> 
> $ ./qemu-system-x86_64.exe -machine pc,accel=tcg -display gtk
> **
> ERROR:../qemu/util/aio-win32.c:337:aio_poll: assertion failed:
> (in_aio_context_home_thread(ctx))
> Bail out! ERROR:../qemu/util/aio-win32.c:337:aio_poll: assertion
> failed: (in_aio_context_home_thread(ctx))
> 
> Fixes: 9ce44e2ce2 ("qmp: Move dispatcher to a coroutine")
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> ---
>   util/aio-win32.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/util/aio-win32.c b/util/aio-win32.c
> index e7b1d649e9..168717b51b 100644
> --- a/util/aio-win32.c
> +++ b/util/aio-win32.c
> @@ -18,6 +18,7 @@
>   #include "qemu/osdep.h"
>   #include "qemu-common.h"
>   #include "block/block.h"
> +#include "qemu/main-loop.h"
>   #include "qemu/queue.h"
>   #include "qemu/sockets.h"
>   #include "qapi/error.h"
> @@ -333,8 +334,13 @@ bool aio_poll(AioContext *ctx, bool blocking)
>        * There cannot be two concurrent aio_poll calls for the same AioContext (or
>        * an aio_poll concurrent with a GSource prepare/check/dispatch callback).
>        * We rely on this below to avoid slow locked accesses to ctx->notify_me.
> +     *
> +     * aio_poll() may only be called in the AioContext's thread. iohandler_ctx
> +     * is special in that it runs in the main thread, but that thread's context
> +     * is qemu_aio_context.
>        */
> -    assert(in_aio_context_home_thread(ctx));
> +    assert(in_aio_context_home_thread(ctx == iohandler_get_aio_context() ?
> +                                      qemu_get_aio_context() : ctx));
>       progress = false;
>   
>       /* aio_notify can avoid the expensive event_notifier_set if

Sorry about the delay, however I've just tried this on top of git master and it fixes 
the problem with the assert() when exiting QEMU on Win32 so:

Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

Is it possible to get this merged for 5.2?


ATB,

Mark.


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

end of thread, other threads:[~2020-11-02 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21  6:40 [PATCH] qmp: fix aio_poll() assertion failure on Windows Volker Rümelin
2020-10-21 14:51 ` Stefan Hajnoczi
2020-11-02 12:50 ` Mark Cave-Ayland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.