aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2023-05-16 15:02:27 -0400
committerKevin Wolf <kwolf@redhat.com>2023-05-30 17:32:02 +0200
commitff82b7835b2fbbd0a17d616f6929601a97a6497d (patch)
treecb0b3a8ccbf2e144d69b013eed773a18896d1e70 /block
parent9998f70f6625f15f2ae36f612509ea34733c11d3 (diff)
downloadqemu-ff82b7835b2fbbd0a17d616f6929601a97a6497d.zip
qemu-ff82b7835b2fbbd0a17d616f6929601a97a6497d.tar.gz
qemu-ff82b7835b2fbbd0a17d616f6929601a97a6497d.tar.bz2
block: add blk_in_drain() API
The BlockBackend quiesce_counter is greater than zero during drained sections. Add an API to check whether the BlockBackend is in a drained section. The next patch will use this API. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20230516190238.8401-10-stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index 2074ac6..241f643 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1287,6 +1287,13 @@ blk_check_byte_request(BlockBackend *blk, int64_t offset, int64_t bytes)
return 0;
}
+/* Are we currently in a drained section? */
+bool blk_in_drain(BlockBackend *blk)
+{
+ GLOBAL_STATE_CODE(); /* change to IO_OR_GS_CODE(), if necessary */
+ return qatomic_read(&blk->quiesce_counter);
+}
+
/* To be called between exactly one pair of blk_inc/dec_in_flight() */
static void coroutine_fn blk_wait_while_drained(BlockBackend *blk)
{