Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
block: mark mixed functions that can suspend
The marking should be extended transitively to all functions that call
these ones, so that static analysis can be done much more efficiently.
However, this is a start and makes it possible to use vrc's path-based
searches to find potential bugs where coroutine_fns call blocking functions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Sep 26, 2023
1 parent 1bce34a commit e2dbca0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions block/io.c
Expand Up @@ -387,7 +387,8 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
bdrv_do_drained_begin(bs, parent, false);
}

void bdrv_drained_begin(BlockDriverState *bs)
void coroutine_mixed_fn
bdrv_drained_begin(BlockDriverState *bs)
{
IO_OR_GS_CODE();
bdrv_do_drained_begin(bs, NULL, true);
Expand Down Expand Up @@ -506,7 +507,7 @@ void bdrv_drain_all_begin_nopoll(void)
}
}

void bdrv_drain_all_begin(void)
void coroutine_mixed_fn bdrv_drain_all_begin(void)
{
BlockDriverState *bs = NULL;

Expand Down
2 changes: 1 addition & 1 deletion block/qcow2.c
Expand Up @@ -5288,7 +5288,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
return spec_info;
}

static int qcow2_has_zero_init(BlockDriverState *bs)
static int coroutine_mixed_fn qcow2_has_zero_init(BlockDriverState *bs)
{
BDRVQcow2State *s = bs->opaque;
bool preallocated;
Expand Down
4 changes: 2 additions & 2 deletions block/qed.c
Expand Up @@ -570,8 +570,8 @@ static void coroutine_fn bdrv_qed_open_entry(void *opaque)
qemu_co_mutex_unlock(&s->table_lock);
}

static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
static int coroutine_mixed_fn bdrv_qed_open(BlockDriverState *bs, QDict *options,
int flags, Error **errp)
{
QEDOpenCo qoc = {
.bs = bs,
Expand Down
4 changes: 2 additions & 2 deletions block/throttle-groups.c
Expand Up @@ -317,8 +317,8 @@ static bool coroutine_fn throttle_group_co_restart_queue(ThrottleGroupMember *tg
* @tgm: the current ThrottleGroupMember
* @direction: the ThrottleDirection
*/
static void schedule_next_request(ThrottleGroupMember *tgm,
ThrottleDirection direction)
static void coroutine_mixed_fn schedule_next_request(ThrottleGroupMember *tgm,
ThrottleDirection direction)
{
ThrottleState *ts = tgm->throttle_state;
ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
Expand Down

0 comments on commit e2dbca0

Please sign in to comment.