From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQoNC-0000oO-4v for qemu-devel@nongnu.org; Thu, 07 Jun 2018 02:26:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQoNA-0002sY-9m for qemu-devel@nongnu.org; Thu, 07 Jun 2018 02:26:14 -0400 From: Markus Armbruster Date: Thu, 7 Jun 2018 08:25:50 +0200 Message-Id: <20180607062559.16127-11-armbru@redhat.com> In-Reply-To: <20180607062559.16127-1-armbru@redhat.com> References: <20180607062559.16127-1-armbru@redhat.com> Subject: [Qemu-devel] [RFC PATCH 10/19] block: Make remaining uses of qobject input visitor more robust List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, mreitz@redhat.com, jcody@redhat.com, eblake@redhat.com 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() * 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 --- 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); 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); -- 2.17.1