This patch is pure refactoring: instead of hard-coding permission to
use a protocol prefix when creating an image, the drivers can now pass
in a parameter, comparable to what they could already do for opening a
pre-existing image. This patch is purely mechanical (all drivers pass
in true for now), but it will enable the next patch to cater to
drivers that want to differ in behavior for the primary image vs. any
secondary images that are opened at the same time as creating the
primary image.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <
20250915213919.
3121401-5-eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
}
int coroutine_fn bdrv_co_create_file(const char *filename, QemuOpts *opts,
- Error **errp)
+ bool allow_protocol_prefix, Error **errp)
{
QemuOpts *protocol_opts;
BlockDriver *drv;
GLOBAL_STATE_CODE();
- drv = bdrv_find_protocol(filename, true, errp);
+ drv = bdrv_find_protocol(filename, allow_protocol_prefix, errp);
if (drv == NULL) {
return -ENOENT;
}
}
/* Create protocol layer */
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto fail;
}
}
/* Create and open the file (protocol layer) */
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto done;
}
}
/* Create and open the file (protocol layer) */
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto fail;
}
}
/* Create and open the file (protocol layer) */
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto finish;
}
/* Create and open an external data file (protocol layer) */
val = qdict_get_try_str(qdict, BLOCK_OPT_DATA_FILE);
if (val) {
- ret = bdrv_co_create_file(val, opts, errp);
+ ret = bdrv_co_create_file(val, opts, true, errp);
if (ret < 0) {
goto finish;
}
}
/* Create and open the file (protocol layer) */
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto fail;
}
raw_co_create_opts(BlockDriver *drv, const char *filename,
QemuOpts *opts, Error **errp)
{
- return bdrv_co_create_file(filename, opts, errp);
+ return bdrv_co_create_file(filename, opts, true, errp);
}
static int raw_open(BlockDriverState *bs, QDict *options, int flags,
qdict = qemu_opts_to_qdict_filtered(opts, NULL, &vdi_create_opts, true);
/* Create and open the file (protocol layer) */
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto done;
}
}
/* Create and open the file (protocol layer) */
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto fail;
}
int ret;
BlockBackend *blk = NULL;
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto exit;
}
}
/* Create and open the file (protocol layer) */
- ret = bdrv_co_create_file(filename, opts, errp);
+ ret = bdrv_co_create_file(filename, opts, true, errp);
if (ret < 0) {
goto fail;
}
QemuOpts *opts, Error **errp);
int coroutine_fn GRAPH_UNLOCKED
-bdrv_co_create_file(const char *filename, QemuOpts *opts, Error **errp);
+bdrv_co_create_file(const char *filename, QemuOpts *opts,
+ bool allow_protocol_prefix, Error **errp);
BlockDriverState *bdrv_new(void);
int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,