This patchset add a JSON output mode to the qemu-img info command. It's a rewrite from scratch of the original patchset by Wenchao Xia following Anthony Liguori advices on JSON formating.
the --output=(json|human) option is now mandatory on the command line. Benoît Canet (3): qapi: Add SnapshotInfo. qapi: Add ImageInfo. qemu-img: Add json output option to the info command. in v2: eblake: make some field optionals squash the two qapi patchs together fix a typo on vm_clock_nsec bcanet: fix a potential memory leak in v3: lcapitulino: remove unneeded test put '\n' at the end of json in printf statement drop the uneeded head pointer in collect_snapshots in v4: Wenchao Xia && Kevin Wolf: -Refactor to separate rate ImageInfo collection from human printing. Kevin Wolf: -Use --output=(json|human). -make the two choice exclusive and print a message if none is specified. -cosmetic '=' alignement in collect snapshots. Benoît Canet: -add full-backing-filename to the ImageInfo structure (needed for human printing) -make ImageInfo->actual_size optional depending on the context. in v5: Eric Blake: -use a constant for getopt parsing to avoid future short options collision. -make the command default to --output=human. -fix spurious whitespace change. -split vm-clock-nsec in two fields vm-clock-sec and vm-clock-nsec. -declare JSON structure as "Since 1.3" in v6: Blue Swirl: -Add missing const in getopt structure declaration. Eric Blake: -Remove spurious undef. -Use an enum instead of two boolean. in v7: Kevin Wolf: -Add missing documentation. -Change bogus comment about chained lists support in qapi. -Remove collect_backing_file_format and use bs->backing_format instead. -Remove uneeded if. -Change bogus printing logic for backing file format. -Rename Format enum to OutputFormat. -Use OFORMAT_HUMAN by default and get rid of uneeded else branch -Use error_report insted of fprintf. -Use a switch instead of ifs. Benoît Canet: Rename FORMAT_HUMAN and FORMAT_JSON to OFORMAT_JSON and OFORMAT_HUMAN Benoît Canet (2): qapi: Add SnapshotInfo and ImageInfo. qemu-img: Add json output option to the info command. Makefile | 3 +- qapi-schema.json | 64 +++++++++++++++ qemu-img-cmds.hx | 4 +- qemu-img.c | 232 +++++++++++++++++++++++++++++++++++++++++++----------- qemu-img.texi | 5 +- 5 files changed, 259 insertions(+), 49 deletions(-) -- 1.7.9.5