|
|
ed5979 |
From c8c282c2e1d74cfc5de6527f7e20dfc3e76b67ac Mon Sep 17 00:00:00 2001
|
|
|
ed5979 |
From: Hanna Reitz <hreitz@redhat.com>
|
|
|
ed5979 |
Date: Mon, 20 Jun 2022 18:27:00 +0200
|
|
|
ed5979 |
Subject: [PATCH 13/20] block/qapi: Add indentation to bdrv_node_info_dump()
|
|
|
ed5979 |
|
|
|
ed5979 |
RH-Author: Hanna Czenczek <hreitz@redhat.com>
|
|
|
ed5979 |
RH-MergeRequest: 145: Show protocol-level information in qemu-img info
|
|
|
ed5979 |
RH-Bugzilla: 1860292
|
|
|
ed5979 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
ed5979 |
RH-Commit: [8/12] d3a697e81ab9828457198075e5815a592363c725 (hreitz/qemu-kvm-c-9-s)
|
|
|
ed5979 |
|
|
|
ed5979 |
In order to let qemu-img info present a block graph, add a parameter to
|
|
|
ed5979 |
bdrv_node_info_dump() and bdrv_image_info_specific_dump() so that the
|
|
|
ed5979 |
information of nodes below the root level can be given an indentation.
|
|
|
ed5979 |
|
|
|
ed5979 |
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
ed5979 |
Message-Id: <20220620162704.80987-9-hreitz@redhat.com>
|
|
|
ed5979 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
(cherry picked from commit 76c9e9750d1bd580e8ed4465f6be3a986434e7c3)
|
|
|
ed5979 |
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
|
|
|
ed5979 |
---
|
|
|
ed5979 |
block/monitor/block-hmp-cmds.c | 2 +-
|
|
|
ed5979 |
block/qapi.c | 47 +++++++++++++++++++---------------
|
|
|
ed5979 |
include/block/qapi.h | 5 ++--
|
|
|
ed5979 |
qemu-img.c | 2 +-
|
|
|
ed5979 |
qemu-io-cmds.c | 3 ++-
|
|
|
ed5979 |
5 files changed, 34 insertions(+), 25 deletions(-)
|
|
|
ed5979 |
|
|
|
ed5979 |
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
|
|
ed5979 |
index aa37faa601..72824d4e2e 100644
|
|
|
ed5979 |
--- a/block/monitor/block-hmp-cmds.c
|
|
|
ed5979 |
+++ b/block/monitor/block-hmp-cmds.c
|
|
|
ed5979 |
@@ -734,7 +734,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
|
|
|
ed5979 |
monitor_printf(mon, "\nImages:\n");
|
|
|
ed5979 |
image_info = inserted->image;
|
|
|
ed5979 |
while (1) {
|
|
|
ed5979 |
- bdrv_node_info_dump(qapi_ImageInfo_base(image_info));
|
|
|
ed5979 |
+ bdrv_node_info_dump(qapi_ImageInfo_base(image_info), 0);
|
|
|
ed5979 |
if (image_info->has_backing_image) {
|
|
|
ed5979 |
image_info = image_info->backing_image;
|
|
|
ed5979 |
} else {
|
|
|
ed5979 |
diff --git a/block/qapi.c b/block/qapi.c
|
|
|
ed5979 |
index f208c21ccf..3e35603f0c 100644
|
|
|
ed5979 |
--- a/block/qapi.c
|
|
|
ed5979 |
+++ b/block/qapi.c
|
|
|
ed5979 |
@@ -915,7 +915,8 @@ static bool qobject_is_empty_dump(const QObject *obj)
|
|
|
ed5979 |
* prepending an optional prefix if the dump is not empty.
|
|
|
ed5979 |
*/
|
|
|
ed5979 |
void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
|
|
|
ed5979 |
- const char *prefix)
|
|
|
ed5979 |
+ const char *prefix,
|
|
|
ed5979 |
+ int indentation)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
QObject *obj, *data;
|
|
|
ed5979 |
Visitor *v = qobject_output_visitor_new(&obj);
|
|
|
ed5979 |
@@ -925,48 +926,51 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
|
|
|
ed5979 |
data = qdict_get(qobject_to(QDict, obj), "data");
|
|
|
ed5979 |
if (!qobject_is_empty_dump(data)) {
|
|
|
ed5979 |
if (prefix) {
|
|
|
ed5979 |
- qemu_printf("%s", prefix);
|
|
|
ed5979 |
+ qemu_printf("%*s%s", indentation * 4, "", prefix);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
- dump_qobject(1, data);
|
|
|
ed5979 |
+ dump_qobject(indentation + 1, data);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
qobject_unref(obj);
|
|
|
ed5979 |
visit_free(v);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
-void bdrv_node_info_dump(BlockNodeInfo *info)
|
|
|
ed5979 |
+void bdrv_node_info_dump(BlockNodeInfo *info, int indentation)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
char *size_buf, *dsize_buf;
|
|
|
ed5979 |
+ g_autofree char *ind_s = g_strdup_printf("%*s", indentation * 4, "");
|
|
|
ed5979 |
+
|
|
|
ed5979 |
if (!info->has_actual_size) {
|
|
|
ed5979 |
dsize_buf = g_strdup("unavailable");
|
|
|
ed5979 |
} else {
|
|
|
ed5979 |
dsize_buf = size_to_str(info->actual_size);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
size_buf = size_to_str(info->virtual_size);
|
|
|
ed5979 |
- qemu_printf("image: %s\n"
|
|
|
ed5979 |
- "file format: %s\n"
|
|
|
ed5979 |
- "virtual size: %s (%" PRId64 " bytes)\n"
|
|
|
ed5979 |
- "disk size: %s\n",
|
|
|
ed5979 |
- info->filename, info->format, size_buf,
|
|
|
ed5979 |
- info->virtual_size,
|
|
|
ed5979 |
- dsize_buf);
|
|
|
ed5979 |
+ qemu_printf("%simage: %s\n"
|
|
|
ed5979 |
+ "%sfile format: %s\n"
|
|
|
ed5979 |
+ "%svirtual size: %s (%" PRId64 " bytes)\n"
|
|
|
ed5979 |
+ "%sdisk size: %s\n",
|
|
|
ed5979 |
+ ind_s, info->filename,
|
|
|
ed5979 |
+ ind_s, info->format,
|
|
|
ed5979 |
+ ind_s, size_buf, info->virtual_size,
|
|
|
ed5979 |
+ ind_s, dsize_buf);
|
|
|
ed5979 |
g_free(size_buf);
|
|
|
ed5979 |
g_free(dsize_buf);
|
|
|
ed5979 |
|
|
|
ed5979 |
if (info->has_encrypted && info->encrypted) {
|
|
|
ed5979 |
- qemu_printf("encrypted: yes\n");
|
|
|
ed5979 |
+ qemu_printf("%sencrypted: yes\n", ind_s);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
if (info->has_cluster_size) {
|
|
|
ed5979 |
- qemu_printf("cluster_size: %" PRId64 "\n",
|
|
|
ed5979 |
- info->cluster_size);
|
|
|
ed5979 |
+ qemu_printf("%scluster_size: %" PRId64 "\n",
|
|
|
ed5979 |
+ ind_s, info->cluster_size);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
if (info->has_dirty_flag && info->dirty_flag) {
|
|
|
ed5979 |
- qemu_printf("cleanly shut down: no\n");
|
|
|
ed5979 |
+ qemu_printf("%scleanly shut down: no\n", ind_s);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
if (info->has_backing_filename) {
|
|
|
ed5979 |
- qemu_printf("backing file: %s", info->backing_filename);
|
|
|
ed5979 |
+ qemu_printf("%sbacking file: %s", ind_s, info->backing_filename);
|
|
|
ed5979 |
if (!info->has_full_backing_filename) {
|
|
|
ed5979 |
qemu_printf(" (cannot determine actual path)");
|
|
|
ed5979 |
} else if (strcmp(info->backing_filename,
|
|
|
ed5979 |
@@ -975,15 +979,16 @@ void bdrv_node_info_dump(BlockNodeInfo *info)
|
|
|
ed5979 |
}
|
|
|
ed5979 |
qemu_printf("\n");
|
|
|
ed5979 |
if (info->has_backing_filename_format) {
|
|
|
ed5979 |
- qemu_printf("backing file format: %s\n",
|
|
|
ed5979 |
- info->backing_filename_format);
|
|
|
ed5979 |
+ qemu_printf("%sbacking file format: %s\n",
|
|
|
ed5979 |
+ ind_s, info->backing_filename_format);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
if (info->has_snapshots) {
|
|
|
ed5979 |
SnapshotInfoList *elem;
|
|
|
ed5979 |
|
|
|
ed5979 |
- qemu_printf("Snapshot list:\n");
|
|
|
ed5979 |
+ qemu_printf("%sSnapshot list:\n", ind_s);
|
|
|
ed5979 |
+ qemu_printf("%s", ind_s);
|
|
|
ed5979 |
bdrv_snapshot_dump(NULL);
|
|
|
ed5979 |
qemu_printf("\n");
|
|
|
ed5979 |
|
|
|
ed5979 |
@@ -1003,6 +1008,7 @@ void bdrv_node_info_dump(BlockNodeInfo *info)
|
|
|
ed5979 |
|
|
|
ed5979 |
pstrcpy(sn.id_str, sizeof(sn.id_str), elem->value->id);
|
|
|
ed5979 |
pstrcpy(sn.name, sizeof(sn.name), elem->value->name);
|
|
|
ed5979 |
+ qemu_printf("%s", ind_s);
|
|
|
ed5979 |
bdrv_snapshot_dump(&sn;;
|
|
|
ed5979 |
qemu_printf("\n");
|
|
|
ed5979 |
}
|
|
|
ed5979 |
@@ -1010,6 +1016,7 @@ void bdrv_node_info_dump(BlockNodeInfo *info)
|
|
|
ed5979 |
|
|
|
ed5979 |
if (info->has_format_specific) {
|
|
|
ed5979 |
bdrv_image_info_specific_dump(info->format_specific,
|
|
|
ed5979 |
- "Format specific information:\n");
|
|
|
ed5979 |
+ "Format specific information:\n",
|
|
|
ed5979 |
+ indentation);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
diff --git a/include/block/qapi.h b/include/block/qapi.h
|
|
|
ed5979 |
index 196436020e..38855f2ae9 100644
|
|
|
ed5979 |
--- a/include/block/qapi.h
|
|
|
ed5979 |
+++ b/include/block/qapi.h
|
|
|
ed5979 |
@@ -49,6 +49,7 @@ void bdrv_query_block_graph_info(BlockDriverState *bs,
|
|
|
ed5979 |
|
|
|
ed5979 |
void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
|
|
|
ed5979 |
void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
|
|
|
ed5979 |
- const char *prefix);
|
|
|
ed5979 |
-void bdrv_node_info_dump(BlockNodeInfo *info);
|
|
|
ed5979 |
+ const char *prefix,
|
|
|
ed5979 |
+ int indentation);
|
|
|
ed5979 |
+void bdrv_node_info_dump(BlockNodeInfo *info, int indentation);
|
|
|
ed5979 |
#endif
|
|
|
ed5979 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
ed5979 |
index 3b2ca3bbcb..30b4ea58bb 100644
|
|
|
ed5979 |
--- a/qemu-img.c
|
|
|
ed5979 |
+++ b/qemu-img.c
|
|
|
ed5979 |
@@ -2859,7 +2859,7 @@ static void dump_human_image_info_list(BlockNodeInfoList *list)
|
|
|
ed5979 |
}
|
|
|
ed5979 |
delim = true;
|
|
|
ed5979 |
|
|
|
ed5979 |
- bdrv_node_info_dump(elem->value);
|
|
|
ed5979 |
+ bdrv_node_info_dump(elem->value, 0);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
|
|
|
ed5979 |
index f4a374528e..fdcb89211b 100644
|
|
|
ed5979 |
--- a/qemu-io-cmds.c
|
|
|
ed5979 |
+++ b/qemu-io-cmds.c
|
|
|
ed5979 |
@@ -1826,7 +1826,8 @@ static int info_f(BlockBackend *blk, int argc, char **argv)
|
|
|
ed5979 |
}
|
|
|
ed5979 |
if (spec_info) {
|
|
|
ed5979 |
bdrv_image_info_specific_dump(spec_info,
|
|
|
ed5979 |
- "Format specific information:\n");
|
|
|
ed5979 |
+ "Format specific information:\n",
|
|
|
ed5979 |
+ 0);
|
|
|
ed5979 |
qapi_free_ImageInfoSpecific(spec_info);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
--
|
|
|
ed5979 |
2.31.1
|
|
|
ed5979 |
|