Revert "monitor: use aio_co_reschedule_self()"

Commit 1f25c172f8 ("monitor: use aio_co_reschedule_self()") was a code
cleanup that uses aio_co_reschedule_self() instead of open coding
coroutine rescheduling.

Bug RHEL-34618 was reported and Kevin Wolf <kwolf@redhat.com> identified
the root cause. I missed that aio_co_reschedule_self() ->
qemu_get_current_aio_context() only knows about
qemu_aio_context/IOThread AioContexts and not about iohandler_ctx. It
does not function correctly when going back from the iohandler_ctx to
qemu_aio_context.

Go back to open coding the AioContext transitions to avoid this bug.

This reverts commit 1f25c172f8.

Cc: qemu-stable@nongnu.org
Buglink: https://issues.redhat.com/browse/RHEL-34618
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20240506190622.56095-2-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 719c6819ed)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
Stefan Hajnoczi 2024-05-06 15:06:21 -04:00 committed by Michael Tokarev
parent 0d90c36d9c
commit 35e5ce5bd6

View File

@ -212,7 +212,8 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *requ
* executing the command handler so that it can make progress if it * executing the command handler so that it can make progress if it
* involves an AIO_WAIT_WHILE(). * involves an AIO_WAIT_WHILE().
*/ */
aio_co_reschedule_self(qemu_get_aio_context()); aio_co_schedule(qemu_get_aio_context(), qemu_coroutine_self());
qemu_coroutine_yield();
} }
monitor_set_cur(qemu_coroutine_self(), cur_mon); monitor_set_cur(qemu_coroutine_self(), cur_mon);
@ -226,7 +227,9 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *requ
* Move back to iohandler_ctx so that nested event loops for * Move back to iohandler_ctx so that nested event loops for
* qemu_aio_context don't start new monitor commands. * qemu_aio_context don't start new monitor commands.
*/ */
aio_co_reschedule_self(iohandler_get_aio_context()); aio_co_schedule(iohandler_get_aio_context(),
qemu_coroutine_self());
qemu_coroutine_yield();
} }
} else { } else {
/* /*