aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block/sheepdog.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 6c487c8322..cbbebc1aaf 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2151,13 +2151,21 @@ static int coroutine_fn sd_co_create_opts(BlockDriver *drv,
Error **errp)
{
BlockdevCreateOptions *create_options = NULL;
- QDict *qdict, *location_qdict;
+ QDict *qdict = NULL, *location_qdict;
Visitor *v;
- char *redundancy;
+ char *redundancy = NULL;
Error *local_err = NULL;
int ret;
+ char *backing_fmt = NULL;
redundancy = qemu_opt_get_del(opts, BLOCK_OPT_REDUNDANCY);
+ backing_fmt = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FMT);
+
+ if (backing_fmt && strcmp(backing_fmt, "sheepdog") != 0) {
+ error_setg(errp, "backing_file must be a sheepdog image");
+ ret = -EINVAL;
+ goto fail;
+ }
qdict = qemu_opts_to_qdict(opts, NULL);
qdict_put_str(qdict, "driver", "sheepdog");
@@ -2220,6 +2228,7 @@ fail:
qapi_free_BlockdevCreateOptions(create_options);
qobject_unref(qdict);
g_free(redundancy);
+ g_free(backing_fmt);
return ret;
}
@@ -3178,6 +3187,11 @@ static QemuOptsList sd_create_opts = {
.help = "File name of a base image"
},
{
+ .name = BLOCK_OPT_BACKING_FMT,
+ .type = QEMU_OPT_STRING,
+ .help = "Must be 'sheepdog' if present",
+ },
+ {
.name = BLOCK_OPT_PREALLOC,
.type = QEMU_OPT_STRING,
.help = "Preallocation mode (allowed values: off, full)"