qmp: Tighten output visitor rules
commit56a6f02b8ce1fe41a2a9077593e46eca7d98267d
authorEric Blake <eblake@redhat.com>
Thu, 28 Apr 2016 21:45:26 +0000 (28 15:45 -0600)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 12 May 2016 07:47:55 +0000 (12 09:47 +0200)
tree8071e53eba8577e41476d4f2f4b7e082862ab51c
parentf2ff429bfa713da1366333417fecfa939a709cf1
qmp: Tighten output visitor rules

Tighten assertions in the QMP output visitor, so that:

- qmp_output_get_qobject() can only be called after pairing a
visit_end_* for every visit_start_* (rather than allowing it on
a partially built object)

- qmp_output_get_qobject() cannot be called unless at least one
visit_type_* or visit_start/visit_end pair has occurred since
creation/reset (the accidental return of NULL fixed by commit
ab8bf1d7 would have been much easier to diagnose)

- ensure that we are encountering the expected object or list
type, to provide protection against mismatched push(struct)/
pop(list) or push(list)/pop(struct), similar to the qmp-input
protection added in commit bdd8e6b5.

- ensure that except for the root, 'name' is non-null inside a
dict, and NULL inside a list (this may need changing later if
we add "name.0" support for better error messages for a list,
but for now it makes sure all users are at least consistent)

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1461879932-9020-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
qapi/qmp-output-visitor.c