diff options
author | Kevin Wolf <kwolf@redhat.com> | 2023-09-11 11:46:20 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-09-20 17:46:01 +0200 |
commit | 9def6082cf885fbb2e8e719d5055109c8a04b885 (patch) | |
tree | 33f5abf2dbe6ab2397bb613452f42ec9bf60616a /include/block | |
parent | 32a8aba37eaae54d3a0a7ae5e93e3e157525660a (diff) | |
download | qemu-9def6082cf885fbb2e8e719d5055109c8a04b885.zip qemu-9def6082cf885fbb2e8e719d5055109c8a04b885.tar.gz qemu-9def6082cf885fbb2e8e719d5055109c8a04b885.tar.bz2 |
block: Mark bdrv_add/del_child() and caller GRAPH_WRLOCK
The functions read the parents list in the generic block layer, so we
need to hold the graph lock already there. The BlockDriver
implementations actually modify the graph, so it has to be a writer
lock.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230911094620.45040-22-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'include/block')
-rw-r--r-- | include/block/block-global-state.h | 8 | ||||
-rw-r--r-- | include/block/block_int-common.h | 9 |
2 files changed, 10 insertions, 7 deletions
diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h index 0f6df8f..f31660c 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -276,9 +276,11 @@ int bdrv_try_change_aio_context(BlockDriverState *bs, AioContext *ctx, int bdrv_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz); int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo); -void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, - Error **errp); -void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp); +void GRAPH_WRLOCK +bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, Error **errp); + +void GRAPH_WRLOCK +bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp); /** * diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index 3feb67e..2ca3758 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -393,10 +393,11 @@ struct BlockDriver { */ int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo); - void (*bdrv_add_child)(BlockDriverState *parent, BlockDriverState *child, - Error **errp); - void (*bdrv_del_child)(BlockDriverState *parent, BdrvChild *child, - Error **errp); + void GRAPH_WRLOCK_PTR (*bdrv_add_child)( + BlockDriverState *parent, BlockDriverState *child, Error **errp); + + void GRAPH_WRLOCK_PTR (*bdrv_del_child)( + BlockDriverState *parent, BdrvChild *child, Error **errp); /** * Informs the block driver that a permission change is intended. The |