qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 09/10] qcow2: Use visitor for options in qco


From: Eric Blake
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 01/11/2018 01:52 PM, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
>  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: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]