[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 13/26] block: Make remaining uses of qobject input vi
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 13/26] block: Make remaining uses of qobject input visitor more robust |
Date: |
Fri, 15 Jun 2018 16:20:55 +0200 |
From: Markus Armbruster <address@hidden>
Remaining uses of qobject_input_visitor_new_keyval() in the block
subsystem:
* block_crypto_open_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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/crypto.c | 12 +++++++++---
block/vdi.c | 8 ++++++--
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/block/crypto.c b/block/crypto.c
index bc322b50f5..82091c5f70 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,10 @@ 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, &local_err);
+ if (local_err) {
+ goto out;
+ }
visit_start_struct(v, NULL, NULL, 0, &local_err);
if (local_err) {
@@ -210,7 +213,10 @@ 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, &local_err);
+ if (local_err) {
+ goto out;
+ }
visit_start_struct(v, NULL, NULL, 0, &local_err);
if (local_err) {
diff --git a/block/vdi.c b/block/vdi.c
index 668af0a828..1d8ed67dbf 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,11 @@ 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, errp);
+ if (!v) {
+ ret = -EINVAL;
+ goto done;
+ }
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
visit_free(v);
--
2.13.6
- [Qemu-block] [PULL 10/26] block: Fix -drive for certain non-string scalars, (continued)
- [Qemu-block] [PULL 10/26] block: Fix -drive for certain non-string scalars, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 14/26] block-qdict: Simplify qdict_flatten_qdict(), Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 12/26] block: Factor out qobject_input_visitor_new_flat_confused(), Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 16/26] block-qdict: Clean up qdict_crumple() a bit, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 11/26] block: Clean up a misuse of qobject_to() in .bdrv_co_create_opts(), Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 17/26] block-qdict: Simplify qdict_is_list() some, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 19/26] check-block-qdict: Cover flattening of empty lists and dictionaries, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 21/26] rbd: New parameter auth-client-required, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 20/26] block: Fix -blockdev / blockdev-add for empty objects and arrays, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 22/26] rbd: New parameter key-secret, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 13/26] block: Make remaining uses of qobject input visitor more robust,
Kevin Wolf <=
- [Qemu-block] [PULL 18/26] check-block-qdict: Rename qdict_flatten()'s variables for clarity, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 08/26] qobject: Move block-specific qdict code to block-qdict.c, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 24/26] block: Remove deprecated -drive option addr, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 23/26] block: Remove deprecated -drive geometry options, Kevin Wolf, 2018/06/15
- [Qemu-block] [PULL 25/26] block: Remove deprecated -drive option serial, Kevin Wolf, 2018/06/15