diff options
author | Kevin Wolf <kwolf@redhat.com> | 2023-02-03 16:21:55 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-02-23 19:49:23 +0100 |
commit | 4ec8df0183d0906ae6704d65ef6d8082c970ecdf (patch) | |
tree | 45fc829fcb4ea5851b8547cfce9d79ae7a73875e /block | |
parent | 7b9e8b22bca534e0e86915c0856d77a7ae99e160 (diff) | |
download | qemu-4ec8df0183d0906ae6704d65ef6d8082c970ecdf.zip qemu-4ec8df0183d0906ae6704d65ef6d8082c970ecdf.tar.gz qemu-4ec8df0183d0906ae6704d65ef6d8082c970ecdf.tar.bz2 |
block: Mark bdrv_co_create() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of
bdrv_co_create() need to hold a reader lock for the graph.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230203152202.49054-17-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/create.c | 9 | ||||
-rw-r--r-- | block/crypto.c | 7 | ||||
-rw-r--r-- | block/file-posix.c | 7 | ||||
-rw-r--r-- | block/file-win32.c | 7 | ||||
-rw-r--r-- | block/parallels.c | 7 | ||||
-rw-r--r-- | block/qcow.c | 6 | ||||
-rw-r--r-- | block/qcow2.c | 7 | ||||
-rw-r--r-- | block/qed.c | 7 | ||||
-rw-r--r-- | block/raw-format.c | 7 | ||||
-rw-r--r-- | block/vdi.c | 7 | ||||
-rw-r--r-- | block/vhdx.c | 7 | ||||
-rw-r--r-- | block/vmdk.c | 63 | ||||
-rw-r--r-- | block/vpc.c | 7 |
13 files changed, 70 insertions, 78 deletions
diff --git a/block/create.c b/block/create.c index 4df43f1..bf67b99 100644 --- a/block/create.c +++ b/block/create.c @@ -43,6 +43,7 @@ static int coroutine_fn blockdev_create_run(Job *job, Error **errp) int ret; GLOBAL_STATE_CODE(); + GRAPH_RDLOCK_GUARD(); job_progress_set_remaining(&s->common, 1); ret = s->drv->bdrv_co_create(s->opts, errp); @@ -59,6 +60,12 @@ static const JobDriver blockdev_create_job_driver = { .run = blockdev_create_run, }; +/* Checking whether the function is present doesn't require the graph lock */ +static inline bool TSA_NO_TSA has_bdrv_co_create(BlockDriver *drv) +{ + return drv->bdrv_co_create; +} + void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options, Error **errp) { @@ -79,7 +86,7 @@ void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options, } /* Error out if the driver doesn't support .bdrv_co_create */ - if (!drv->bdrv_co_create) { + if (!has_bdrv_co_create(drv)) { error_setg(errp, "Driver does not support blockdev-create"); return; } diff --git a/block/crypto.c b/block/crypto.c index 0ebb846..e77790a 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -664,10 +664,9 @@ fail: return ret; } -static int coroutine_fn block_crypto_co_create_opts_luks(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +block_crypto_co_create_opts_luks(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { QCryptoBlockCreateOptions *create_opts = NULL; BlockDriverState *bs = NULL; diff --git a/block/file-posix.c b/block/file-posix.c index 13da095..5760cf2 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2607,10 +2607,9 @@ out: return result; } -static int coroutine_fn raw_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +raw_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { BlockdevCreateOptions options; int64_t total_size = 0; diff --git a/block/file-win32.c b/block/file-win32.c index 200d244..c7d0b85 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -613,10 +613,9 @@ static int raw_co_create(BlockdevCreateOptions *options, Error **errp) return 0; } -static int coroutine_fn raw_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +raw_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { BlockdevCreateOptions options; int64_t total_size = 0; diff --git a/block/parallels.c b/block/parallels.c index a7e9cad..0136848 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -622,10 +622,9 @@ exit: goto out; } -static int coroutine_fn parallels_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +parallels_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { BlockdevCreateOptions *create_options = NULL; BlockDriverState *bs = NULL; diff --git a/block/qcow.c b/block/qcow.c index 58a0b4e..490e4f8 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -921,9 +921,9 @@ exit: return ret; } -static int coroutine_fn qcow_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, Error **errp) +static int coroutine_fn GRAPH_RDLOCK +qcow_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { BlockdevCreateOptions *create_options = NULL; BlockDriverState *bs = NULL; diff --git a/block/qcow2.c b/block/qcow2.c index c318f41..30fd53f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3816,10 +3816,9 @@ out: return ret; } -static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts, + Error **errp) { BlockdevCreateOptions *create_options = NULL; QDict *qdict; diff --git a/block/qed.c b/block/qed.c index c969b31..ed94bb6 100644 --- a/block/qed.c +++ b/block/qed.c @@ -754,10 +754,9 @@ out: return ret; } -static int coroutine_fn bdrv_qed_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +bdrv_qed_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { BlockdevCreateOptions *create_options = NULL; QDict *qdict; diff --git a/block/raw-format.c b/block/raw-format.c index 9913cb8..646606e 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -430,10 +430,9 @@ static int raw_has_zero_init(BlockDriverState *bs) return bdrv_has_zero_init(bs->file->bs); } -static int coroutine_fn raw_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +raw_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { return bdrv_co_create_file(filename, opts, errp); } diff --git a/block/vdi.c b/block/vdi.c index b50c0b7..f2434d6 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -898,10 +898,9 @@ static int coroutine_fn vdi_co_create(BlockdevCreateOptions *create_options, return vdi_co_do_create(create_options, DEFAULT_CLUSTER_SIZE, errp); } -static int coroutine_fn vdi_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +vdi_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { QDict *qdict = NULL; BlockdevCreateOptions *create_options = NULL; diff --git a/block/vhdx.c b/block/vhdx.c index ffa4455..8142072 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2059,10 +2059,9 @@ delete_and_exit: return ret; } -static int coroutine_fn vhdx_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +vhdx_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { BlockdevCreateOptions *create_options = NULL; QDict *qdict; diff --git a/block/vmdk.c b/block/vmdk.c index c601ca8..f5f4901 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2277,11 +2277,10 @@ exit: return ret; } -static int coroutine_fn vmdk_create_extent(const char *filename, - int64_t filesize, bool flat, - bool compress, bool zeroed_grain, - BlockBackend **pbb, - QemuOpts *opts, Error **errp) +static int coroutine_fn GRAPH_RDLOCK +vmdk_create_extent(const char *filename, int64_t filesize, bool flat, + bool compress, bool zeroed_grain, BlockBackend **pbb, + QemuOpts *opts, Error **errp) { int ret; BlockBackend *blk = NULL; @@ -2359,14 +2358,10 @@ static int filename_decompose(const char *filename, char *path, char *prefix, * non-split format. * idx >= 1: get the n-th extent if in a split subformat */ -typedef BlockBackend * coroutine_fn (*vmdk_create_extent_fn)(int64_t size, - int idx, - bool flat, - bool split, - bool compress, - bool zeroed_grain, - void *opaque, - Error **errp); +typedef BlockBackend * coroutine_fn /* GRAPH_RDLOCK */ + (*vmdk_create_extent_fn)(int64_t size, int idx, bool flat, bool split, + bool compress, bool zeroed_grain, void *opaque, + Error **errp); static void vmdk_desc_add_extent(GString *desc, const char *extent_line_fmt, @@ -2379,17 +2374,18 @@ static void vmdk_desc_add_extent(GString *desc, g_free(basename); } -static int coroutine_fn vmdk_co_do_create(int64_t size, - BlockdevVmdkSubformat subformat, - BlockdevVmdkAdapterType adapter_type, - const char *backing_file, - const char *hw_version, - const char *toolsversion, - bool compat6, - bool zeroed_grain, - vmdk_create_extent_fn extent_fn, - void *opaque, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +vmdk_co_do_create(int64_t size, + BlockdevVmdkSubformat subformat, + BlockdevVmdkAdapterType adapter_type, + const char *backing_file, + const char *hw_version, + const char *toolsversion, + bool compat6, + bool zeroed_grain, + vmdk_create_extent_fn extent_fn, + void *opaque, + Error **errp) { int extent_idx; BlockBackend *blk = NULL; @@ -2609,10 +2605,10 @@ typedef struct { QemuOpts *opts; } VMDKCreateOptsData; -static BlockBackend * coroutine_fn vmdk_co_create_opts_cb(int64_t size, int idx, - bool flat, bool split, bool compress, - bool zeroed_grain, void *opaque, - Error **errp) +static BlockBackend * coroutine_fn GRAPH_RDLOCK +vmdk_co_create_opts_cb(int64_t size, int idx, bool flat, bool split, + bool compress, bool zeroed_grain, void *opaque, + Error **errp) { BlockBackend *blk = NULL; BlockDriverState *bs = NULL; @@ -2651,10 +2647,9 @@ exit: return blk; } -static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +vmdk_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { Error *local_err = NULL; char *desc = NULL; @@ -2814,8 +2809,8 @@ static BlockBackend * coroutine_fn vmdk_co_create_cb(int64_t size, int idx, return blk; } -static int coroutine_fn vmdk_co_create(BlockdevCreateOptions *create_options, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +vmdk_co_create(BlockdevCreateOptions *create_options, Error **errp) { BlockdevCreateOptionsVmdk *opts; diff --git a/block/vpc.c b/block/vpc.c index 1f0f26c..b89b0ff 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -1087,10 +1087,9 @@ out: return ret; } -static int coroutine_fn vpc_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +vpc_co_create_opts(BlockDriver *drv, const char *filename, + QemuOpts *opts, Error **errp) { BlockdevCreateOptions *create_options = NULL; QDict *qdict; |