diff options
author | Eric Blake | 2020-07-06 22:39:48 +0200 |
---|---|---|
committer | Kevin Wolf | 2020-07-14 15:18:59 +0200 |
commit | d51a814cf41033d2d29b050e04d85155ac941221 (patch) | |
tree | 18ae8d56d7ea76e964ae67a7c24fd09c827cb1c5 | |
parent | sheepdog: Add trivial backing_fmt support (diff) | |
download | qemu-d51a814cf41033d2d29b050e04d85155ac941221.tar.gz qemu-d51a814cf41033d2d29b050e04d85155ac941221.tar.xz qemu-d51a814cf41033d2d29b050e04d85155ac941221.zip |
vmdk: Add trivial backing_fmt support
vmdk already requires that if backing_file is present, that it be
another vmdk image (see vmdk_co_do_create). Meanwhile, we want to
move towards always being explicit about the backing format for other
drivers where it matters. So for convenience, make qemu-img create -F
vmdk work, while rejecting all other explicit formats (note that this
is only for QemuOpts usage; there is no change to the QAPI to allow a
format through -blockdev).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200706203954.341758-5-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | block/vmdk.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/block/vmdk.c b/block/vmdk.c index 28cec50f38..bf9df5ce92 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2633,6 +2633,14 @@ static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv, bool zeroed_grain; bool compat6; VMDKCreateOptsData data; + char *backing_fmt = NULL; + + backing_fmt = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FMT); + if (backing_fmt && strcmp(backing_fmt, "vmdk") != 0) { + error_setg(errp, "backing_file must be a vmdk image"); + ret = -EINVAL; + goto exit; + } if (filename_decompose(filename, path, prefix, postfix, PATH_MAX, errp)) { ret = -EINVAL; @@ -2691,6 +2699,7 @@ static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv, vmdk_co_create_opts_cb, &data, errp); exit: + g_free(backing_fmt); g_free(adapter_type); g_free(backing_file); g_free(hw_version); @@ -3027,6 +3036,11 @@ static QemuOptsList vmdk_create_opts = { .help = "File name of a base image" }, { + .name = BLOCK_OPT_BACKING_FMT, + .type = QEMU_OPT_STRING, + .help = "Must be 'vmdk' if present", + }, + { .name = BLOCK_OPT_COMPAT6, .type = QEMU_OPT_BOOL, .help = "VMDK version 6 image", |