From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: mreitz@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH 09/10] qcow2: Use visitor for options in qcow2_create()
Date: Tue, 16 Jan 2018 13:59:00 -0600 [thread overview]
Message-ID: <64cf790b-485c-06dd-ad0e-7686914e3fa8@redhat.com> (raw)
In-Reply-To: <20180111195225.4226-10-kwolf@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2812 bytes --]
On 01/11/2018 01:52 PM, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/qcow2.c | 227 ++++++++++++++++++---------------------------
> tests/qemu-iotests/049.out | 10 +-
> 2 files changed, 93 insertions(+), 144 deletions(-)
>
> + /* Only the keyval visitor supports the dotted syntax needed for
> + * encryption, so go through a QDict before getting a QAPI type. Ignore
> + * options meant for the protocol layer so that the visitor doesn't
> + * complain. */
> + qdict = qemu_opts_to_qdict_filtered(opts, NULL, bdrv_qcow2.create_opts,
> + true);
Whether we like it or not, the keyval visitor is getting more and more
important!
> +
> + /* TODO QAPI doesn't allow dots in enum values. Either change QAPI or
> + * decide on the proper new representation for blockdev-create */
> + val = qdict_get_try_str(qdict, BLOCK_OPT_COMPAT_LEVEL);
> + if (val && !strcmp(val, "0.10")) {
> + qdict_put_str(qdict, BLOCK_OPT_COMPAT_LEVEL, "0_10");
> + } else if (val && !strcmp(val, "1.1")) {
> + qdict_put_str(qdict, BLOCK_OPT_COMPAT_LEVEL, "1_1");
Yeah, I flagged that in the earlier QAPI patch. The fact that it starts
with a number at all is also a bit worrying (we have to support leading
digits for legacy reasons in QKeyCode, but maybe naming things just 'v2'
and 'v3' might be cleaner than '0_10' and '1_1'?)
> + /* Now get the QAPI type BlockdevCreateOptions */
> + qobj = qdict_crumple(qdict, errp);
> + QDECREF(qdict);
> + qdict = qobject_to_qdict(qobj);
> + if (qdict == NULL) {
> ret = -EINVAL;
> goto finish;
> }
>
> - if (qemu_opt_get_bool_del(opts, BLOCK_OPT_LAZY_REFCOUNTS, false)) {
> - flags |= BLOCK_FLAG_LAZY_REFCOUNTS;
> - }
> + v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
> + visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
> + visit_free(v);
Feels like a lot of round-tripping between formats to get things this
compact - but it's as good as anything else I can come up with.
> +++ b/tests/qemu-iotests/049.out
> @@ -106,7 +106,7 @@ qemu-img: Value '-1k' is out of range for parameter 'size'
> qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2'
>
> qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1kilobyte
> -qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suffixes for
> +qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suffixes for
Why are you re-adding trailing whitespace?
Overall seems sane.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2018-01-16 19:59 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-11 19:52 [Qemu-devel] [RFC PATCH 00/10] x-blockdev-create for qcow2 Kevin Wolf
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 01/10] block/qapi: Introduce BlockdevCreateOptions Kevin Wolf
2018-01-16 18:54 ` Eric Blake
2018-01-16 19:58 ` Kevin Wolf
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 02/10] block/qapi: Add qcow2 create options to schema Kevin Wolf
2018-01-12 10:53 ` Daniel P. Berrange
2018-01-15 13:38 ` Kevin Wolf
2018-01-15 13:51 ` Daniel P. Berrange
2018-01-15 14:07 ` Kevin Wolf
2018-01-15 14:11 ` Daniel P. Berrange
2018-01-16 18:59 ` Eric Blake
2018-01-16 20:11 ` Kevin Wolf
2018-01-16 20:27 ` Eric Blake
2018-01-29 16:57 ` Max Reitz
2018-01-29 18:06 ` Kevin Wolf
2018-01-29 18:06 ` Max Reitz
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 03/10] qcow2: Let qcow2_create() handle protocol layer Kevin Wolf
2018-01-16 19:03 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 04/10] qcow2: Pass BlockdevCreateOptions to qcow2_create2() Kevin Wolf
2018-01-16 19:21 ` Eric Blake
2018-01-29 17:12 ` Max Reitz
2018-01-29 18:10 ` Kevin Wolf
2018-01-29 18:11 ` Max Reitz
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 05/10] qcow2: Use BlockdevRef in qcow2_create2() Kevin Wolf
2018-01-16 19:35 ` Eric Blake
2018-01-29 17:30 ` Max Reitz
2018-01-29 18:14 ` Kevin Wolf
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 06/10] qcow2: Use QCryptoBlockCreateOptions " Kevin Wolf
2018-01-16 19:37 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 07/10] qcow2: Handle full/falloc preallocation " Kevin Wolf
2018-01-16 19:40 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 08/10] util: Add qemu_opts_to_qdict_filtered() Kevin Wolf
2018-01-16 19:45 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 09/10] qcow2: Use visitor for options in qcow2_create() Kevin Wolf
2018-01-16 19:59 ` Eric Blake [this message]
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 10/10] block: x-blockdev-create QMP command Kevin Wolf
2018-01-16 20:06 ` Eric Blake
2018-01-17 17:50 ` Kevin Wolf
2018-01-11 20:40 ` [Qemu-devel] [RFC PATCH 00/10] x-blockdev-create for qcow2 no-reply
2018-01-11 20:40 ` no-reply
2018-01-16 10:23 ` Kevin Wolf
2018-01-29 18:23 ` Max Reitz
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=64cf790b-485c-06dd-ad0e-7686914e3fa8@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pkrempa@redhat.com \
--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 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).