Prerequisites: + my qapi cleanups subset E v8: https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03863.html
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 v2 notes: Fix bugs so that 'make check' and qemu-iotests pass at all points. Rebase on top of qapi cleanups subset E v8. Promote out of RFC. However, in this version, I'm still presenting two alternative solutions: either patch 8 (keep the qjson.h interface) or patches 10-11 (completely drop qjson.h, by inlining its contents but adding more glue in vmstate.c). Patch 9 is a revert to show that the two alternatives are orthogonal; the final series won't need a revert. I'd welcome opinions on which alternative to stick with. Backport diffstat (renames of 1 and 14 confuse the stats): 001/14:[down] 'qapi: Rename (one) qjson.h to qobject-json.h' 002/14:[----] [--] 'qapi: Improve use of qmp/types.h' 003/14:[----] [--] 'qapi: Factor out JSON string escaping' 004/14:[0002] [FC] 'qapi: Factor out JSON number formatting' 005/14:[----] [--] 'qapi: Use qstring_append_chr() where appropriate' 006/14:[0016] [FC] 'qapi: Add qstring_append_format()' 007/14:[0063] [FC] 'qapi: add json output visitor' 008/14:[0008] [FC] 'qjson: Simplify by using json-output-visitor' 009/14:[down] 'Revert "qjson: Simplify by using json-output-visitor"' 010/14:[down] 'vmstate: use new JSON output visitor' 011/14:[down] 'qjson: Remove unused file' 012/14:[----] [--] 'qapi: Add qobject_to_json_pretty_prefix()' 013/14:[0004] [FC] 'qapi: Support pretty printing in JSON output visitor' 014/14:[down] 'qemu-img: Use new JSON output formatter' v1 (RFC) notes: https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg01760.html Eric Blake (14): 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 MAINTAINERS | 2 +- Makefile.objs | 1 - 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/migration/vmstate.h | 4 +- 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 - include/qjson.h | 29 -- migration/savevm.c | 66 ++-- migration/vmstate.c | 63 ++-- monitor.c | 8 +- qapi/Makefile.objs | 2 +- qapi/json-output-visitor.c | 222 ++++++++++++ qapi/qmp-dispatch.c | 1 + qapi/qmp-event.c | 2 +- qemu-img.c | 69 ++-- qga/main.c | 2 +- qjson.c | 129 ------- qobject/Makefile.objs | 3 +- qobject/json-parser.c | 14 +- qobject/{qjson.c => qobject-json.c} | 147 ++------ qobject/qobject.c | 7 +- qobject/qstring.c | 117 ++++++- target-s390x/kvm.c | 2 +- tests/.gitignore | 3 +- tests/Makefile | 14 +- tests/{check-qjson.c => check-qobject-json.c} | 86 ++++- tests/libqtest.c | 2 +- tests/qemu-iotests/043.out | 22 +- tests/test-json-output-visitor.c | 482 ++++++++++++++++++++++++++ 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 +- 46 files changed, 1126 insertions(+), 439 deletions(-) create mode 100644 include/qapi/json-output-visitor.h rename include/qapi/qmp/{qjson.h => qobject-json.h} (90%) delete mode 100644 include/qjson.h create mode 100644 qapi/json-output-visitor.c delete mode 100644 qjson.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