From 89bd030533e3592ca0a995450dcfc5d53e459e20 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 22 Mar 2018 14:11:20 +0100 Subject: block: Really pause block jobs on drain We already requested that block jobs be paused in .bdrv_drained_begin, but no guarantee was made that the job was actually inactive at the point where bdrv_drained_begin() returned. This introduces a new callback BdrvChildRole.bdrv_drained_poll() and uses it to make bdrv_drain_poll() consider block jobs using the node to be drained. For the test case to work as expected, we have to switch from block_job_sleep_ns() to qemu_co_sleep_ns() so that the test job is even considered active and must be waited for when draining the node. Signed-off-by: Kevin Wolf --- include/block/block.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/block/block.h') diff --git a/include/block/block.h b/include/block/block.h index e677080c4e..cebbb39c6c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -567,6 +567,14 @@ void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore); */ void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore); +/** + * bdrv_drain_poll: + * + * Poll for pending requests in @bs and its parents (except for + * @ignore_parent). This is part of bdrv_drained_begin. + */ +bool bdrv_drain_poll(BlockDriverState *bs, BdrvChild *ignore_parent); + /** * bdrv_drained_begin: * -- cgit v1.2.3