Skip to content

Commit

Permalink
block: Take graph rdlock in bdrv_change_aio_context()
Browse files Browse the repository at this point in the history
The function reads the parents list, so it needs to hold the graph lock.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-ID: <20230911094620.45040-19-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
kevmw committed Sep 20, 2023
1 parent 733467a commit 7f831d2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -7688,17 +7688,21 @@ static bool bdrv_change_aio_context(BlockDriverState *bs, AioContext *ctx,
return true;
}

bdrv_graph_rdlock_main_loop();
QLIST_FOREACH(c, &bs->parents, next_parent) {
if (!bdrv_parent_change_aio_context(c, ctx, visited, tran, errp)) {
bdrv_graph_rdunlock_main_loop();
return false;
}
}

QLIST_FOREACH(c, &bs->children, next) {
if (!bdrv_child_change_aio_context(c, ctx, visited, tran, errp)) {
bdrv_graph_rdunlock_main_loop();
return false;
}
}
bdrv_graph_rdunlock_main_loop();

state = g_new(BdrvStateSetAioContext, 1);
*state = (BdrvStateSetAioContext) {
Expand Down

0 comments on commit 7f831d2

Please sign in to comment.