Now human monitor can show image details include internal snapshot info for every block device.
Signed-off-by: Wenchao Xia <xiaw...@linux.vnet.ibm.com> --- hmp.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/hmp.c b/hmp.c index c475d65..49f851b 100644 --- a/hmp.c +++ b/hmp.c @@ -22,6 +22,7 @@ #include "qemu/sockets.h" #include "monitor/monitor.h" #include "ui/console.h" +#include "block/qapi.h" static void hmp_handle_error(Monitor *mon, Error **errp) { @@ -272,9 +273,12 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict) qapi_free_CpuInfoList(cpu_list); } +#define IMAGE_INFO_BUF_SIZE (2048) void hmp_info_block(Monitor *mon, const QDict *qdict) { BlockInfoList *block_list, *info; + ImageInfo *image_info; + char *buf = NULL; block_list = qmp_query_block(NULL); @@ -316,6 +320,22 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) info->value->inserted->iops, info->value->inserted->iops_rd, info->value->inserted->iops_wr); + + if (!buf) { + buf = g_malloc0(IMAGE_INFO_BUF_SIZE); + } + monitor_printf(mon, " images:\n"); + image_info = info->value->inserted->image; + while (1) { + bdrv_image_info_dump(buf, IMAGE_INFO_BUF_SIZE, image_info); + monitor_printf(mon, "%s", buf); + if (image_info->has_backing_image) { + image_info = image_info->backing_image; + } else { + break; + } + } + } else { monitor_printf(mon, " [not inserted]"); } @@ -323,6 +343,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) monitor_printf(mon, "\n"); } + g_free(buf); qapi_free_BlockInfoList(block_list); } -- 1.7.1