From 43526ec8d1395fe4efbed15e9764b64641b95bcc Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Thu, 6 Jun 2013 12:27:58 +0800 Subject: block: add image info query function bdrv_query_image_info() This patch adds function bdrv_query_image_info(), which will retrieve image info in qmp object format. The implementation is based on the code moved from qemu-img.c, but uses block layer function to get snapshot info. Signed-off-by: Wenchao Xia Signed-off-by: Stefan Hajnoczi --- qemu-img.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'qemu-img.c') diff --git a/qemu-img.c b/qemu-img.c index e3d8fe3c77..809b4f1c00 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1644,6 +1644,7 @@ static ImageInfoList *collect_image_info_list(const char *filename, ImageInfoList *head = NULL; ImageInfoList **last = &head; GHashTable *filenames; + Error *err = NULL; filenames = g_hash_table_new_full(g_str_hash, str_equal_func, NULL, NULL); @@ -1665,11 +1666,11 @@ static ImageInfoList *collect_image_info_list(const char *filename, goto err; } - info = g_new0(ImageInfo, 1); - bdrv_collect_image_info(bs, info, filename); - bdrv_query_snapshot_info_list(bs, &info->snapshots, NULL); - if (info->snapshots) { - info->has_snapshots = true; + bdrv_query_image_info(bs, &info, &err); + if (error_is_set(&err)) { + error_report("%s", error_get_pretty(err)); + error_free(err); + goto err; } elem = g_new0(ImageInfoList, 1); -- cgit v1.2.3