diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-10-27 12:48:55 +0200 |
---|---|---|
committer | Fam Zheng <famz@redhat.com> | 2016-10-28 21:50:18 +0800 |
commit | 88b062c2036cfd05b5111147736a08ba05ea05a9 (patch) | |
tree | b7018cd61ca309939b7197f7ad3ff729f9c0769d /include/block/block.h | |
parent | 6653a73d12fbac8c9b5c22bb21aef22759b28c1c (diff) |
block: introduce BDRV_POLL_WHILE
We want the BDS event loop to run exclusively in the iothread that
owns the BDS's AioContext. This macro will provide the synchronization
between the two event loops; for now it just wraps the common idiom
of a while loop around aio_poll.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-Id: <1477565348-5458-8-git-send-email-pbonzini@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'include/block/block.h')
-rw-r--r-- | include/block/block.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/block/block.h b/include/block/block.h index 398a050176..a9d7c0d82e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -334,6 +334,15 @@ void bdrv_drain(BlockDriverState *bs); void coroutine_fn bdrv_co_drain(BlockDriverState *bs); void bdrv_drain_all(void); +#define BDRV_POLL_WHILE(bs, cond) ({ \ + bool waited_ = false; \ + BlockDriverState *bs_ = (bs); \ + while ((cond)) { \ + aio_poll(bdrv_get_aio_context(bs_), true); \ + waited_ = true; \ + } \ + waited_; }) + int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int count); int bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, int count); int bdrv_has_zero_init_1(BlockDriverState *bs); |