Skip to content

Commit

Permalink
block: Mark bdrv_parent_cb_change_media() GRAPH_RDLOCK
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>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230911094620.45040-17-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
kevmw committed Sep 14, 2023
1 parent 21a32c8 commit 4dc516f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion block.c
Original file line number Diff line number Diff line change
Expand Up @@ -3371,7 +3371,8 @@ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
}


static void bdrv_parent_cb_change_media(BlockDriverState *bs, bool load)
static void GRAPH_RDLOCK
bdrv_parent_cb_change_media(BlockDriverState *bs, bool load)
{
BdrvChild *c;
GLOBAL_STATE_CODE();
Expand Down Expand Up @@ -3969,6 +3970,9 @@ bdrv_open_inherit(const char *filename, const char *reference, QDict *options,
GLOBAL_STATE_CODE();
assert(!qemu_in_coroutine());

/* TODO We'll eventually have to take a writer lock in this function */
GRAPH_RDLOCK_GUARD_MAINLOOP();

if (reference) {
bool options_non_empty = options ? qdict_size(options) : false;
qobject_unref(options);
Expand Down

0 comments on commit 4dc516f

Please sign in to comment.