Prerequisites: + my qapi cleanups subset E v16: https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg04397.html
Note that the series has a mutually exclusive choice: either patch 8, or patches 10-11. I still haven't gotten any feedback on which choice seems nicer. I wrote this series for several reasons: 1. I've been doing a lot of churn in the qapi visitor interfaces lately; adding two new visitors 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 4. Doing QAPI cloning by round-tripping into and back out of QObject is wasteful v2 was here (yes, really 4 months ago): https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03929.html Since then, I've added the clone visitor, and retitled a couple of patches (so backport-diff gets a bit confused): 001/18:[0004] [FC] 'qapi: Rename (one) qjson.h to qobject-json.h' 002/18:[----] [-C] 'qapi: Improve use of qmp/types.h' 003/18:[0002] [FC] 'qapi: Factor out JSON string escaping' 004/18:[0022] [FC] 'qapi: Factor out JSON number formatting' 005/18:[----] [--] 'qapi: Use qstring_append_chr() where appropriate' 006/18:[0004] [FC] 'qapi: Add qstring_append_format()' 007/18:[down] 'qapi: Add json output visitor' 008/18:[0002] [FC] 'qjson: Simplify by using json-output-visitor' 009/18:[0002] [FC] 'Revert "qjson: Simplify by using json-output-visitor"' 010/18:[down] 'vmstate: Use new JSON output visitor' 011/18:[0002] [FC] 'qjson: Remove unused file' 012/18:[----] [--] 'qapi: Add qobject_to_json_pretty_prefix()' 013/18:[0006] [FC] 'qapi: Support pretty printing in JSON output visitor' 014/18:[0002] [FC] 'qemu-img: Use new JSON output formatter' 015/18:[down] 'qapi: Add new clone visitor' 016/18:[down] 'sockets: Use new QAPI cloning' 017/18:[down] 'replay: Use new QAPI cloning' 018/18:[down] 'qapi: Add parameter to visit_end_*' Eric Blake (18): qapi: Rename (one) 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 Revert "qjson: Simplify by using json-output-visitor" vmstate: Use new JSON output visitor qjson: Remove unused file qapi: Add qobject_to_json_pretty_prefix() qapi: Support pretty printing in JSON output visitor qemu-img: Use new JSON output formatter qapi: Add new clone visitor sockets: Use new QAPI cloning replay: Use new QAPI cloning qapi: Add parameter to visit_end_* include/qapi/visitor.h | 71 ++-- include/qapi/visitor-impl.h | 7 +- scripts/qapi-commands.py | 4 +- scripts/qapi-event.py | 2 +- scripts/qapi-types.py | 42 +++ scripts/qapi-visit.py | 8 +- include/migration/vmstate.h | 4 +- include/qapi/clone-visitor.h | 28 ++ include/qapi/json-output-visitor.h | 29 ++ include/qapi/qmp/{qjson.h => qobject-json.h} | 1 + include/qapi/qmp/qstring.h | 10 +- include/qapi/qmp/types.h | 1 - include/qjson.h | 29 -- qapi/qapi-visit-core.c | 13 +- balloon.c | 2 +- block.c | 2 +- block/archipelago.c | 2 +- block/crypto.c | 4 +- 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 + hw/ppc/spapr_drc.c | 4 +- hw/virtio/virtio-balloon.c | 4 +- migration/savevm.c | 68 ++-- migration/vmstate.c | 64 ++-- monitor.c | 8 +- qapi/json-output-visitor.c | 221 ++++++++++++ qapi/opts-visitor.c | 4 +- qapi/qapi-clone-visitor.c | 165 +++++++++ qapi/qapi-dealloc-visitor.c | 47 +-- qapi/qmp-dispatch.c | 1 + qapi/qmp-event.c | 2 +- qapi/qmp-input-visitor.c | 2 +- qapi/qmp-output-visitor.c | 4 +- qapi/string-input-visitor.c | 2 +- qapi/string-output-visitor.c | 2 +- qemu-img.c | 69 ++-- qga/main.c | 2 +- qjson.c | 129 ------- qobject/json-parser.c | 14 +- qobject/qjson.c | 296 ---------------- qobject/qobject-json.c | 219 ++++++++++++ qobject/qobject.c | 7 +- qobject/qstring.c | 123 ++++++- qom/object.c | 2 +- qom/object_interfaces.c | 4 +- replay/replay-input.c | 30 +- target-s390x/kvm.c | 2 +- tests/{check-qjson.c => check-qobject-json.c} | 86 ++++- tests/libqtest.c | 2 +- tests/test-clone-visitor.c | 239 +++++++++++++ tests/test-json-output-visitor.c | 482 ++++++++++++++++++++++++++ tests/test-qmp-input-strict.c | 1 + tests/test-qmp-input-visitor.c | 3 +- tests/test-qmp-output-visitor.c | 3 +- tests/test-visitor-serialization.c | 1 + ui/spice-core.c | 2 +- util/qemu-sockets.c | 22 +- vl.c | 2 +- MAINTAINERS | 2 +- Makefile.objs | 1 - docs/qapi-code-gen.txt | 42 ++- qapi/Makefile.objs | 2 +- qobject/Makefile.objs | 3 +- tests/.gitignore | 4 +- tests/Makefile | 17 +- tests/qemu-iotests/043.out | 22 +- 71 files changed, 1917 insertions(+), 786 deletions(-) create mode 100644 include/qapi/clone-visitor.h create mode 100644 include/qapi/json-output-visitor.h rename include/qapi/qmp/{qjson.h => qobject-json.h} (89%) delete mode 100644 include/qjson.h create mode 100644 qapi/json-output-visitor.c create mode 100644 qapi/qapi-clone-visitor.c delete mode 100644 qjson.c delete mode 100644 qobject/qjson.c create mode 100644 qobject/qobject-json.c rename tests/{check-qjson.c => check-qobject-json.c} (95%) create mode 100644 tests/test-clone-visitor.c create mode 100644 tests/test-json-output-visitor.c -- 2.5.5