mirror of
https://github.com/mii443/qemu.git
synced 2025-12-09 05:58:32 +00:00
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 <xiawenc@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
committed by
Stefan Hajnoczi
parent
fb0ed4539c
commit
43526ec8d1
11
qemu-img.c
11
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);
|
||||
|
||||
Reference in New Issue
Block a user