Followup series to conversation about PRId64 and MacOS: https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg04226.html
We have relatively few users of dynamic JSON (the ability to pass varargs plus a format string with % sequences embedded in the JSON, to create a final QObject dynamically). Most of them live in the testsuite. Converting ALL uses to hand-written QObjects would have been too invasive, so I hope this series hits a nice compromise of adjusting the few users that injected non-strings, while moving the work of string injection out of the JSON parser proper and instead into libqtest. Doing this means the testsuite is doing a lot fewer string->QObject->string round-trips when computing what to send over a QMP wire transaction. I'm also pleased that this series has a net overall reduction in lines of code, while still adding several new useful features (such as qdict_put_str() in 2/36, QAPI_TO_QOBJECT() in 11/36, qmp_cmd() in 9/36) and fixing a couple of testsuite flaws (7/36, 8/36). Patch 2/36 may be a candidate for splitting into sub-patches, but the series is already long enough that I wanted to post it for feedback on the approaches taken here. Partially overlaps with my earlier v6 posting of a qapi JSON visitor (https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg01915.html); whichever series goes in first has two patches that the other series will use as-is (28/36, 29/36). Eric Blake (36): pci: Use struct instead of QDict to pass back parameters qdict: Add convenience helpers for wrapped puts qlist: Add convenience helpers for wrapped appends qmp-event: Avoid dynamic JSON qmp-dispatch: Avoid dynamic JSON qobject-input-visitor: Avoid dynamic JSON in tests fdc-test: Avoid deprecated 'change' command test-qga: Actually test 0xff sync bytes qtest: Add a new helper qmp_cmd() and friends qtest: Avoid dynamic JSON in libqtest qapi: Add QAPI_TO_QOBJECT() convenience macro nbd: Use simpler QAPI_TO_QOBJECT() nfs: Use simpler QAPI_TO_QOBJECT() qapi: Use simpler QAPI_TO_QOBJECT() blockdev: Use simpler QAPI_TO_QOBJECT() qapi: Promote blockdev-change-medium arguments to QAPI type qtest: Avoid dynamic JSON in ahci-test qtest: Avoid dynamic JSON in fdc-test qtest: Change qmp_discard_response() to drop varargs qtest: Avoid dynamic JSON in device-introspect-test qtest: Avoid dynamic JSON in tmp105-test qtest: Avoid dynamic JSON in pc-cpu-test qtest: Avoid dynamic JSON in virtio-blk-test qtest: Drop unused qmp_fdv() qtest: Change qmp_fd_send() to drop varags qtest: Drop unused qtest_qmp_async() qtest: Avoid dynamic JSON in qmp_cmd() qapi: Factor out JSON string escaping qapi: Add qstring_append_printf() qtest: Avoid dynamic JSON in qmp_fd_sendv() qtest: Document calling conventions qtest: Avoid dynamic JSON in qom-test qtest: Avoid dynamic JSON in test-x86-cpuid-compat qapi: Rip out dynamic JSON parser frontend qapi: Rip out dynamic JSON parser escape sequence support qapi: Rip out dynamic JSON parser backend qapi/block-core.json | 11 ++- include/qapi/qmp/json-lexer.h | 1 - include/qapi/qmp/json-parser.h | 6 +- include/qapi/qmp/qdict.h | 8 ++ include/qapi/qmp/qjson.h | 4 +- include/qapi/qmp/qlist.h | 8 ++ include/qapi/qmp/qstring.h | 7 +- include/qapi/qobject-output-visitor.h | 19 ++++ tests/libqtest.h | 78 +++++++-------- block.c | 59 +++++------- block/archipelago.c | 4 +- block/blkdebug.c | 6 +- block/blkverify.c | 11 +-- block/curl.c | 2 +- block/iscsi.c | 2 +- block/nbd.c | 47 ++++----- block/nfs.c | 49 ++++------ block/null.c | 2 +- block/qapi.c | 6 +- block/qcow2.c | 4 +- block/quorum.c | 13 +-- block/raw-posix.c | 8 +- block/raw-win32.c | 4 +- block/ssh.c | 16 ++- block/vvfat.c | 10 +- blockdev.c | 42 +++----- hw/block/xen_disk.c | 2 +- hw/pci/pcie_aer.c | 36 ++++--- hw/usb/xen-usb.c | 12 +-- migration/qjson.c | 12 +-- monitor.c | 30 +++--- qapi/qmp-dispatch.c | 8 +- qapi/qmp-event.c | 15 +-- qapi/qobject-output-visitor.c | 16 +++ qemu-img.c | 6 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- qga/main.c | 2 +- qobject/json-lexer.c | 40 -------- qobject/json-parser.c | 66 ++++--------- qobject/qdict.c | 2 +- qobject/qjson.c | 177 ++++++++++++++-------------------- qobject/qstring.c | 26 ++++- target-s390x/cpu_models.c | 4 +- tests/ahci-test.c | 26 ++++- tests/check-qdict.c | 142 +++++++++++++-------------- tests/check-qjson.c | 113 +--------------------- tests/check-qlist.c | 2 +- tests/device-introspect-test.c | 15 +-- tests/fdc-test.c | 15 ++- tests/libqtest.c | 147 ++++++++++++++-------------- tests/pc-cpu-test.c | 12 ++- tests/qom-test.c | 15 +-- tests/test-qga.c | 12 ++- tests/test-qmp-commands.c | 30 +++--- tests/test-qmp-event.c | 30 +++--- tests/test-qobject-input-strict.c | 37 +------ tests/test-qobject-input-visitor.c | 75 ++++++-------- tests/test-qobject-output-visitor.c | 6 +- tests/test-x86-cpuid-compat.c | 14 ++- tests/tmp105-test.c | 7 +- tests/virtio-blk-test.c | 22 +++-- util/qemu-option.c | 6 +- 63 files changed, 726 insertions(+), 885 deletions(-) -- 2.7.4