Skip to content

Commit

Permalink
qemu-img: Take graph lock more selectively
Browse files Browse the repository at this point in the history
If we take a reader lock, we can't call any functions that take a writer
lock internally without causing deadlocks once the reader lock is
actually enforced in the main thread, too. Take the reader lock only
where it is actually needed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230510203601.418015-5-kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
kevmw committed May 19, 2023
1 parent e3e31dc commit 3db0c8b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions qemu-img.c
Original file line number Diff line number Diff line change
Expand Up @@ -2938,16 +2938,17 @@ static BlockGraphInfoList *collect_image_info_list(bool image_opts,
}
bs = blk_bs(blk);

GRAPH_RDLOCK_GUARD_MAINLOOP();

/*
* Note that the returned BlockGraphInfo object will not have
* information about this image's backing node, because we have opened
* it with BDRV_O_NO_BACKING. Printing this object will therefore not
* duplicate the backing chain information that we obtain by walking
* the chain manually here.
*/
bdrv_graph_rdlock_main_loop();
bdrv_query_block_graph_info(bs, &info, &err);
bdrv_graph_rdunlock_main_loop();

if (err) {
error_report_err(err);
blk_unref(blk);
Expand Down

0 comments on commit 3db0c8b

Please sign in to comment.