diff options
author | Sergio Lopez | 2020-12-14 18:05:18 +0100 |
---|---|---|
committer | Eric Blake | 2021-01-20 21:48:54 +0100 |
commit | f148ae7d36cbb924447f4b528a94d7799836c749 (patch) | |
tree | 9c08b2964964a841c219c1ea61f7f2addd42ffdf /os-posix.c | |
parent | block: Honor blk_set_aio_context() context requirements (diff) | |
download | qemu-f148ae7d36cbb924447f4b528a94d7799836c749.tar.gz qemu-f148ae7d36cbb924447f4b528a94d7799836c749.tar.xz qemu-f148ae7d36cbb924447f4b528a94d7799836c749.zip |
nbd/server: Quiesce coroutines on context switch
When switching between AIO contexts we need to me make sure that both
recv_coroutine and send_coroutine are not scheduled to run. Otherwise,
QEMU may crash while attaching the new context with an error like
this one:
aio_co_schedule: Co-routine was already scheduled in 'aio_co_schedule'
To achieve this we need a local implementation of
'qio_channel_readv_all_eof' named 'nbd_read_eof' (a trick already done
by 'nbd/client.c') that allows us to interrupt the operation and to
know when recv_coroutine is yielding.
With this in place, we delegate detaching the AIO context to the
owning context with a BH ('nbd_aio_detach_bh') scheduled using
'aio_wait_bh_oneshot'. This BH signals that we need to quiesce the
channel by setting 'client->quiescing' to 'true', and either waits for
the coroutine to finish using AIO_WAIT_WHILE or, if it's yielding in
'nbd_read_eof', actively enters the coroutine to interrupt it.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1900326
Signed-off-by: Sergio Lopez <slp@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20201214170519.223781-4-slp@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'os-posix.c')
0 files changed, 0 insertions, 0 deletions