|
|
7f1c5b |
From dca4cbe680baff837ca8ac8bd39b77b46af3f64b Mon Sep 17 00:00:00 2001
|
|
|
7f1c5b |
From: Hanna Reitz <hreitz@redhat.com>
|
|
|
7f1c5b |
Date: Mon, 20 Jun 2022 18:26:57 +0200
|
|
|
7f1c5b |
Subject: [PATCH 10/20] qemu-img: Use BlockNodeInfo
|
|
|
7f1c5b |
|
|
|
7f1c5b |
RH-Author: Hanna Czenczek <hreitz@redhat.com>
|
|
|
7f1c5b |
RH-MergeRequest: 145: Show protocol-level information in qemu-img info
|
|
|
7f1c5b |
RH-Bugzilla: 1860292
|
|
|
7f1c5b |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7f1c5b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7f1c5b |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
7f1c5b |
RH-Commit: [5/12] b599af3ec05951a0ba11d9eae2ee19148d6bf624 (hreitz/qemu-kvm-c-9-s)
|
|
|
7f1c5b |
|
|
|
7f1c5b |
qemu-img info never uses ImageInfo's backing-image field, because it
|
|
|
7f1c5b |
opens the backing chain one by one with BDRV_O_NO_BACKING, and prints
|
|
|
7f1c5b |
all backing chain nodes' information consecutively. Use BlockNodeInfo
|
|
|
7f1c5b |
to make it clear that we only print information about a single node, and
|
|
|
7f1c5b |
that we are not using the backing-image field.
|
|
|
7f1c5b |
|
|
|
7f1c5b |
Notably, bdrv_image_info_dump() does not evaluate the backing-image
|
|
|
7f1c5b |
field, so we can easily make it take a BlockNodeInfo pointer (and
|
|
|
7f1c5b |
consequentially rename it to bdrv_node_info_dump()). It makes more
|
|
|
7f1c5b |
sense this way, because again, the interface now makes it syntactically
|
|
|
7f1c5b |
clear that backing-image is ignored by this function.
|
|
|
7f1c5b |
|
|
|
7f1c5b |
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
7f1c5b |
Message-Id: <20220620162704.80987-6-hreitz@redhat.com>
|
|
|
7f1c5b |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7f1c5b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7f1c5b |
(cherry picked from commit b1f4cd1589a16fec02f264a09bd3560e4ccce3c2)
|
|
|
7f1c5b |
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
|
|
|
7f1c5b |
---
|
|
|
7f1c5b |
block/monitor/block-hmp-cmds.c | 2 +-
|
|
|
7f1c5b |
block/qapi.c | 2 +-
|
|
|
7f1c5b |
include/block/qapi.h | 2 +-
|
|
|
7f1c5b |
qapi/block-core.json | 4 +--
|
|
|
7f1c5b |
qemu-img.c | 48 +++++++++++++++++-----------------
|
|
|
7f1c5b |
5 files changed, 29 insertions(+), 29 deletions(-)
|
|
|
7f1c5b |
|
|
|
7f1c5b |
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
|
|
7f1c5b |
index b6135e9bfe..aa37faa601 100644
|
|
|
7f1c5b |
--- a/block/monitor/block-hmp-cmds.c
|
|
|
7f1c5b |
+++ b/block/monitor/block-hmp-cmds.c
|
|
|
7f1c5b |
@@ -734,7 +734,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
|
|
|
7f1c5b |
monitor_printf(mon, "\nImages:\n");
|
|
|
7f1c5b |
image_info = inserted->image;
|
|
|
7f1c5b |
while (1) {
|
|
|
7f1c5b |
- bdrv_image_info_dump(image_info);
|
|
|
7f1c5b |
+ bdrv_node_info_dump(qapi_ImageInfo_base(image_info));
|
|
|
7f1c5b |
if (image_info->has_backing_image) {
|
|
|
7f1c5b |
image_info = image_info->backing_image;
|
|
|
7f1c5b |
} else {
|
|
|
7f1c5b |
diff --git a/block/qapi.c b/block/qapi.c
|
|
|
7f1c5b |
index e5022b4481..ad88bf9b38 100644
|
|
|
7f1c5b |
--- a/block/qapi.c
|
|
|
7f1c5b |
+++ b/block/qapi.c
|
|
|
7f1c5b |
@@ -865,7 +865,7 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
|
|
|
7f1c5b |
visit_free(v);
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
|
|
|
7f1c5b |
-void bdrv_image_info_dump(ImageInfo *info)
|
|
|
7f1c5b |
+void bdrv_node_info_dump(BlockNodeInfo *info)
|
|
|
7f1c5b |
{
|
|
|
7f1c5b |
char *size_buf, *dsize_buf;
|
|
|
7f1c5b |
if (!info->has_actual_size) {
|
|
|
7f1c5b |
diff --git a/include/block/qapi.h b/include/block/qapi.h
|
|
|
7f1c5b |
index c7de4e3fa9..22198dcd0c 100644
|
|
|
7f1c5b |
--- a/include/block/qapi.h
|
|
|
7f1c5b |
+++ b/include/block/qapi.h
|
|
|
7f1c5b |
@@ -45,5 +45,5 @@ void bdrv_query_image_info(BlockDriverState *bs,
|
|
|
7f1c5b |
void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
|
|
|
7f1c5b |
void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
|
|
|
7f1c5b |
const char *prefix);
|
|
|
7f1c5b |
-void bdrv_image_info_dump(ImageInfo *info);
|
|
|
7f1c5b |
+void bdrv_node_info_dump(BlockNodeInfo *info);
|
|
|
7f1c5b |
#endif
|
|
|
7f1c5b |
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
|
|
7f1c5b |
index 7720da0498..4cf2deeb6c 100644
|
|
|
7f1c5b |
--- a/qapi/block-core.json
|
|
|
7f1c5b |
+++ b/qapi/block-core.json
|
|
|
7f1c5b |
@@ -5796,9 +5796,9 @@
|
|
|
7f1c5b |
##
|
|
|
7f1c5b |
# @DummyBlockCoreForceArrays:
|
|
|
7f1c5b |
#
|
|
|
7f1c5b |
-# Not used by QMP; hack to let us use ImageInfoList internally
|
|
|
7f1c5b |
+# Not used by QMP; hack to let us use BlockNodeInfoList internally
|
|
|
7f1c5b |
#
|
|
|
7f1c5b |
# Since: 8.0
|
|
|
7f1c5b |
##
|
|
|
7f1c5b |
{ 'struct': 'DummyBlockCoreForceArrays',
|
|
|
7f1c5b |
- 'data': { 'unused-image-info': ['ImageInfo'] } }
|
|
|
7f1c5b |
+ 'data': { 'unused-block-node-info': ['BlockNodeInfo'] } }
|
|
|
7f1c5b |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
7f1c5b |
index 2f85bb7ede..3b2ca3bbcb 100644
|
|
|
7f1c5b |
--- a/qemu-img.c
|
|
|
7f1c5b |
+++ b/qemu-img.c
|
|
|
7f1c5b |
@@ -2816,13 +2816,13 @@ static void dump_snapshots(BlockDriverState *bs)
|
|
|
7f1c5b |
g_free(sn_tab);
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
|
|
|
7f1c5b |
-static void dump_json_image_info_list(ImageInfoList *list)
|
|
|
7f1c5b |
+static void dump_json_block_node_info_list(BlockNodeInfoList *list)
|
|
|
7f1c5b |
{
|
|
|
7f1c5b |
GString *str;
|
|
|
7f1c5b |
QObject *obj;
|
|
|
7f1c5b |
Visitor *v = qobject_output_visitor_new(&obj);
|
|
|
7f1c5b |
|
|
|
7f1c5b |
- visit_type_ImageInfoList(v, NULL, &list, &error_abort);
|
|
|
7f1c5b |
+ visit_type_BlockNodeInfoList(v, NULL, &list, &error_abort);
|
|
|
7f1c5b |
visit_complete(v, &obj);
|
|
|
7f1c5b |
str = qobject_to_json_pretty(obj, true);
|
|
|
7f1c5b |
assert(str != NULL);
|
|
|
7f1c5b |
@@ -2832,13 +2832,13 @@ static void dump_json_image_info_list(ImageInfoList *list)
|
|
|
7f1c5b |
g_string_free(str, true);
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
|
|
|
7f1c5b |
-static void dump_json_image_info(ImageInfo *info)
|
|
|
7f1c5b |
+static void dump_json_block_node_info(BlockNodeInfo *info)
|
|
|
7f1c5b |
{
|
|
|
7f1c5b |
GString *str;
|
|
|
7f1c5b |
QObject *obj;
|
|
|
7f1c5b |
Visitor *v = qobject_output_visitor_new(&obj);
|
|
|
7f1c5b |
|
|
|
7f1c5b |
- visit_type_ImageInfo(v, NULL, &info, &error_abort);
|
|
|
7f1c5b |
+ visit_type_BlockNodeInfo(v, NULL, &info, &error_abort);
|
|
|
7f1c5b |
visit_complete(v, &obj);
|
|
|
7f1c5b |
str = qobject_to_json_pretty(obj, true);
|
|
|
7f1c5b |
assert(str != NULL);
|
|
|
7f1c5b |
@@ -2848,9 +2848,9 @@ static void dump_json_image_info(ImageInfo *info)
|
|
|
7f1c5b |
g_string_free(str, true);
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
|
|
|
7f1c5b |
-static void dump_human_image_info_list(ImageInfoList *list)
|
|
|
7f1c5b |
+static void dump_human_image_info_list(BlockNodeInfoList *list)
|
|
|
7f1c5b |
{
|
|
|
7f1c5b |
- ImageInfoList *elem;
|
|
|
7f1c5b |
+ BlockNodeInfoList *elem;
|
|
|
7f1c5b |
bool delim = false;
|
|
|
7f1c5b |
|
|
|
7f1c5b |
for (elem = list; elem; elem = elem->next) {
|
|
|
7f1c5b |
@@ -2859,7 +2859,7 @@ static void dump_human_image_info_list(ImageInfoList *list)
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
delim = true;
|
|
|
7f1c5b |
|
|
|
7f1c5b |
- bdrv_image_info_dump(elem->value);
|
|
|
7f1c5b |
+ bdrv_node_info_dump(elem->value);
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
|
|
|
7f1c5b |
@@ -2869,24 +2869,24 @@ static gboolean str_equal_func(gconstpointer a, gconstpointer b)
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
|
|
|
7f1c5b |
/**
|
|
|
7f1c5b |
- * Open an image file chain and return an ImageInfoList
|
|
|
7f1c5b |
+ * Open an image file chain and return an BlockNodeInfoList
|
|
|
7f1c5b |
*
|
|
|
7f1c5b |
* @filename: topmost image filename
|
|
|
7f1c5b |
* @fmt: topmost image format (may be NULL to autodetect)
|
|
|
7f1c5b |
* @chain: true - enumerate entire backing file chain
|
|
|
7f1c5b |
* false - only topmost image file
|
|
|
7f1c5b |
*
|
|
|
7f1c5b |
- * Returns a list of ImageInfo objects or NULL if there was an error opening an
|
|
|
7f1c5b |
- * image file. If there was an error a message will have been printed to
|
|
|
7f1c5b |
- * stderr.
|
|
|
7f1c5b |
+ * Returns a list of BlockNodeInfo objects or NULL if there was an error
|
|
|
7f1c5b |
+ * opening an image file. If there was an error a message will have been
|
|
|
7f1c5b |
+ * printed to stderr.
|
|
|
7f1c5b |
*/
|
|
|
7f1c5b |
-static ImageInfoList *collect_image_info_list(bool image_opts,
|
|
|
7f1c5b |
- const char *filename,
|
|
|
7f1c5b |
- const char *fmt,
|
|
|
7f1c5b |
- bool chain, bool force_share)
|
|
|
7f1c5b |
+static BlockNodeInfoList *collect_image_info_list(bool image_opts,
|
|
|
7f1c5b |
+ const char *filename,
|
|
|
7f1c5b |
+ const char *fmt,
|
|
|
7f1c5b |
+ bool chain, bool force_share)
|
|
|
7f1c5b |
{
|
|
|
7f1c5b |
- ImageInfoList *head = NULL;
|
|
|
7f1c5b |
- ImageInfoList **tail = &head;
|
|
|
7f1c5b |
+ BlockNodeInfoList *head = NULL;
|
|
|
7f1c5b |
+ BlockNodeInfoList **tail = &head;
|
|
|
7f1c5b |
GHashTable *filenames;
|
|
|
7f1c5b |
Error *err = NULL;
|
|
|
7f1c5b |
|
|
|
7f1c5b |
@@ -2895,7 +2895,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
|
|
|
7f1c5b |
while (filename) {
|
|
|
7f1c5b |
BlockBackend *blk;
|
|
|
7f1c5b |
BlockDriverState *bs;
|
|
|
7f1c5b |
- ImageInfo *info;
|
|
|
7f1c5b |
+ BlockNodeInfo *info;
|
|
|
7f1c5b |
|
|
|
7f1c5b |
if (g_hash_table_lookup_extended(filenames, filename, NULL, NULL)) {
|
|
|
7f1c5b |
error_report("Backing file '%s' creates an infinite loop.",
|
|
|
7f1c5b |
@@ -2912,7 +2912,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
bs = blk_bs(blk);
|
|
|
7f1c5b |
|
|
|
7f1c5b |
- bdrv_query_image_info(bs, &info, &err;;
|
|
|
7f1c5b |
+ bdrv_query_block_node_info(bs, &info, &err;;
|
|
|
7f1c5b |
if (err) {
|
|
|
7f1c5b |
error_report_err(err);
|
|
|
7f1c5b |
blk_unref(blk);
|
|
|
7f1c5b |
@@ -2945,7 +2945,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
|
|
|
7f1c5b |
return head;
|
|
|
7f1c5b |
|
|
|
7f1c5b |
err:
|
|
|
7f1c5b |
- qapi_free_ImageInfoList(head);
|
|
|
7f1c5b |
+ qapi_free_BlockNodeInfoList(head);
|
|
|
7f1c5b |
g_hash_table_destroy(filenames);
|
|
|
7f1c5b |
return NULL;
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
@@ -2956,7 +2956,7 @@ static int img_info(int argc, char **argv)
|
|
|
7f1c5b |
OutputFormat output_format = OFORMAT_HUMAN;
|
|
|
7f1c5b |
bool chain = false;
|
|
|
7f1c5b |
const char *filename, *fmt, *output;
|
|
|
7f1c5b |
- ImageInfoList *list;
|
|
|
7f1c5b |
+ BlockNodeInfoList *list;
|
|
|
7f1c5b |
bool image_opts = false;
|
|
|
7f1c5b |
bool force_share = false;
|
|
|
7f1c5b |
|
|
|
7f1c5b |
@@ -3035,14 +3035,14 @@ static int img_info(int argc, char **argv)
|
|
|
7f1c5b |
break;
|
|
|
7f1c5b |
case OFORMAT_JSON:
|
|
|
7f1c5b |
if (chain) {
|
|
|
7f1c5b |
- dump_json_image_info_list(list);
|
|
|
7f1c5b |
+ dump_json_block_node_info_list(list);
|
|
|
7f1c5b |
} else {
|
|
|
7f1c5b |
- dump_json_image_info(list->value);
|
|
|
7f1c5b |
+ dump_json_block_node_info(list->value);
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
break;
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
|
|
|
7f1c5b |
- qapi_free_ImageInfoList(list);
|
|
|
7f1c5b |
+ qapi_free_BlockNodeInfoList(list);
|
|
|
7f1c5b |
return 0;
|
|
|
7f1c5b |
}
|
|
|
7f1c5b |
|
|
|
7f1c5b |
--
|
|
|
7f1c5b |
2.31.1
|
|
|
7f1c5b |
|