qemu-e2k/qobject
Markus Armbruster 2860b2b2cb block: Fix -blockdev / blockdev-add for empty objects and arrays
-blockdev and blockdev-add silently ignore empty objects and arrays in
their argument.  That's because qmp_blockdev_add() converts the
argument to a flat QDict, and qdict_flatten() eats empty QDict and
QList members.  For instance, we ignore an empty BlockdevOptions
member @cache.  No real harm, as absent means the same as empty there.

Thus, the flaw puts an artificial restriction on the QAPI schema: we
can't have potentially empty objects and arrays within
BlockdevOptions, except when they're optional and "empty" has the same
meaning as "absent".

Our QAPI schema satisfies this restriction (I checked), but it's a
trap for the unwary, and a temptation to employ awkward workarounds
for the wary.  Let's get rid of it.

Change qdict_flatten() and qdict_crumple() to treat empty dictionaries
and lists exactly like scalars.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2018-06-15 14:49:44 +02:00
..
Makefile.objs qobject: Move block-specific qdict code to block-qdict.c 2018-06-15 14:49:44 +02:00
block-qdict.c block: Fix -blockdev / blockdev-add for empty objects and arrays 2018-06-15 14:49:44 +02:00
json-lexer.c json: learn to parse uint64 numbers 2017-06-20 14:31:31 +02:00
json-parser.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
json-streamer.c json-streamer: fix double-free on exiting during a parse 2016-07-12 18:31:27 +02:00
qbool.c qapi: Remove qobject_to_X() functions 2018-03-19 14:58:36 -05:00
qdict.c qobject: Move block-specific qdict code to block-qdict.c 2018-06-15 14:49:44 +02:00
qjson.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
qlist.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
qlit.c qapi: Replace qobject_to_X(o) by qobject_to(X, o) 2018-03-19 14:58:36 -05:00
qnull.c qapi: Add qobject_is_equal() 2017-11-17 18:21:30 +01:00
qnum.c qapi: Remove qobject_to_X() functions 2018-03-19 14:58:36 -05:00
qobject.c qobject: use a QObjectBase_ struct 2018-05-04 08:27:53 +02:00
qstring.c qobject: introduce qobject_get_try_str() 2018-03-19 14:58:36 -05:00