This is an update of the bits of this previous series which were not merged
https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg01723.html The problem addressed in this series is that the 'qemu-img info' command does not have a stable output format for the image specific info objects. The QAPI types are first converted to QDicts, and then printed with custom code to recurse over the QDicts. This causes information about the object field ordering to be thrown away, and fields are printed in whatever order they appear in the QDict hash buckets. This is not a big deal historically since none of the image formats had nested data structures, but with the LUKS blockdev this style of random ordering looks very unpleasant. To address this, the patch series introduces a TextOutputVisitor class that is designed to be able to print out arbitrarily nested QAPI types directly, in a format that is identical to that currently used with 'qemu-img info'. Consult the patch in question to actually see the output format, and compare test-string-output-visitor.c with test-text-output-visitor.c to see how we really do have 2 completely distinct output formats that don't share any significant characteristics beyond both being "plain text". Changed in v2: - Pulled code for printing sized value out into the cutils file via qemu_sztostr* methods - Added unit test for text output visitor - Convert block code to use qemu_sztostr* methods - Convert string output visitor code to use qemu_sztostr* methods - Document the string output visitor format against its constructor - Document the text otput visitor format against its constructor. - Adjustments to block i/o tests to take account of stable field ordering - Adjustments to block i/o tests to take account of simpified size format when ending in a .0 Daniel P. Berrange (6): cutils: add helpers for formatting sized values qapi: convert StringOutputVisitor to use qemu_szutostr qapi: assert that visitor impls have required callbacks qapi: add a text output visitor for pretty printing types block: convert to use the qemu_szutostr functions block: convert to use qapi_stringify_ImageInfoSpecific block/qapi.c | 163 +++------------- include/qapi/string-output-visitor.h | 28 ++- include/qapi/text-output-visitor.h | 77 ++++++++ include/qemu/cutils.h | 12 ++ qapi/Makefile.objs | 1 + qapi/qapi-visit-core.c | 15 ++ qapi/string-output-visitor.c | 20 +- qapi/text-output-visitor.c | 349 +++++++++++++++++++++++++++++++++ tests/Makefile.include | 5 +- tests/qemu-iotests/095.out | 2 +- tests/qemu-iotests/104.out | 2 +- tests/test-cutils.c | 96 +++++++++ tests/test-string-output-visitor.c | 22 +++ tests/test-text-output-visitor.c | 366 +++++++++++++++++++++++++++++++++++ util/cutils.c | 78 ++++++++ 15 files changed, 1079 insertions(+), 157 deletions(-) create mode 100644 include/qapi/text-output-visitor.h create mode 100644 qapi/text-output-visitor.c create mode 100644 tests/test-text-output-visitor.c -- 2.7.4