diff mbox series

[1/6] block: assert that bdrv_co_create is always called with graph rdlock taken

Message ID 20221116135331.3052923-2-eesposit@redhat.com
State New
Headers show
Series Protect the block layer with a rwlock: part 2 | expand

Commit Message

Emanuele Giuseppe Esposito Nov. 16, 2022, 1:53 p.m. UTC
This function is either called by bdrv_create(), which always takes
care of creating a new coroutine, or by bdrv_create_file(), which
is only called by BlockDriver->bdrv_co_create_opts callbacks,
invoked by bdrv_co_create().

Protecting bdrv_co_create() implies that BlockDriver->bdrv_co_create_opts
is always called with graph rdlock taken.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 block.c                          | 1 +
 include/block/block_int-common.h | 1 +
 2 files changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/block.c b/block.c
index c7611bed9e..e54ed300d7 100644
--- a/block.c
+++ b/block.c
@@ -537,6 +537,7 @@  int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename,
     assert(qemu_in_coroutine());
     assert(*errp == NULL);
     assert(drv);
+    assert_bdrv_graph_readable();
 
     if (!drv->bdrv_co_create_opts) {
         error_setg(errp, "Driver '%s' does not support image creation",
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index db97d61836..d45961a1d1 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -253,6 +253,7 @@  struct BlockDriver {
 
     int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts,
                                        Error **errp);
+    /* Called with graph rdlock taken */
     int coroutine_fn (*bdrv_co_create_opts)(BlockDriver *drv,
                                             const char *filename,
                                             QemuOpts *opts,