qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Fam Zheng <fam@euphon.net>,
	pkrempa@redhat.com, qemu-block@nongnu.org, kchamart@redhat.com,
	libvir-list@redhat.com, Michael Tokarev <mjt@tls.msk.ru>,
	Laurent Vivier <laurent@vivier.eu>,
	mreitz@redhat.com,
	"open list:Trivial patches" <qemu-trivial@nongnu.org>
Subject: [PATCH v4 2/7] vmdk: Add trivial backing_fmt support
Date: Thu, 12 Mar 2020 14:28:17 -0500	[thread overview]
Message-ID: <20200312192822.3739399-3-eblake@redhat.com> (raw)
In-Reply-To: <20200312192822.3739399-1-eblake@redhat.com>

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>
---
 block/vmdk.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/block/vmdk.c b/block/vmdk.c
index 20e909d99794..3c7893817afe 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -2611,6 +2611,14 @@ static int coroutine_fn vmdk_co_create_opts(const char *filename, QemuOpts *opts
     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;
@@ -2669,6 +2677,7 @@ static int coroutine_fn vmdk_co_create_opts(const char *filename, QemuOpts *opts
                             vmdk_co_create_opts_cb, &data, errp);

 exit:
+    g_free(backing_fmt);
     g_free(adapter_type);
     g_free(backing_file);
     g_free(hw_version);
@@ -3005,6 +3014,11 @@ static QemuOptsList vmdk_create_opts = {
             .type = QEMU_OPT_STRING,
             .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,
-- 
2.25.1



  parent reply	other threads:[~2020-03-12 19:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 19:28 [PATCH v4 0/7] Tighten qemu-img rules on missing backing format Eric Blake
2020-03-12 19:28 ` [PATCH v4 1/7] sheepdog: Add trivial backing_fmt support Eric Blake
2020-03-12 19:28 ` Eric Blake [this message]
2020-03-12 19:28 ` [PATCH v4 3/7] qcow: Tolerate backing_fmt=, but warn on backing_fmt=raw Eric Blake
2020-03-12 19:28 ` [PATCH v4 4/7] qcow2: Deprecate use of qemu-img amend to change backing file Eric Blake
2020-03-12 19:28 ` [PATCH v4 5/7] iotests: Specify explicit backing format where sensible Eric Blake
2020-03-12 19:28 ` [PATCH v4 6/7] block: Add support to warn on backing file change without format Eric Blake
2020-03-12 19:28 ` [PATCH v4 7/7] qemu-img: Deprecate use of -b without -F Eric Blake
2020-03-13 18:22   ` Eric Blake
2020-03-17 16:21   ` Kashyap Chamarthy
2020-03-12 21:39 ` [PATCH v4 0/7] Tighten qemu-img rules on missing backing format no-reply
2020-03-12 22:01   ` Eric Blake
2020-03-12 21:43 ` no-reply
2020-03-12 21:46 ` no-reply
2020-04-02 21:32 ` [PATCH for-5.0? " Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200312192822.3739399-3-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=fam@euphon.net \
    --cc=kchamart@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=libvir-list@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=mreitz@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).