v2: Use "pause" approach as suggested by Paolo. Stopping the vm will drive the block job all the way to the end, because the sleep duration is too short, which means the block_job_sleep_ns in the block jobs are unhelpful. That is because the timer will fire too soon, even before the aio_poll in bdrv_drain_all returns.
Fix this by pausing all the block jobs during bdrv_drain_all. Please review! Fam Fam Zheng (4): blockjob: Allow nested pause block: Pause block jobs in bdrv_drain_all qemu-iotests: Test that "stop" doesn't drain block jobs blockjob: Update function name in comments block.c | 20 +++++++++++ block/backup.c | 2 +- block/mirror.c | 4 +-- blockdev.c | 8 +++-- blockjob.c | 23 +++++++++---- include/block/blockjob.h | 20 ++++++++--- tests/qemu-iotests/129 | 86 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/129.out | 5 +++ tests/qemu-iotests/group | 1 + 9 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 tests/qemu-iotests/129 create mode 100644 tests/qemu-iotests/129.out -- 2.1.0