block: add missing coroutine_fn annotations

The functions call coroutine functions or are called by coroutine.

Add an assert() in qcow2_do_close() code path which calls a
no_coroutine_fn bdrv_graph_wrlock_drained().

Add an assert() in qcow2_update_options_commit() in the coroutine
path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260730171027.1023696-1-marcandre.lureau@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Marc-André Lureau authored and Kevin Wolf committed 2026-11-09 16:32:35 +01:00
1 parent 43d614ab3a
commit ae8aacb25f
5 files changed
+21 -14

No files matched your search

+7 -6
View File
@@ -56,12 +56,13 @@ static int block_crypto_probe_generic(QCryptoBlockFormat format,
}
static int block_crypto_read_func(QCryptoBlock *block,
size_t offset,
uint8_t *buf,
size_t buflen,
void *opaque,
Error **errp)
static int coroutine_mixed_fn
block_crypto_read_func(QCryptoBlock *block,
size_t offset,
uint8_t *buf,
size_t buflen,
void *opaque,
Error **errp)
{
BlockDriverState *bs = opaque;
BlockCrypto *crypto = bs->opaque;
+5 -3
View File
@@ -354,8 +354,9 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
assert(data.done);
}
static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
bool poll)
static void coroutine_mixed_fn
bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
bool poll)
{
IO_OR_GS_CODE();
@@ -405,7 +406,8 @@ bdrv_drained_begin(BlockDriverState *bs)
* This function does not poll, nor must any of its recursively called
* functions.
*/
static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
static void coroutine_mixed_fn
bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
{
IO_OR_GS_CODE();
+6 -3
View File
@@ -1287,9 +1287,10 @@ fail:
}
/* s_locked specifies whether s->lock is held or not */
static void qcow2_update_options_commit(BlockDriverState *bs,
Qcow2ReopenState *r,
bool s_locked)
static coroutine_mixed_fn void
qcow2_update_options_commit(BlockDriverState *bs,
Qcow2ReopenState *r,
bool s_locked)
{
BDRVQcow2State *s = bs->opaque;
int i;
@@ -1299,6 +1300,7 @@ static void qcow2_update_options_commit(BlockDriverState *bs,
* table caches
*/
if (s_locked) {
assert(qemu_in_coroutine());
cache_clean_timer_co_locked_del_and_wait(bs);
} else {
cache_clean_timer_del_and_wait(bs);
@@ -2919,6 +2921,7 @@ qcow2_do_close(BlockDriverState *bs, bool close_data_file)
g_free(s->image_backing_format);
if (close_data_file && has_data_file(bs)) {
assert(!qemu_in_coroutine());
GLOBAL_STATE_CODE();
bdrv_graph_rdunlock_main_loop();
bdrv_graph_wrlock_drained();
+2 -1
View File
@@ -338,7 +338,8 @@ void block_job_ratelimit_processed_bytes(BlockJob *job, uint64_t n)
ratelimit_calculate_delay(&job->limit, n);
}
void block_job_ratelimit_sleep(BlockJob *job)
void coroutine_fn
block_job_ratelimit_sleep(BlockJob *job)
{
uint64_t delay_ns;
+1 -1
View File
@@ -150,7 +150,7 @@ void block_job_ratelimit_processed_bytes(BlockJob *job, uint64_t n);
* Put the job to sleep (assuming that it wasn't canceled) to throttle it to the
* right speed according to its rate limiting.
*/
void block_job_ratelimit_sleep(BlockJob *job);
void coroutine_fn block_job_ratelimit_sleep(BlockJob *job);
/**
* block_job_error_action: