diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2017-05-09 15:49:08 -0400 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-05-09 15:49:14 -0400 |
commit | 76d20ea0f1b26ebd5da2f5fb2fdf3250cde887bb (patch) | |
tree | bcb0e4a8f29bdcfa0f5785a09608bff57a82107c /qapi/qobject-input-visitor.c | |
parent | 7ed57b66221b5a3e23b3519824637b297dc92090 (diff) | |
parent | dcd3b25d656d346205dc0f2254723fccf0264e45 (diff) | |
download | qemu-76d20ea0f1b26ebd5da2f5fb2fdf3250cde887bb.zip qemu-76d20ea0f1b26ebd5da2f5fb2fdf3250cde887bb.tar.gz qemu-76d20ea0f1b26ebd5da2f5fb2fdf3250cde887bb.tar.bz2 |
Merge remote-tracking branch 'armbru/tags/pull-qapi-2017-05-04-v3' into staging
QAPI patches for 2017-05-04
# gpg: Signature made Tue 09 May 2017 03:16:12 AM EDT
# 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
* armbru/tags/pull-qapi-2017-05-04-v3: (28 commits)
qmp-shell: improve help
qmp-shell: don't show version greeting if unavailable
qmp-shell: Cope with query-commands error
qmp-shell: add -N option to skip negotiate
qmp-shell: add persistent command history
qobject-input-visitor: Catch misuse of end_struct vs. end_list
qapi: Document intended use of @name within alternate visits
qobject-input-visitor: Document full_name_nth()
qmp: Improve QMP dispatch error messages
sockets: Delete unused helper socket_address_crumple()
sockets: Limit SocketAddressLegacy to external interfaces
sockets: Rename SocketAddressFlat to SocketAddress
sockets: Rename SocketAddress to SocketAddressLegacy
qapi: New QAPI_CLONE_MEMBERS()
sockets: Prepare inet_parse() for flattened SocketAddress
sockets: Prepare vsock_parse() for flattened SocketAddress
test-qga: Actually test 0xff sync bytes
fdc-test: Avoid deprecated 'change' command
QemuOpts: Simplify qemu_opts_to_qdict()
block: Simplify bdrv_append_temp_snapshot() logic
...
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'qapi/qobject-input-visitor.c')
-rw-r--r-- | qapi/qobject-input-visitor.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 865e948..d0f0002 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -55,6 +55,17 @@ static QObjectInputVisitor *to_qiv(Visitor *v) return container_of(v, QObjectInputVisitor, visitor); } +/* + * Find the full name of something @qiv is currently visiting. + * @qiv is visiting something named @name in the stack of containers + * @qiv->stack. + * If @n is zero, return its full name. + * If @n is positive, return the full name of the @n-th container + * counting from the top. The stack of containers must have at least + * @n elements. + * The returned string is valid until the next full_name_nth(@v) or + * destruction of @v. + */ static const char *full_name_nth(QObjectInputVisitor *qiv, const char *name, int n) { @@ -280,6 +291,15 @@ static void qobject_input_start_struct(Visitor *v, const char *name, void **obj, } } +static void qobject_input_end_struct(Visitor *v, void **obj) +{ + QObjectInputVisitor *qiv = to_qiv(v); + StackObject *tos = QSLIST_FIRST(&qiv->stack); + + assert(qobject_type(tos->obj) == QTYPE_QDICT && tos->h); + qobject_input_pop(v, obj); +} + static void qobject_input_start_list(Visitor *v, const char *name, GenericList **list, size_t size, @@ -335,6 +355,14 @@ static void qobject_input_check_list(Visitor *v, Error **errp) } } +static void qobject_input_end_list(Visitor *v, void **obj) +{ + QObjectInputVisitor *qiv = to_qiv(v); + StackObject *tos = QSLIST_FIRST(&qiv->stack); + + assert(qobject_type(tos->obj) == QTYPE_QLIST && !tos->h); + qobject_input_pop(v, obj); +} static void qobject_input_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, size_t size, @@ -634,11 +662,11 @@ static QObjectInputVisitor *qobject_input_visitor_base_new(QObject *obj) v->visitor.type = VISITOR_INPUT; v->visitor.start_struct = qobject_input_start_struct; v->visitor.check_struct = qobject_input_check_struct; - v->visitor.end_struct = qobject_input_pop; + v->visitor.end_struct = qobject_input_end_struct; v->visitor.start_list = qobject_input_start_list; v->visitor.next_list = qobject_input_next_list; v->visitor.check_list = qobject_input_check_list; - v->visitor.end_list = qobject_input_pop; + v->visitor.end_list = qobject_input_end_list; v->visitor.start_alternate = qobject_input_start_alternate; v->visitor.optional = qobject_input_optional; v->visitor.free = qobject_input_free; |