aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-07-06 11:38:09 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-07-06 11:38:09 +0100
commit975b1c3ac6ae57b3e1356b0156c68f63a8a349dc (patch)
treeecd35419f10196800c44176645084c3691f660df /qom
parentfc5d0a2b243ad7bd4db1f29e6e274507df54a8a8 (diff)
parentb6954712abea03afd686b724060f9873e2c61f2b (diff)
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2016-07-06' into staging
QAPI patches for 2016-07-06 # gpg: Signature made Wed 06 Jul 2016 10:00:51 BST # gpg: using RSA key 0x3870B400EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2016-07-06: replay: Use new QAPI cloning sockets: Use new QAPI cloning qapi: Add new clone visitor qapi: Add new visit_complete() function tests: Factor out common code in qapi output tests tests: Clean up test-string-output-visitor qmp-output-visitor: Favor new visit_free() function string-output-visitor: Favor new visit_free() function qmp-input-visitor: Favor new visit_free() function string-input-visitor: Favor new visit_free() function opts-visitor: Favor new visit_free() function qapi: Add new visit_free() function qapi: Add parameter to visit_end_* qemu-img: Don't leak errors when outputting JSON qapi: Improve use of qmp/types.h Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c58
-rw-r--r--qom/object_interfaces.c12
-rw-r--r--qom/qom-qobject.c19
3 files changed, 41 insertions, 48 deletions
diff --git a/qom/object.c b/qom/object.c
index 9743ea4708..8166b7dace 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1221,8 +1221,7 @@ int object_property_get_enum(Object *obj, const char *name,
const char *typename, Error **errp)
{
Error *err = NULL;
- StringOutputVisitor *sov;
- StringInputVisitor *siv;
+ Visitor *v;
char *str;
int ret;
ObjectProperty *prop = object_property_find(obj, name, errp);
@@ -1241,21 +1240,20 @@ int object_property_get_enum(Object *obj, const char *name,
enumprop = prop->opaque;
- sov = string_output_visitor_new(false);
- object_property_get(obj, string_output_get_visitor(sov), name, &err);
+ v = string_output_visitor_new(false, &str);
+ object_property_get(obj, v, name, &err);
if (err) {
error_propagate(errp, err);
- string_output_visitor_cleanup(sov);
+ visit_free(v);
return 0;
}
- str = string_output_get_string(sov);
- siv = string_input_visitor_new(str);
- string_output_visitor_cleanup(sov);
- visit_type_enum(string_input_get_visitor(siv), name, &ret,
- enumprop->strings, errp);
+ visit_complete(v, &str);
+ visit_free(v);
+ v = string_input_visitor_new(str);
+ visit_type_enum(v, name, &ret, enumprop->strings, errp);
g_free(str);
- string_input_visitor_cleanup(siv);
+ visit_free(v);
return ret;
}
@@ -1264,55 +1262,51 @@ void object_property_get_uint16List(Object *obj, const char *name,
uint16List **list, Error **errp)
{
Error *err = NULL;
- StringOutputVisitor *ov;
- StringInputVisitor *iv;
+ Visitor *v;
char *str;
- ov = string_output_visitor_new(false);
- object_property_get(obj, string_output_get_visitor(ov),
- name, &err);
+ v = string_output_visitor_new(false, &str);
+ object_property_get(obj, v, name, &err);
if (err) {
error_propagate(errp, err);
goto out;
}
- str = string_output_get_string(ov);
- iv = string_input_visitor_new(str);
- visit_type_uint16List(string_input_get_visitor(iv), NULL, list, errp);
+ visit_complete(v, &str);
+ visit_free(v);
+ v = string_input_visitor_new(str);
+ visit_type_uint16List(v, NULL, list, errp);
g_free(str);
- string_input_visitor_cleanup(iv);
out:
- string_output_visitor_cleanup(ov);
+ visit_free(v);
}
void object_property_parse(Object *obj, const char *string,
const char *name, Error **errp)
{
- StringInputVisitor *siv;
- siv = string_input_visitor_new(string);
- object_property_set(obj, string_input_get_visitor(siv), name, errp);
-
- string_input_visitor_cleanup(siv);
+ Visitor *v = string_input_visitor_new(string);
+ object_property_set(obj, v, name, errp);
+ visit_free(v);
}
char *object_property_print(Object *obj, const char *name, bool human,
Error **errp)
{
- StringOutputVisitor *sov;
+ Visitor *v;
char *string = NULL;
Error *local_err = NULL;
- sov = string_output_visitor_new(human);
- object_property_get(obj, string_output_get_visitor(sov), name, &local_err);
+ v = string_output_visitor_new(human, &string);
+ object_property_get(obj, v, name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
- string = string_output_get_string(sov);
+ visit_complete(v, &string);
out:
- string_output_visitor_cleanup(sov);
+ visit_free(v);
return string;
}
@@ -2044,7 +2038,7 @@ static void property_get_tm(Object *obj, Visitor *v, const char *name,
}
visit_check_struct(v, &err);
out_end:
- visit_end_struct(v);
+ visit_end_struct(v, NULL);
out:
error_propagate(errp, err);
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 51e62e29d6..bf598468ab 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -71,7 +71,7 @@ Object *user_creatable_add(const QDict *qdict,
obj = user_creatable_add_type(type, id, pdict, v, &local_err);
out_visit:
- visit_end_struct(v);
+ visit_end_struct(v, NULL);
out:
QDECREF(pdict);
@@ -127,7 +127,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
if (!local_err) {
visit_check_struct(v, &local_err);
}
- visit_end_struct(v);
+ visit_end_struct(v, NULL);
if (local_err) {
goto out;
}
@@ -156,15 +156,15 @@ out:
Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
{
- OptsVisitor *ov;
+ Visitor *v;
QDict *pdict;
Object *obj = NULL;
- ov = opts_visitor_new(opts);
+ v = opts_visitor_new(opts);
pdict = qemu_opts_to_qdict(opts, NULL);
- obj = user_creatable_add(pdict, opts_get_visitor(ov), errp);
- opts_visitor_cleanup(ov);
+ obj = user_creatable_add(pdict, v, errp);
+ visit_free(v);
QDECREF(pdict);
return obj;
}
diff --git a/qom/qom-qobject.c b/qom/qom-qobject.c
index b66088d730..c225abcbad 100644
--- a/qom/qom-qobject.c
+++ b/qom/qom-qobject.c
@@ -21,12 +21,11 @@
void object_property_set_qobject(Object *obj, QObject *value,
const char *name, Error **errp)
{
- QmpInputVisitor *qiv;
+ Visitor *v;
/* TODO: Should we reject, rather than ignore, excess input? */
- qiv = qmp_input_visitor_new(value, false);
- object_property_set(obj, qmp_input_get_visitor(qiv), name, errp);
-
- qmp_input_visitor_cleanup(qiv);
+ v = qmp_input_visitor_new(value, false);
+ object_property_set(obj, v, name, errp);
+ visit_free(v);
}
QObject *object_property_get_qobject(Object *obj, const char *name,
@@ -34,14 +33,14 @@ QObject *object_property_get_qobject(Object *obj, const char *name,
{
QObject *ret = NULL;
Error *local_err = NULL;
- QmpOutputVisitor *qov;
+ Visitor *v;
- qov = qmp_output_visitor_new();
- object_property_get(obj, qmp_output_get_visitor(qov), name, &local_err);
+ v = qmp_output_visitor_new(&ret);
+ object_property_get(obj, v, name, &local_err);
if (!local_err) {
- ret = qmp_output_get_qobject(qov);
+ visit_complete(v, &ret);
}
error_propagate(errp, local_err);
- qmp_output_visitor_cleanup(qov);
+ visit_free(v);
return ret;
}