From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pkrempa@redhat.com,
"open list:Sheepdog" <sheepdog@lists.wpkg.org>,
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>,
Liu Yuan <namei.unix@gmail.com>
Subject: [PATCH v5 1/7] sheepdog: Add trivial backing_fmt support
Date: Fri, 3 Apr 2020 12:58:53 -0500 [thread overview]
Message-ID: <20200403175859.863248-2-eblake@redhat.com> (raw)
In-Reply-To: <20200403175859.863248-1-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>
---
block/sheepdog.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 59f7ebb1710f..8f558367d2d5 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2163,13 +2163,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");
@@ -2234,6 +2242,7 @@ fail:
qapi_free_BlockdevCreateOptions(create_options);
qobject_unref(qdict);
g_free(redundancy);
+ g_free(backing_fmt);
return ret;
}
@@ -3191,6 +3200,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.26.0.rc2
next prev parent reply other threads:[~2020-04-03 18:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-03 17:58 [PATCH v5 for-5.0? 0/7] Tighten qemu-img rules on missing backing format Eric Blake
2020-04-03 17:58 ` Eric Blake [this message]
2020-04-03 17:58 ` [PATCH v5 2/7] vmdk: Add trivial backing_fmt support Eric Blake
2020-04-03 17:58 ` [PATCH v5 3/7] qcow: Tolerate backing_fmt=, but warn on backing_fmt=raw Eric Blake
2020-05-05 7:35 ` Kevin Wolf
2020-05-05 15:30 ` Eric Blake
2020-06-22 21:58 ` Eric Blake
2020-06-23 10:40 ` Kevin Wolf
2020-04-03 17:58 ` [PATCH v5 4/7] qcow2: Deprecate use of qemu-img amend to change backing file Eric Blake
2020-05-05 7:50 ` Kevin Wolf
2020-04-03 17:58 ` [PATCH v5 5/7] iotests: Specify explicit backing format where sensible Eric Blake
2020-04-03 17:58 ` [PATCH v5 6/7] block: Add support to warn on backing file change without format Eric Blake
2020-04-03 17:58 ` [PATCH v5 7/7] qemu-img: Deprecate use of -b without -F Eric Blake
2020-05-05 8:11 ` Kevin Wolf
2020-05-05 8:43 ` Peter Krempa
2020-05-04 20:02 ` [PATCH v5 for-5.0? 0/7] Tighten qemu-img rules on missing backing format 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=20200403175859.863248-2-eblake@redhat.com \
--to=eblake@redhat.com \
--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=namei.unix@gmail.com \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=sheepdog@lists.wpkg.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).