The other day we re-introduced synchronous qcow2 read/write functions to work around the buggy bdrv_read/write emulation, this series implements the proper fix for it.
Basically what it's doing is to ensure that the emulation only runs its own AIO callbacks and bottom halves. Callbacks from outside need to wait so they can't corrupt the internal state of the driver calling bdrv_read/write (and assuming that nobody else runs in between). Kevin Wolf (8): posix-aio-compat: Split out posix_aio_process_queue Add qemu_aio_process_queue() Split out bottom halves Introduce contexts for asynchronous callbacks block: Use new AsyncContext for bdrv_read/write emulation posix-aio-compat: Honour AsyncContext linux-aio: Honour AsyncContext Revert "qcow2: Bring synchronous read/write back to life" Makefile.target | 2 +- aio.c | 30 +++++++ async.c | 216 +++++++++++++++++++++++++++++++++++++++++++++++++ block.c | 22 ++++- block/curl.c | 8 +- block/qcow2-cluster.c | 6 +- block/qcow2.c | 51 +----------- block/qcow2.h | 3 - linux-aio.c | 87 ++++++++++++++++---- posix-aio-compat.c | 58 +++++++++---- qemu-aio.h | 13 +++ qemu-common.h | 5 + qemu-tool.c | 13 +++ vl.c | 104 ----------------------- 14 files changed, 418 insertions(+), 200 deletions(-) create mode 100644 async.c