|
|
357786 |
From 8a66fde222f0192c1d9ce215f297964ab34235c7 Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
Date: Mon, 18 Jun 2018 08:43:20 +0200
|
|
|
357786 |
Subject: [PATCH 13/54] block: Factor out
|
|
|
357786 |
qobject_input_visitor_new_flat_confused()
|
|
|
357786 |
|
|
|
357786 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
Message-id: <20180618084330.30009-14-armbru@redhat.com>
|
|
|
357786 |
Patchwork-id: 80728
|
|
|
357786 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 13/23] block: Factor out qobject_input_visitor_new_flat_confused()
|
|
|
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 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
(cherry picked from commit af91062ee1408f7f5bb58389d355d29a5040c648)
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
block/nbd.c | 7 ++-----
|
|
|
357786 |
block/nfs.c | 7 ++-----
|
|
|
357786 |
block/parallels.c | 7 ++-----
|
|
|
357786 |
block/qcow.c | 7 ++-----
|
|
|
357786 |
block/qcow2.c | 7 ++-----
|
|
|
357786 |
block/qed.c | 7 ++-----
|
|
|
357786 |
block/rbd.c | 7 ++-----
|
|
|
357786 |
block/sheepdog.c | 14 ++++----------
|
|
|
357786 |
block/ssh.c | 7 ++-----
|
|
|
357786 |
block/vhdx.c | 7 ++-----
|
|
|
357786 |
block/vpc.c | 7 ++-----
|
|
|
357786 |
include/block/qdict.h | 3 ++-
|
|
|
357786 |
qobject/block-qdict.c | 28 +++++++++++++++++++++++++++-
|
|
|
357786 |
13 files changed, 53 insertions(+), 62 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/nbd.c b/block/nbd.c
|
|
|
357786 |
index b0be357..10912c3 100644
|
|
|
357786 |
--- a/block/nbd.c
|
|
|
357786 |
+++ b/block/nbd.c
|
|
|
357786 |
@@ -263,7 +263,6 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
|
|
|
357786 |
{
|
|
|
357786 |
SocketAddress *saddr = NULL;
|
|
|
357786 |
QDict *addr = NULL;
|
|
|
357786 |
- QObject *crumpled_addr = NULL;
|
|
|
357786 |
Visitor *iv = NULL;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
|
|
|
357786 |
@@ -273,12 +272,11 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
|
|
|
357786 |
goto done;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- crumpled_addr = qdict_crumple_for_keyval_qiv(addr, errp);
|
|
|
357786 |
- if (!crumpled_addr) {
|
|
|
357786 |
+ iv = qobject_input_visitor_new_flat_confused(addr, errp);
|
|
|
357786 |
+ if (!iv) {
|
|
|
357786 |
goto done;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- iv = qobject_input_visitor_new_keyval(crumpled_addr);
|
|
|
357786 |
visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
|
|
|
357786 |
if (local_err) {
|
|
|
357786 |
error_propagate(errp, local_err);
|
|
|
357786 |
@@ -287,7 +285,6 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
|
|
|
357786 |
|
|
|
357786 |
done:
|
|
|
357786 |
qobject_unref(addr);
|
|
|
357786 |
- qobject_unref(crumpled_addr);
|
|
|
357786 |
visit_free(iv);
|
|
|
357786 |
return saddr;
|
|
|
357786 |
}
|
|
|
357786 |
diff --git a/block/nfs.c b/block/nfs.c
|
|
|
357786 |
index 4090d28..1e12958 100644
|
|
|
357786 |
--- a/block/nfs.c
|
|
|
357786 |
+++ b/block/nfs.c
|
|
|
357786 |
@@ -556,19 +556,16 @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options,
|
|
|
357786 |
Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevOptionsNfs *opts = NULL;
|
|
|
357786 |
- QObject *crumpled = NULL;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
|
|
|
357786 |
- crumpled = qdict_crumple_for_keyval_qiv(options, errp);
|
|
|
357786 |
- if (crumpled == NULL) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(options, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
return NULL;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(crumpled);
|
|
|
357786 |
visit_type_BlockdevOptionsNfs(v, NULL, &opts, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
- qobject_unref(crumpled);
|
|
|
357786 |
|
|
|
357786 |
if (local_err) {
|
|
|
357786 |
return NULL;
|
|
|
357786 |
diff --git a/block/parallels.c b/block/parallels.c
|
|
|
357786 |
index 1c96c39..b6ebe36 100644
|
|
|
357786 |
--- a/block/parallels.c
|
|
|
357786 |
+++ b/block/parallels.c
|
|
|
357786 |
@@ -615,7 +615,6 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
QDict *qdict;
|
|
|
357786 |
- QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
int ret;
|
|
|
357786 |
|
|
|
357786 |
@@ -651,14 +650,12 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "driver", "parallels");
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
- qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- if (!qobj) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(qdict, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto done;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
- qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/qcow.c b/block/qcow.c
|
|
|
357786 |
index 43a595a..4b3bc31 100644
|
|
|
357786 |
--- a/block/qcow.c
|
|
|
357786 |
+++ b/block/qcow.c
|
|
|
357786 |
@@ -945,7 +945,6 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
QDict *qdict;
|
|
|
357786 |
- QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
const char *val;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
@@ -995,14 +994,12 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "driver", "qcow");
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
- qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- if (!qobj) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(qdict, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
- qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
357786 |
index ede52a8..35842c5 100644
|
|
|
357786 |
--- a/block/qcow2.c
|
|
|
357786 |
+++ b/block/qcow2.c
|
|
|
357786 |
@@ -3068,7 +3068,6 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
QDict *qdict;
|
|
|
357786 |
- QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
@@ -3139,14 +3138,12 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
/* Now get the QAPI type BlockdevCreateOptions */
|
|
|
357786 |
- qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- if (!qobj) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(qdict, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto finish;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
- qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/qed.c b/block/qed.c
|
|
|
357786 |
index 3818888..4c5d7e8 100644
|
|
|
357786 |
--- a/block/qed.c
|
|
|
357786 |
+++ b/block/qed.c
|
|
|
357786 |
@@ -723,7 +723,6 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
QDict *qdict;
|
|
|
357786 |
- QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
@@ -763,14 +762,12 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "driver", "qed");
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
- qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- if (!qobj) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(qdict, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
- qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/rbd.c b/block/rbd.c
|
|
|
357786 |
index 0b5455f..c834d72 100644
|
|
|
357786 |
--- a/block/rbd.c
|
|
|
357786 |
+++ b/block/rbd.c
|
|
|
357786 |
@@ -623,7 +623,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
357786 |
BDRVRBDState *s = bs->opaque;
|
|
|
357786 |
BlockdevOptionsRbd *opts = NULL;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
- QObject *crumpled = NULL;
|
|
|
357786 |
const QDictEntry *e;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
char *keypairs, *secretid;
|
|
|
357786 |
@@ -640,16 +639,14 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
/* Convert the remaining options into a QAPI object */
|
|
|
357786 |
- crumpled = qdict_crumple_for_keyval_qiv(options, errp);
|
|
|
357786 |
- if (crumpled == NULL) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(options, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
r = -EINVAL;
|
|
|
357786 |
goto out;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(crumpled);
|
|
|
357786 |
visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
- qobject_unref(crumpled);
|
|
|
357786 |
|
|
|
357786 |
if (local_err) {
|
|
|
357786 |
error_propagate(errp, local_err);
|
|
|
357786 |
diff --git a/block/sheepdog.c b/block/sheepdog.c
|
|
|
357786 |
index dd582d5..d1c9bf5 100644
|
|
|
357786 |
--- a/block/sheepdog.c
|
|
|
357786 |
+++ b/block/sheepdog.c
|
|
|
357786 |
@@ -539,19 +539,17 @@ static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s,
|
|
|
357786 |
static SocketAddress *sd_server_config(QDict *options, Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
QDict *server = NULL;
|
|
|
357786 |
- QObject *crumpled_server = NULL;
|
|
|
357786 |
Visitor *iv = NULL;
|
|
|
357786 |
SocketAddress *saddr = NULL;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
|
|
|
357786 |
qdict_extract_subqdict(options, &server, "server.");
|
|
|
357786 |
|
|
|
357786 |
- crumpled_server = qdict_crumple_for_keyval_qiv(server, errp);
|
|
|
357786 |
- if (!crumpled_server) {
|
|
|
357786 |
+ iv = qobject_input_visitor_new_flat_confused(server, errp);
|
|
|
357786 |
+ if (!iv) {
|
|
|
357786 |
goto done;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- iv = qobject_input_visitor_new_keyval(crumpled_server);
|
|
|
357786 |
visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
|
|
|
357786 |
if (local_err) {
|
|
|
357786 |
error_propagate(errp, local_err);
|
|
|
357786 |
@@ -560,7 +558,6 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp)
|
|
|
357786 |
|
|
|
357786 |
done:
|
|
|
357786 |
visit_free(iv);
|
|
|
357786 |
- qobject_unref(crumpled_server);
|
|
|
357786 |
qobject_unref(server);
|
|
|
357786 |
return saddr;
|
|
|
357786 |
}
|
|
|
357786 |
@@ -2174,7 +2171,6 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
QDict *qdict, *location_qdict;
|
|
|
357786 |
- QObject *crumpled;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
const char *redundancy;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
@@ -2210,16 +2206,14 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
/* Get the QAPI object */
|
|
|
357786 |
- crumpled = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- if (crumpled == NULL) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(qdict, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(crumpled);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
- qobject_unref(crumpled);
|
|
|
357786 |
|
|
|
357786 |
if (local_err) {
|
|
|
357786 |
error_propagate(errp, local_err);
|
|
|
357786 |
diff --git a/block/ssh.c b/block/ssh.c
|
|
|
357786 |
index 2fc7cd9..aab6996 100644
|
|
|
357786 |
--- a/block/ssh.c
|
|
|
357786 |
+++ b/block/ssh.c
|
|
|
357786 |
@@ -606,7 +606,6 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp)
|
|
|
357786 |
BlockdevOptionsSsh *result = NULL;
|
|
|
357786 |
QemuOpts *opts = NULL;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
- QObject *crumpled;
|
|
|
357786 |
const QDictEntry *e;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
|
|
|
357786 |
@@ -623,15 +622,13 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp)
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
/* Create the QAPI object */
|
|
|
357786 |
- crumpled = qdict_crumple_for_keyval_qiv(options, errp);
|
|
|
357786 |
- if (crumpled == NULL) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(options, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(crumpled);
|
|
|
357786 |
visit_type_BlockdevOptionsSsh(v, NULL, &result, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
- qobject_unref(crumpled);
|
|
|
357786 |
|
|
|
357786 |
if (local_err) {
|
|
|
357786 |
error_propagate(errp, local_err);
|
|
|
357786 |
diff --git a/block/vhdx.c b/block/vhdx.c
|
|
|
357786 |
index 728d8b3..6731298 100644
|
|
|
357786 |
--- a/block/vhdx.c
|
|
|
357786 |
+++ b/block/vhdx.c
|
|
|
357786 |
@@ -1964,7 +1964,6 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
QDict *qdict;
|
|
|
357786 |
- QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
@@ -2003,14 +2002,12 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "driver", "vhdx");
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
- qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- if (!qobj) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(qdict, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
- qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/vpc.c b/block/vpc.c
|
|
|
357786 |
index a9bb041..bf294ab 100644
|
|
|
357786 |
--- a/block/vpc.c
|
|
|
357786 |
+++ b/block/vpc.c
|
|
|
357786 |
@@ -1082,7 +1082,6 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
QDict *qdict;
|
|
|
357786 |
- QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
@@ -1119,14 +1118,12 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "driver", "vpc");
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
- qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- if (!qobj) {
|
|
|
357786 |
+ v = qobject_input_visitor_new_flat_confused(qdict, errp);
|
|
|
357786 |
+ if (!v) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
- qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/include/block/qdict.h b/include/block/qdict.h
|
|
|
357786 |
index 47d9638..d8cb502 100644
|
|
|
357786 |
--- a/include/block/qdict.h
|
|
|
357786 |
+++ b/include/block/qdict.h
|
|
|
357786 |
@@ -21,7 +21,6 @@ void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start);
|
|
|
357786 |
void qdict_array_split(QDict *src, QList **dst);
|
|
|
357786 |
int qdict_array_entries(QDict *src, const char *subqdict);
|
|
|
357786 |
QObject *qdict_crumple(const QDict *src, Error **errp);
|
|
|
357786 |
-QObject *qdict_crumple_for_keyval_qiv(QDict *qdict, Error **errp);
|
|
|
357786 |
void qdict_flatten(QDict *qdict);
|
|
|
357786 |
|
|
|
357786 |
typedef struct QDictRenames {
|
|
|
357786 |
@@ -30,4 +29,6 @@ typedef struct QDictRenames {
|
|
|
357786 |
} QDictRenames;
|
|
|
357786 |
bool qdict_rename_keys(QDict *qdict, const QDictRenames *renames, Error **errp);
|
|
|
357786 |
|
|
|
357786 |
+Visitor *qobject_input_visitor_new_flat_confused(QDict *qdict,
|
|
|
357786 |
+ Error **errp);
|
|
|
357786 |
#endif
|
|
|
357786 |
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
|
|
|
357786 |
index aba372c..41f39ab 100644
|
|
|
357786 |
--- a/qobject/block-qdict.c
|
|
|
357786 |
+++ b/qobject/block-qdict.c
|
|
|
357786 |
@@ -13,6 +13,7 @@
|
|
|
357786 |
#include "qapi/qmp/qlist.h"
|
|
|
357786 |
#include "qapi/qmp/qnum.h"
|
|
|
357786 |
#include "qapi/qmp/qstring.h"
|
|
|
357786 |
+#include "qapi/qobject-input-visitor.h"
|
|
|
357786 |
#include "qemu/cutils.h"
|
|
|
357786 |
#include "qapi/error.h"
|
|
|
357786 |
|
|
|
357786 |
@@ -529,7 +530,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp)
|
|
|
357786 |
* used for anything else, and it should go away once the block
|
|
|
357786 |
* subsystem has been cleaned up.
|
|
|
357786 |
*/
|
|
|
357786 |
-QObject *qdict_crumple_for_keyval_qiv(QDict *src, Error **errp)
|
|
|
357786 |
+static QObject *qdict_crumple_for_keyval_qiv(QDict *src, Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
QDict *tmp = NULL;
|
|
|
357786 |
char *buf;
|
|
|
357786 |
@@ -695,3 +696,28 @@ bool qdict_rename_keys(QDict *qdict, const QDictRenames *renames, Error **errp)
|
|
|
357786 |
}
|
|
|
357786 |
return true;
|
|
|
357786 |
}
|
|
|
357786 |
+
|
|
|
357786 |
+/*
|
|
|
357786 |
+ * Create a QObject input visitor for flat @qdict with possibly
|
|
|
357786 |
+ * confused scalar types.
|
|
|
357786 |
+ *
|
|
|
357786 |
+ * The block subsystem uses this function to visit its flat QDict with
|
|
|
357786 |
+ * possibly confused scalar types. It should not be used for anything
|
|
|
357786 |
+ * else, and it should go away once the block subsystem has been
|
|
|
357786 |
+ * cleaned up.
|
|
|
357786 |
+ */
|
|
|
357786 |
+Visitor *qobject_input_visitor_new_flat_confused(QDict *qdict,
|
|
|
357786 |
+ Error **errp)
|
|
|
357786 |
+{
|
|
|
357786 |
+ QObject *crumpled;
|
|
|
357786 |
+ Visitor *v;
|
|
|
357786 |
+
|
|
|
357786 |
+ crumpled = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
+ if (!crumpled) {
|
|
|
357786 |
+ return NULL;
|
|
|
357786 |
+ }
|
|
|
357786 |
+
|
|
|
357786 |
+ v = qobject_input_visitor_new_keyval(crumpled);
|
|
|
357786 |
+ qobject_unref(crumpled);
|
|
|
357786 |
+ return v;
|
|
|
357786 |
+}
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|