Here is my NBD asynchronous operation series, including asynchronous server.
Patches 1-5 add asynchronous operation to the client. Patches 6-9 add new features for flush/FUA and discard (trim). Patches 10-25 add asynchronous operation to the server. Chunyan Liu (1): Update ioctl order in nbd_init() to detect EBUSY Paolo Bonzini (24): add qemu_send_full and qemu_recv_full sheepdog: move coroutine send/recv function to generic code nbd: switch to asynchronous operation nbd: split requests nbd: allow multiple in-flight requests nbd: fix error handling in the server nbd: add support for NBD_CMD_FLAG_FUA nbd: add support for NBD_CMD_FLUSH nbd: add support for NBD_CMD_TRIM qemu-nbd: remove offset argument to nbd_trip qemu-nbd: remove data_size argument to nbd_trip move corking functions to osdep.c qemu-nbd: simplify nbd_trip qemu-nbd: introduce nbd_do_send_reply qemu-nbd: more robust handling of invalid requests qemu-nbd: introduce nbd_do_receive_request qemu-nbd: introduce NBDExport qemu-nbd: introduce NBDRequest link the main loop and its dependencies into the tools qemu-nbd: use common main loop qemu-nbd: move client handling to nbd.c qemu-nbd: add client pointer to NBDRequest qemu-nbd: asynchronous operation qemu-nbd: throttle requests Makefile | 5 +- Makefile.objs | 2 +- block/nbd.c | 319 ++++++++++++++++++++++++++++++------- block/sheepdog.c | 250 +++-------------------------- cutils.c | 111 +++++++++++++ main-loop.h | 6 + nbd.c | 439 ++++++++++++++++++++++++++++++++++++++++----------- nbd.h | 14 ++- os-posix.c | 42 ----- os-win32.c | 5 - osdep.c | 76 +++++++++ oslib-posix.c | 43 +++++ oslib-win32.c | 5 + qemu-common.h | 34 ++++ qemu-coroutine-io.c | 96 +++++++++++ qemu-nbd.c | 120 +++++--------- qemu-tool.c | 42 +++--- qemu_socket.h | 1 + 18 files changed, 1080 insertions(+), 530 deletions(-) create mode 100644 qemu-coroutine-io.c -- 1.7.7.1