]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Add assertion for bdrv_graph_wrlock()
authorKevin Wolf <kwolf@redhat.com>
Fri, 29 Sep 2023 14:51:57 +0000 (16:51 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 12 Oct 2023 14:31:33 +0000 (16:31 +0200)
bdrv_graph_wrlock() can't run in a coroutine (because it polls) and
requires holding the BQL. We already have GLOBAL_STATE_CODE() to assert
the latter. Assert the former as well and add a no_coroutine_fn marker.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230929145157.45443-23-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/graph-lock.c
include/block/graph-lock.h

index 58a799065f7801979869efeb906b2b9ff8f04215..e5525ee2db4474c70a68a70be81edd2efa23d0c6 100644 (file)
@@ -106,12 +106,13 @@ static uint32_t reader_count(void)
     return rd;
 }
 
-void bdrv_graph_wrlock(BlockDriverState *bs)
+void no_coroutine_fn bdrv_graph_wrlock(BlockDriverState *bs)
 {
     AioContext *ctx = NULL;
 
     GLOBAL_STATE_CODE();
     assert(!qatomic_read(&has_writer));
+    assert(!qemu_in_coroutine());
 
     /*
      * Release only non-mainloop AioContext. The mainloop often relies on the
index 7e04f98ff025538512e0db4104de5492e3ab052b..6f1cd12745fe721fed5feaed823a24f41650de93 100644 (file)
@@ -116,7 +116,8 @@ void unregister_aiocontext(AioContext *ctx);
  * This function polls. Callers must not hold the lock of any AioContext other
  * than the current one and the one of @bs.
  */
-void bdrv_graph_wrlock(BlockDriverState *bs) TSA_ACQUIRE(graph_lock) TSA_NO_TSA;
+void no_coroutine_fn TSA_ACQUIRE(graph_lock) TSA_NO_TSA
+bdrv_graph_wrlock(BlockDriverState *bs);
 
 /*
  * bdrv_graph_wrunlock: