Blame SOURCES/kvm-block-Make-remaining-uses-of-qobject-input-visitor-m.patch

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