|
|
ae23c9 |
From d8f04a096c6c5ec035c17ef41e1af1801beb27a6 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Date: Mon, 18 Jun 2018 08:43:21 +0200
|
|
|
ae23c9 |
Subject: [PATCH 023/268] block: Make remaining uses of qobject input visitor
|
|
|
ae23c9 |
more robust
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180618084330.30009-15-armbru@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 80730
|
|
|
ae23c9 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 14/23] block: Make remaining uses of qobject input visitor more robust
|
|
|
ae23c9 |
Bugzilla: 1557995
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Remaining uses of qobject_input_visitor_new_keyval() in the block
|
|
|
ae23c9 |
subsystem:
|
|
|
ae23c9 |
|
|
|
ae23c9 |
* block_crypto_open_opts_init()
|
|
|
ae23c9 |
Currently doesn't visit any non-string scalars, thus safe. It's
|
|
|
ae23c9 |
called from
|
|
|
ae23c9 |
- block_crypto_open_luks()
|
|
|
ae23c9 |
Creates the QDict with qemu_opts_to_qdict_filtered(), which
|
|
|
ae23c9 |
creates only string scalars, but has a TODO asking for other types.
|
|
|
ae23c9 |
- qcow_open()
|
|
|
ae23c9 |
- qcow2_open(), qcow2_co_invalidate_cache(), qcow2_reopen_prepare()
|
|
|
ae23c9 |
|
|
|
ae23c9 |
* block_crypto_create_opts_init(), called from
|
|
|
ae23c9 |
- block_crypto_co_create_opts_luks()
|
|
|
ae23c9 |
Also creates the QDict with qemu_opts_to_qdict_filtered().
|
|
|
ae23c9 |
|
|
|
ae23c9 |
* vdi_co_create_opts()
|
|
|
ae23c9 |
Also creates the QDict with qemu_opts_to_qdict_filtered().
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Replace these uses by qobject_input_visitor_new_flat_confused() for
|
|
|
ae23c9 |
robustness. This adds crumpling. Right now, that's a no-op, but if
|
|
|
ae23c9 |
we ever extend these things in non-flat ways, crumpling will be
|
|
|
ae23c9 |
needed.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit f853465aacb45dbb07e4cc9815e39b55e10dc690)
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block/crypto.c | 12 +++++++++---
|
|
|
ae23c9 |
block/vdi.c | 8 ++++++--
|
|
|
ae23c9 |
2 files changed, 15 insertions(+), 5 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block/crypto.c b/block/crypto.c
|
|
|
ae23c9 |
index 7e7ad2d..f5151f4 100644
|
|
|
ae23c9 |
--- a/block/crypto.c
|
|
|
ae23c9 |
+++ b/block/crypto.c
|
|
|
ae23c9 |
@@ -21,11 +21,11 @@
|
|
|
ae23c9 |
#include "qemu/osdep.h"
|
|
|
ae23c9 |
|
|
|
ae23c9 |
#include "block/block_int.h"
|
|
|
ae23c9 |
+#include "block/qdict.h"
|
|
|
ae23c9 |
#include "sysemu/block-backend.h"
|
|
|
ae23c9 |
#include "crypto/block.h"
|
|
|
ae23c9 |
#include "qapi/opts-visitor.h"
|
|
|
ae23c9 |
#include "qapi/qapi-visit-crypto.h"
|
|
|
ae23c9 |
-#include "qapi/qmp/qdict.h"
|
|
|
ae23c9 |
#include "qapi/qobject-input-visitor.h"
|
|
|
ae23c9 |
#include "qapi/error.h"
|
|
|
ae23c9 |
#include "qemu/option.h"
|
|
|
ae23c9 |
@@ -159,7 +159,10 @@ block_crypto_open_opts_init(QCryptoBlockFormat format,
|
|
|
ae23c9 |
ret = g_new0(QCryptoBlockOpenOptions, 1);
|
|
|
ae23c9 |
ret->format = format;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- v = qobject_input_visitor_new_keyval(QOBJECT(opts));
|
|
|
ae23c9 |
+ v = qobject_input_visitor_new_flat_confused(opts, &local_err);
|
|
|
ae23c9 |
+ if (local_err) {
|
|
|
ae23c9 |
+ goto out;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
|
|
|
ae23c9 |
visit_start_struct(v, NULL, NULL, 0, &local_err);
|
|
|
ae23c9 |
if (local_err) {
|
|
|
ae23c9 |
@@ -210,7 +213,10 @@ block_crypto_create_opts_init(QCryptoBlockFormat format,
|
|
|
ae23c9 |
ret = g_new0(QCryptoBlockCreateOptions, 1);
|
|
|
ae23c9 |
ret->format = format;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- v = qobject_input_visitor_new_keyval(QOBJECT(opts));
|
|
|
ae23c9 |
+ v = qobject_input_visitor_new_flat_confused(opts, &local_err);
|
|
|
ae23c9 |
+ if (local_err) {
|
|
|
ae23c9 |
+ goto out;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
|
|
|
ae23c9 |
visit_start_struct(v, NULL, NULL, 0, &local_err);
|
|
|
ae23c9 |
if (local_err) {
|
|
|
ae23c9 |
diff --git a/block/vdi.c b/block/vdi.c
|
|
|
ae23c9 |
index 96a22b8..41859a8 100644
|
|
|
ae23c9 |
--- a/block/vdi.c
|
|
|
ae23c9 |
+++ b/block/vdi.c
|
|
|
ae23c9 |
@@ -51,10 +51,10 @@
|
|
|
ae23c9 |
|
|
|
ae23c9 |
#include "qemu/osdep.h"
|
|
|
ae23c9 |
#include "qapi/error.h"
|
|
|
ae23c9 |
-#include "qapi/qmp/qdict.h"
|
|
|
ae23c9 |
#include "qapi/qobject-input-visitor.h"
|
|
|
ae23c9 |
#include "qapi/qapi-visit-block-core.h"
|
|
|
ae23c9 |
#include "block/block_int.h"
|
|
|
ae23c9 |
+#include "block/qdict.h"
|
|
|
ae23c9 |
#include "sysemu/block-backend.h"
|
|
|
ae23c9 |
#include "qemu/module.h"
|
|
|
ae23c9 |
#include "qemu/option.h"
|
|
|
ae23c9 |
@@ -933,7 +933,11 @@ static int coroutine_fn vdi_co_create_opts(const char *filename, QemuOpts *opts,
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* Get the QAPI object */
|
|
|
ae23c9 |
- v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
|
|
|
ae23c9 |
+ v = qobject_input_visitor_new_flat_confused(qdict, errp);
|
|
|
ae23c9 |
+ if (!v) {
|
|
|
ae23c9 |
+ ret = -EINVAL;
|
|
|
ae23c9 |
+ goto done;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
ae23c9 |
visit_free(v);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|