All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>,
	jcody@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org,
	mreitz@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH 10/19] block: Make remaining uses of qobject input visitor more robust
Date: Tue, 12 Jun 2018 18:32:56 +0200	[thread overview]
Message-ID: <874li8othj.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20180612144308.GD4355@localhost.localdomain> (Kevin Wolf's message of "Tue, 12 Jun 2018 16:43:08 +0200")

Kevin Wolf <kwolf@redhat.com> writes:

> Am 07.06.2018 um 08:25 hat Markus Armbruster geschrieben:
>> Remaining uses of qobject_input_visitor_new_keyval() in the block
>> subsystem:
>> 
>> * block_crypto_create_opts_init()
>>   Currently doesn't visit any non-string scalars, thus safe.  It's
>>   called from
>>   - block_crypto_open_luks()
>>     Creates the QDict with qemu_opts_to_qdict_filtered(), which
>>     creates only string scalars, but has a TODO asking for other types.
>>   - qcow_open()
>>   - qcow2_open(), qcow2_co_invalidate_cache(), qcow2_reopen_prepare()
>
> Do you mean block_crypto_open_opts_init()?

Yes.  Fixing...

>> * block_crypto_create_opts_init(), called from
>>   - block_crypto_co_create_opts_luks()
>>     Also creates the QDict with qemu_opts_to_qdict_filtered().
>> 
>> * vdi_co_create_opts()
>>   Also creates the QDict with qemu_opts_to_qdict_filtered().
>> 
>> Replace these uses by qobject_input_visitor_new_flat_confused() for
>> robustness.  This adds crumpling.  Right now, that's a no-op, but if
>> we ever extend these things in non-flat ways, crumpling will be
>> needed.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  block/crypto.c | 6 +++---
>>  block/vdi.c    | 4 ++--
>>  2 files changed, 5 insertions(+), 5 deletions(-)
>> 
>> diff --git a/block/crypto.c b/block/crypto.c
>> index bc322b50f5..25d12e9d47 100644
>> --- a/block/crypto.c
>> +++ b/block/crypto.c
>> @@ -21,11 +21,11 @@
>>  #include "qemu/osdep.h"
>>  
>>  #include "block/block_int.h"
>> +#include "block/qdict.h"
>>  #include "sysemu/block-backend.h"
>>  #include "crypto/block.h"
>>  #include "qapi/opts-visitor.h"
>>  #include "qapi/qapi-visit-crypto.h"
>> -#include "qapi/qmp/qdict.h"
>>  #include "qapi/qobject-input-visitor.h"
>>  #include "qapi/error.h"
>>  #include "qemu/option.h"
>> @@ -159,7 +159,7 @@ block_crypto_open_opts_init(QCryptoBlockFormat format,
>>      ret = g_new0(QCryptoBlockOpenOptions, 1);
>>      ret->format = format;
>>  
>> -    v = qobject_input_visitor_new_keyval(QOBJECT(opts));
>> +    v = qobject_input_visitor_new_flat_confused(opts, &error_abort);
>
> At least this &error_abort is not correct:
>
> $ ./qemu-img create -f qcow2 --object secret,id=sec0,data=foo -oencrypt.format=luks,encrypt.key-secret=sec0 /tmp/test.qcow2 64M
> Formatting '/tmp/test.qcow2', fmt=qcow2 size=67108864 encrypt.format=luks encrypt.key-secret=sec0 cluster_size=65536 lazy_refcounts=off refcount_bits=16
> $ x86_64-softmmu/qemu-system-x86_64 -drive driver=qcow2,encrypt.foo=1,encrypt.foo.bar=2,file.filename=/tmp/test.qcow2
> Unexpected error in qdict_crumple() at qobject/block-qdict.c:452:
> qemu-system-x86_64: -drive driver=qcow2,encrypt.foo=1,encrypt.foo.bar=2,file.filename=/tmp/test.qcow2: Key foo prefix is already set as a dict
> Abgebrochen (Speicherabzug geschrieben)
>
>>      visit_start_struct(v, NULL, NULL, 0, &local_err);
>>      if (local_err) {
>> @@ -210,7 +210,7 @@ block_crypto_create_opts_init(QCryptoBlockFormat format,
>>      ret = g_new0(QCryptoBlockCreateOptions, 1);
>>      ret->format = format;
>>  
>> -    v = qobject_input_visitor_new_keyval(QOBJECT(opts));
>> +    v = qobject_input_visitor_new_flat_confused(opts, &error_abort);
>>  
>>      visit_start_struct(v, NULL, NULL, 0, &local_err);
>>      if (local_err) {
>> diff --git a/block/vdi.c b/block/vdi.c
>> index 668af0a828..6b6eed126d 100644
>> --- a/block/vdi.c
>> +++ b/block/vdi.c
>> @@ -51,10 +51,10 @@
>>  
>>  #include "qemu/osdep.h"
>>  #include "qapi/error.h"
>> -#include "qapi/qmp/qdict.h"
>>  #include "qapi/qobject-input-visitor.h"
>>  #include "qapi/qapi-visit-block-core.h"
>>  #include "block/block_int.h"
>> +#include "block/qdict.h"
>>  #include "sysemu/block-backend.h"
>>  #include "qemu/module.h"
>>  #include "qemu/option.h"
>> @@ -934,7 +934,7 @@ static int coroutine_fn vdi_co_create_opts(const char *filename, QemuOpts *opts,
>>      }
>>  
>>      /* Get the QAPI object */
>> -    v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
>> +    v = qobject_input_visitor_new_flat_confused(qdict, &error_abort);
>>      visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
>>      visit_free(v);
>
> The other two &error_aborts _might_ be correct today because I couldn't
> see callers where the keys weren't already checked by QemuOpts, but I'm
> not sure if I looked at everything nor whether review would catch a
> future patch that added a new such call.

Okay, I'm getting rid of all three.

Thanks!

  reply	other threads:[~2018-06-12 16:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07  6:25 [Qemu-devel] [RFC PATCH 00/19] block: Configuration fixes and rbd authentication Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 01/19] rbd: Drop deprecated -drive parameter "filename" Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 02/19] iscsi: " Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 03/19] block: Add block-specific QDict header Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 04/19] fixup " Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 05/19] qobject: Move block-specific qdict code to block-qdict.c Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 06/19] block: Fix -blockdev for certain non-string scalars Markus Armbruster
2018-06-11 14:44   ` [Qemu-devel] [Qemu-block] " Max Reitz
2018-06-12 13:38   ` [Qemu-devel] " Kevin Wolf
2018-06-12 16:24     ` Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 07/19] block: Fix -drive " Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 08/19] block: Clean up a misuse of qobject_to() in .bdrv_co_create_opts() Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 09/19] block: Factor out qobject_input_visitor_new_flat_confused() Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 10/19] block: Make remaining uses of qobject input visitor more robust Markus Armbruster
2018-06-12 14:43   ` Kevin Wolf
2018-06-12 16:32     ` Markus Armbruster [this message]
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 11/19] block-qdict: Simplify qdict_flatten_qdict() Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 12/19] block-qdict: Tweak qdict_flatten_qdict(), qdict_flatten_qlist() Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 13/19] block-qdict: Clean up qdict_crumple() a bit Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 14/19] block-qdict: Simplify qdict_is_list() some Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 15/19] check-block-qdict: Rename qdict_flatten()'s variables for clarity Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 16/19] check-block-qdict: Cover flattening of empty lists and dictionaries Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 17/19] block: Fix -blockdev / blockdev-add for empty objects and arrays Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 18/19] rbd: New parameter auth-client-required Markus Armbruster
2018-06-07  6:25 ` [Qemu-devel] [RFC PATCH 19/19] rbd: New parameter key-secret Markus Armbruster
2018-06-07 21:33 ` [Qemu-devel] [RFC PATCH 00/19] block: Configuration fixes and rbd authentication Jeff Cody
2018-06-12 12:55   ` Jeff Cody
2018-06-12 19:04     ` Markus Armbruster

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=874li8othj.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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 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.