This serial of patches does two things: merge some info code in qemu-img, and add following interfaces: 1) qmp: query-images 2) qmp: query-snapshots 3) hmp: show internal snapshot info on a single block device These patches follows the rule that use qmp to retieve information, hmp layer just do a translation from qmp object it got, so almost every hmp interface may have a correlated qmp interface. To make code graceful, snapshot retrieving code in qemu and qemu-img are merged into block.c, and some function name was adjusted to make it tips better. Now it works as:
qemu qemu-img dump_monitor dump_stdout |--------------| | qmp | block Note: Last three patches need previous sent patches which extend hmp sub command: http://lists.nongnu.org/archive/html/qemu-devel/2013-01/msg02109.html v2: Rename and adjusted qmp interface according to comments from Eric. Spelling fix. Information retrieving function in block layer goes to seperated patch. Free qmp object after usage in hmp. Added counterpart in qmp-commands.hx. Better tips in qmp-schema.json. v3: Spelling fix in commit message, patch 03/11. Spelling fix in code, patch 06/11. Add comments that vm-state-size is in bytes, and change size of it in example to a reasonable number, patch 08/11. v4: 02/13: in bdrv_get_filename(), add const to parameter *bs. 03/13: new added, in which the function correct the behavior in info retrieving. 04/13: in bdrv_query_snapshot_infolist(), remove NULL check before call err_setg(), added TODO comments that let block layer function set error instead of this layer to tip better for errors, Split out patch about image info to patch 05/13. 05/13: new splitted, and it checks *bs by calling bdrv_can_read_snapshot() before collect internal snasphot info to avoid *err is set unexpectly now. 06/13: check if error happens after calling bdrv_query_image_info(). 08/13: rename info to image in DeviceImageInfo and make it optional, when device is not inserted it will be empty, added error handling code when met error in calling block layer API. 09/13: distinguish *id and *name in bdrv_find_snapshots(), caller can choose what to search with. id_wellformed() should be called in new snapshot creation interface above this function in the future. 10/13: now this interface have addtional parameter *device, which enable showing internal snapshots on a single device. Also use bdrv_can_read_snapshot() instead of bdrv_can_snapshot() now. 11/13: this function goes to hmp.c so hmp_handler_error is not exported any more, split out patch that switch snapshot info function to patch 12/13. 12/13: new splitted. 13/13: use qmp API instead of directly calling block layer API, now all hmp function have correspond qmp funtion in this serial. v5: 04/13: spelling fix in commit message, better comments and better tips of error, after calling bdrv_snapshot_list(). Wenchao Xia (13): 1 qemu-img: remove unused parameter in collect_image_info() 2 block: add bdrv_get_filename() function 3 block: add bdrv_can_read_snapshot() function 4 block: add snapshot info query function bdrv_query_snapshot_infolist() 5 block: add image info query function bdrv_query_image_info() 6 qemu-img: switch image retrieving function 7 block: rename bdrv_query_info to bdrv_query_block_info 8 qmp: add interface query-images. 9 block: export function bdrv_find_snapshot() 10 qmp: add interface query-snapshots 11 hmp: add function hmp_info_snapshots() 12 hmp: switch snapshot info function to qmp based one 13 hmp: show snapshots on single block device block.c | 288 ++++++++++++++++++++++++++++++++++++++++++++++++- hmp.c | 47 ++++++++ hmp.h | 1 + include/block/block.h | 14 +++- monitor.c | 8 +- qapi-schema.json | 46 ++++++++ qemu-img.c | 91 +--------------- qmp-commands.hx | 129 ++++++++++++++++++++++ savevm.c | 94 +--------------- 9 files changed, 536 insertions(+), 182 deletions(-)