All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: [PULL 05/12] sheepdog: Add trivial backing_fmt support
Date: Tue,  7 Jul 2020 18:34:57 +0200	[thread overview]
Message-ID: <20200707163504.194740-6-kwolf@redhat.com> (raw)
In-Reply-To: <20200707163504.194740-1-kwolf@redhat.com>

From: Eric Blake <eblake@redhat.com>

Sheepdog already requires that if backing_file is present, that it be
another sheepdog image (see sd_co_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
sheepdog 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-4-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/sheepdog.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 27a30d17f4..548ce54cbc 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2157,13 +2157,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");
@@ -2228,6 +2236,7 @@ fail:
     qapi_free_BlockdevCreateOptions(create_options);
     qobject_unref(qdict);
     g_free(redundancy);
+    g_free(backing_fmt);
     return ret;
 }
 
@@ -3185,6 +3194,11 @@ static QemuOptsList sd_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 'sheepdog' if present",
+        },
         {
             .name = BLOCK_OPT_PREALLOC,
             .type = QEMU_OPT_STRING,
-- 
2.25.4



  parent reply	other threads:[~2020-07-07 17:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 16:34 [PULL 00/12] Block layer patches Kevin Wolf
2020-07-07 16:34 ` [PULL 01/12] qemu-img map: Don't limit block status request size Kevin Wolf
2020-07-07 16:34 ` [PULL 02/12] file-posix: Mitigate file fragmentation with extent size hints Kevin Wolf
2020-07-07 16:34 ` [PULL 03/12] qemu-img: Flush stdout before before potential stderr messages Kevin Wolf
2020-07-07 16:34 ` [PULL 04/12] block: Finish deprecation of 'qemu-img convert -n -o' Kevin Wolf
2020-07-07 16:34 ` Kevin Wolf [this message]
2020-07-07 16:34 ` [PULL 06/12] vmdk: Add trivial backing_fmt support Kevin Wolf
2020-07-07 16:34 ` [PULL 07/12] qcow: Tolerate backing_fmt= Kevin Wolf
2020-07-07 16:35 ` [PULL 08/12] block: Error if backing file fails during creation without -u Kevin Wolf
2020-07-07 16:35 ` [PULL 09/12] qcow2: Deprecate use of qemu-img amend to change backing file Kevin Wolf
2020-07-07 16:35 ` [PULL 10/12] iotests: Specify explicit backing format where sensible Kevin Wolf
2020-07-07 16:35 ` [PULL 11/12] block: Add support to warn on backing file change without format Kevin Wolf
2020-07-07 16:35 ` [PULL 12/12] qemu-img: Deprecate use of -b without -F Kevin Wolf
2020-07-09 10:28 ` [PULL 00/12] Block layer patches Kevin Wolf

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=20200707163504.194740-6-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.