summary refs log tree commit diff stats
path: root/qemu-img.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2023-05-10 22:35:57 +0200
committerKevin Wolf <kwolf@redhat.com>2023-05-19 19:12:12 +0200
commit3db0c8b25c452b53aabc8efa36e655c7c02abb8f (patch)
tree5c38d0cd7a2b6bcd88d20b7a0b5d000e8054a4d9 /qemu-img.c
parente3e31dc87208007784b93a19f8efcdda90ea64f6 (diff)
downloadfocaccia-qemu-3db0c8b25c452b53aabc8efa36e655c7c02abb8f.tar.gz
focaccia-qemu-3db0c8b25c452b53aabc8efa36e655c7c02abb8f.zip
qemu-img: Take graph lock more selectively
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>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 9f9f0a7629..27f48051b0 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2938,8 +2938,6 @@ 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
@@ -2947,7 +2945,10 @@ static BlockGraphInfoList *collect_image_info_list(bool image_opts,
          * 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);