[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V10 14/17] block: move dump_human_image_info() to bl
From: |
Wenchao Xia |
Subject: |
[Qemu-devel] [PATCH V10 14/17] block: move dump_human_image_info() to block/qapi.c |
Date: |
Fri, 22 Mar 2013 22:19:10 +0800 |
This function is needed later in hmp command, it is also renamed to
bdrv_image_info_dump().
Signed-off-by: Wenchao Xia <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/qapi.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++
include/block/qapi.h | 1 +
qemu-img.c | 69 +-------------------------------------------------
3 files changed, 69 insertions(+), 68 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index 9051947..477659a 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -325,3 +325,70 @@ BlockInfoList *qmp_query_block(Error **errp)
qapi_free_BlockInfoList(head);
return NULL;
}
+
+void bdrv_image_info_dump(ImageInfo *info)
+{
+ char size_buf[128], dsize_buf[128];
+ if (!info->has_actual_size) {
+ snprintf(dsize_buf, sizeof(dsize_buf), "unavailable");
+ } else {
+ get_human_readable_size(dsize_buf, sizeof(dsize_buf),
+ info->actual_size);
+ }
+ get_human_readable_size(size_buf, sizeof(size_buf), info->virtual_size);
+ printf("image: %s\n"
+ "file format: %s\n"
+ "virtual size: %s (%" PRId64 " bytes)\n"
+ "disk size: %s\n",
+ info->filename, info->format, size_buf,
+ info->virtual_size,
+ dsize_buf);
+
+ if (info->has_encrypted && info->encrypted) {
+ printf("encrypted: yes\n");
+ }
+
+ if (info->has_cluster_size) {
+ printf("cluster_size: %" PRId64 "\n", info->cluster_size);
+ }
+
+ if (info->has_dirty_flag && info->dirty_flag) {
+ printf("cleanly shut down: no\n");
+ }
+
+ if (info->has_backing_filename) {
+ printf("backing file: %s", info->backing_filename);
+ if (info->has_full_backing_filename) {
+ printf(" (actual path: %s)", info->full_backing_filename);
+ }
+ putchar('\n');
+ if (info->has_backing_filename_format) {
+ printf("backing file format: %s\n", info->backing_filename_format);
+ }
+ }
+
+ if (info->has_snapshots) {
+ SnapshotInfoList *elem;
+ char buf[256];
+
+ printf("Snapshot list:\n");
+ printf("%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL));
+
+ /* Ideally bdrv_snapshot_dump() would operate on SnapshotInfoList but
+ * we convert to the block layer's native QEMUSnapshotInfo for now.
+ */
+ for (elem = info->snapshots; elem; elem = elem->next) {
+ QEMUSnapshotInfo sn = {
+ .vm_state_size = elem->value->vm_state_size,
+ .date_sec = elem->value->date_sec,
+ .date_nsec = elem->value->date_nsec,
+ .vm_clock_nsec = elem->value->vm_clock_sec * 1000000000ULL +
+ elem->value->vm_clock_nsec,
+ };
+
+ pstrcpy(sn.id_str, sizeof(sn.id_str), elem->value->id);
+ pstrcpy(sn.name, sizeof(sn.name), elem->value->name);
+ printf("%s\n", bdrv_snapshot_dump(buf, sizeof(buf), &sn));
+ }
+ }
+}
diff --git a/include/block/qapi.h b/include/block/qapi.h
index 49f9a17..5b2762c 100644
--- a/include/block/qapi.h
+++ b/include/block/qapi.h
@@ -38,4 +38,5 @@ int bdrv_query_image_info(BlockDriverState *bs,
int bdrv_query_info(BlockDriverState *bs,
BlockInfo **p_info,
Error **errp);
+void bdrv_image_info_dump(ImageInfo *info);
#endif
diff --git a/qemu-img.c b/qemu-img.c
index 1dd0a60..5b229a9 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1606,73 +1606,6 @@ static void dump_json_image_info(ImageInfo *info)
QDECREF(str);
}
-static void dump_human_image_info(ImageInfo *info)
-{
- char size_buf[128], dsize_buf[128];
- if (!info->has_actual_size) {
- snprintf(dsize_buf, sizeof(dsize_buf), "unavailable");
- } else {
- get_human_readable_size(dsize_buf, sizeof(dsize_buf),
- info->actual_size);
- }
- get_human_readable_size(size_buf, sizeof(size_buf), info->virtual_size);
- printf("image: %s\n"
- "file format: %s\n"
- "virtual size: %s (%" PRId64 " bytes)\n"
- "disk size: %s\n",
- info->filename, info->format, size_buf,
- info->virtual_size,
- dsize_buf);
-
- if (info->has_encrypted && info->encrypted) {
- printf("encrypted: yes\n");
- }
-
- if (info->has_cluster_size) {
- printf("cluster_size: %" PRId64 "\n", info->cluster_size);
- }
-
- if (info->has_dirty_flag && info->dirty_flag) {
- printf("cleanly shut down: no\n");
- }
-
- if (info->has_backing_filename) {
- printf("backing file: %s", info->backing_filename);
- if (info->has_full_backing_filename) {
- printf(" (actual path: %s)", info->full_backing_filename);
- }
- putchar('\n');
- if (info->has_backing_filename_format) {
- printf("backing file format: %s\n", info->backing_filename_format);
- }
- }
-
- if (info->has_snapshots) {
- SnapshotInfoList *elem;
- char buf[256];
-
- printf("Snapshot list:\n");
- printf("%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL));
-
- /* Ideally bdrv_snapshot_dump() would operate on SnapshotInfoList but
- * we convert to the block layer's native QEMUSnapshotInfo for now.
- */
- for (elem = info->snapshots; elem; elem = elem->next) {
- QEMUSnapshotInfo sn = {
- .vm_state_size = elem->value->vm_state_size,
- .date_sec = elem->value->date_sec,
- .date_nsec = elem->value->date_nsec,
- .vm_clock_nsec = elem->value->vm_clock_sec * 1000000000ULL +
- elem->value->vm_clock_nsec,
- };
-
- pstrcpy(sn.id_str, sizeof(sn.id_str), elem->value->id);
- pstrcpy(sn.name, sizeof(sn.name), elem->value->name);
- printf("%s\n", bdrv_snapshot_dump(buf, sizeof(buf), &sn));
- }
- }
-}
-
static void dump_human_image_info_list(ImageInfoList *list)
{
ImageInfoList *elem;
@@ -1684,7 +1617,7 @@ static void dump_human_image_info_list(ImageInfoList
*list)
}
delim = true;
- dump_human_image_info(elem->value);
+ bdrv_image_info_dump(elem->value);
}
}
--
1.7.1
- Re: [Qemu-devel] [PATCH V10 05/17] block: add snapshot info query function bdrv_query_snapshot_info_list(), (continued)
- [Qemu-devel] [PATCH V10 08/17] block: move qmp_query_block() and bdrv_query_info() to block/qapi.c, Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 09/17] qmp: add interface query-snapshots, Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 07/17] block: add image info query function bdrv_query_image_info(), Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 10/17] qmp: add recursive member in ImageInfo, Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 11/17] qmp: add ImageInfo in BlockDeviceInfo used by query-block, Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 12/17] hmp: add function hmp_info_snapshots(), Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 13/17] hmp: switch snapshot info function to qmp based one, Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 14/17] block: move dump_human_image_info() to block/qapi.c,
Wenchao Xia <=
- [Qemu-devel] [PATCH V10 15/17] block: dump to buffer for bdrv_image_info_dump(), Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 16/17] hmp: show ImageInfo in 'info block', Wenchao Xia, 2013/03/22
- [Qemu-devel] [PATCH V10 17/17] hmp: add parameter device and -b for info block, Wenchao Xia, 2013/03/22
- Re: [Qemu-devel] [PATCH V10 00/17] qmp/hmp interfaces for internal snapshot info, Kevin Wolf, 2013/03/28