I wrote this series for several reasons: 1. I've been doing a lot of churn in the qapi visitor interfaces lately; adding a new visitor is good proof whether the changes still make sense 2. Alexander ended up writing his own simple JSON generator as qjson.c in his work for vmstate self-description, rather than reusing existing code, because the QObject JSON generator does not have an easy entry point 3. Fam commented while trying to enhance 'qemu-img map' that we are rather wasteful in that there is no way to go directly from a qapi type to JSON without an intermediate QObject creation
RFC because it conflicts with other pending qemu-img patches: https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg01756.html and because I still have testsuite failures in qemu-iotests that must be addressed before the series can be applied (some output reordering occurs, but it also flushed out some clients that are abusing qapi visits by expecting NULL to turn into ""). Posting now to at least get feedback on whether the ideas make sense. Pending prerequisites: + Markus' qapi-not-next branch (including my qapi subset D patches): http://repo.or.cz/qemu/armbru.git/shortlog/refs/heads/qapi-not-next https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg00463.html + v8 or later of my qapi subset E patches (at the time of this mail, only v7 has been posted): https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg01181.html Also available as a tag at this location (with prerequisites applied): git fetch git://repo.or.cz/qemu/ericb.git qapi-jsonv1 Eric Blake (11): qapi: Rename qjson.h to qobject-json.h qapi: Improve use of qmp/types.h qapi: Factor out JSON string escaping qapi: Factor out JSON number formatting qapi: Use qstring_append_chr() where appropriate qapi: Add qstring_append_format() qapi: add json output visitor qjson: Simplify by using json-output-visitor qapi: Add qobject_to_json_pretty_prefix() qapi: Support pretty printing in JSON output visitor RFC: qemu-img: Use new JSON output formatter MAINTAINERS | 2 +- balloon.c | 2 +- block.c | 2 +- block/archipelago.c | 2 +- block/nbd.c | 2 +- block/quorum.c | 2 +- blockjob.c | 2 +- hw/core/qdev.c | 2 +- hw/misc/pvpanic.c | 2 +- hw/net/virtio-net.c | 2 +- hw/pci/pcie_aer.c | 1 + include/qapi/json-output-visitor.h | 25 ++ include/qapi/qmp/{qjson.h => qobject-json.h} | 1 + include/qapi/qmp/qstring.h | 12 +- include/qapi/qmp/types.h | 1 - monitor.c | 8 +- qapi/Makefile.objs | 2 +- qapi/json-output-visitor.c | 221 ++++++++++++ qapi/qmp-dispatch.c | 1 + qapi/qmp-event.c | 2 +- qemu-img.c | 70 ++-- qga/main.c | 2 +- qjson.c | 64 ++-- qobject/Makefile.objs | 3 +- qobject/json-parser.c | 14 +- qobject/{qjson.c => qobject-json.c} | 147 ++------ qobject/qobject.c | 7 +- qobject/qstring.c | 119 ++++++- target-s390x/kvm.c | 2 +- tests/.gitignore | 3 +- tests/Makefile | 12 +- tests/{check-qjson.c => check-qobject-json.c} | 86 ++++- tests/libqtest.c | 2 +- tests/test-json-output-visitor.c | 474 ++++++++++++++++++++++++++ tests/test-qmp-input-strict.c | 1 + tests/test-qmp-input-visitor.c | 1 + tests/test-qmp-output-visitor.c | 1 + tests/test-visitor-serialization.c | 1 + ui/spice-core.c | 2 +- vl.c | 2 +- 40 files changed, 1046 insertions(+), 261 deletions(-) create mode 100644 include/qapi/json-output-visitor.h rename include/qapi/qmp/{qjson.h => qobject-json.h} (90%) create mode 100644 qapi/json-output-visitor.c rename qobject/{qjson.c => qobject-json.c} (50%) rename tests/{check-qjson.c => check-qobject-json.c} (95%) create mode 100644 tests/test-json-output-visitor.c -- 2.4.3