From: Kevin Wolf Date: Mon, 11 Sep 2023 09:46:17 +0000 (+0200) Subject: block: Take graph rdlock in bdrv_change_aio_context() X-Git-Tag: v8.2.0-rc0~115^2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f831d29e3d005e499b22c0591a26a33eb5c406d;p=thirdparty%2Fqemu.git block: Take graph rdlock in bdrv_change_aio_context() The function reads the parents list, so it needs to hold the graph lock. Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito Message-ID: <20230911094620.45040-19-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- diff --git a/block.c b/block.c index e024a6ccece..8e589bb2e49 100644 --- a/block.c +++ b/block.c @@ -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) {