|
|
ed5979 |
From 0044e3848b02ef6edba5961d1f4b6297d137d207 Mon Sep 17 00:00:00 2001
|
|
|
ed5979 |
From: Hanna Reitz <hreitz@redhat.com>
|
|
|
ed5979 |
Date: Mon, 20 Jun 2022 18:26:59 +0200
|
|
|
ed5979 |
Subject: [PATCH 12/20] block/qapi: Introduce BlockGraphInfo
|
|
|
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: [7/12] de47bac372cd552b812c774a2f35f95923af74ff (hreitz/qemu-kvm-c-9-s)
|
|
|
ed5979 |
|
|
|
ed5979 |
Introduce a new QAPI type BlockGraphInfo and an associated
|
|
|
ed5979 |
bdrv_query_block_graph_info() function that recursively gathers
|
|
|
ed5979 |
BlockNodeInfo objects through a block graph.
|
|
|
ed5979 |
|
|
|
ed5979 |
A follow-up patch is going to make "qemu-img info" use this to print
|
|
|
ed5979 |
information about all nodes that are (usually implicitly) opened for a
|
|
|
ed5979 |
given image file.
|
|
|
ed5979 |
|
|
|
ed5979 |
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
ed5979 |
Message-Id: <20220620162704.80987-8-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 6cab33997b91eb86e82a6a2ae58a24f835249d4a)
|
|
|
ed5979 |
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
|
|
|
ed5979 |
---
|
|
|
ed5979 |
block/qapi.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
ed5979 |
include/block/qapi.h | 3 +++
|
|
|
ed5979 |
qapi/block-core.json | 35 ++++++++++++++++++++++++++++++++
|
|
|
ed5979 |
3 files changed, 86 insertions(+)
|
|
|
ed5979 |
|
|
|
ed5979 |
diff --git a/block/qapi.c b/block/qapi.c
|
|
|
ed5979 |
index 5d0a8d2ce3..f208c21ccf 100644
|
|
|
ed5979 |
--- a/block/qapi.c
|
|
|
ed5979 |
+++ b/block/qapi.c
|
|
|
ed5979 |
@@ -411,6 +411,54 @@ fail:
|
|
|
ed5979 |
qapi_free_ImageInfo(info);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
+/**
|
|
|
ed5979 |
+ * bdrv_query_block_graph_info:
|
|
|
ed5979 |
+ * @bs: root node to start from
|
|
|
ed5979 |
+ * @p_info: location to store image information
|
|
|
ed5979 |
+ * @errp: location to store error information
|
|
|
ed5979 |
+ *
|
|
|
ed5979 |
+ * Store image information about the graph starting from @bs in @p_info.
|
|
|
ed5979 |
+ *
|
|
|
ed5979 |
+ * @p_info will be set only on success. On error, store error in @errp.
|
|
|
ed5979 |
+ */
|
|
|
ed5979 |
+void bdrv_query_block_graph_info(BlockDriverState *bs,
|
|
|
ed5979 |
+ BlockGraphInfo **p_info,
|
|
|
ed5979 |
+ Error **errp)
|
|
|
ed5979 |
+{
|
|
|
ed5979 |
+ BlockGraphInfo *info;
|
|
|
ed5979 |
+ BlockChildInfoList **children_list_tail;
|
|
|
ed5979 |
+ BdrvChild *c;
|
|
|
ed5979 |
+ ERRP_GUARD();
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+ info = g_new0(BlockGraphInfo, 1);
|
|
|
ed5979 |
+ bdrv_do_query_node_info(bs, qapi_BlockGraphInfo_base(info), errp);
|
|
|
ed5979 |
+ if (*errp) {
|
|
|
ed5979 |
+ goto fail;
|
|
|
ed5979 |
+ }
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+ children_list_tail = &info->children;
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+ QLIST_FOREACH(c, &bs->children, next) {
|
|
|
ed5979 |
+ BlockChildInfo *c_info;
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+ c_info = g_new0(BlockChildInfo, 1);
|
|
|
ed5979 |
+ QAPI_LIST_APPEND(children_list_tail, c_info);
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+ c_info->name = g_strdup(c->name);
|
|
|
ed5979 |
+ bdrv_query_block_graph_info(c->bs, &c_info->info, errp);
|
|
|
ed5979 |
+ if (*errp) {
|
|
|
ed5979 |
+ goto fail;
|
|
|
ed5979 |
+ }
|
|
|
ed5979 |
+ }
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+ *p_info = info;
|
|
|
ed5979 |
+ return;
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+fail:
|
|
|
ed5979 |
+ assert(*errp != NULL);
|
|
|
ed5979 |
+ qapi_free_BlockGraphInfo(info);
|
|
|
ed5979 |
+}
|
|
|
ed5979 |
+
|
|
|
ed5979 |
/* @p_info will be set only on success. */
|
|
|
ed5979 |
static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
|
|
|
ed5979 |
Error **errp)
|
|
|
ed5979 |
diff --git a/include/block/qapi.h b/include/block/qapi.h
|
|
|
ed5979 |
index 2174bf8fa2..196436020e 100644
|
|
|
ed5979 |
--- a/include/block/qapi.h
|
|
|
ed5979 |
+++ b/include/block/qapi.h
|
|
|
ed5979 |
@@ -43,6 +43,9 @@ void bdrv_query_image_info(BlockDriverState *bs,
|
|
|
ed5979 |
bool flat,
|
|
|
ed5979 |
bool skip_implicit_filters,
|
|
|
ed5979 |
Error **errp);
|
|
|
ed5979 |
+void bdrv_query_block_graph_info(BlockDriverState *bs,
|
|
|
ed5979 |
+ BlockGraphInfo **p_info,
|
|
|
ed5979 |
+ Error **errp);
|
|
|
ed5979 |
|
|
|
ed5979 |
void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
|
|
|
ed5979 |
void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
|
|
|
ed5979 |
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
|
|
ed5979 |
index 4cf2deeb6c..d703e0fb16 100644
|
|
|
ed5979 |
--- a/qapi/block-core.json
|
|
|
ed5979 |
+++ b/qapi/block-core.json
|
|
|
ed5979 |
@@ -307,6 +307,41 @@
|
|
|
ed5979 |
'*backing-image': 'ImageInfo'
|
|
|
ed5979 |
} }
|
|
|
ed5979 |
|
|
|
ed5979 |
+##
|
|
|
ed5979 |
+# @BlockChildInfo:
|
|
|
ed5979 |
+#
|
|
|
ed5979 |
+# Information about all nodes in the block graph starting at some node,
|
|
|
ed5979 |
+# annotated with information about that node in relation to its parent.
|
|
|
ed5979 |
+#
|
|
|
ed5979 |
+# @name: Child name of the root node in the BlockGraphInfo struct, in its role
|
|
|
ed5979 |
+# as the child of some undescribed parent node
|
|
|
ed5979 |
+#
|
|
|
ed5979 |
+# @info: Block graph information starting at this node
|
|
|
ed5979 |
+#
|
|
|
ed5979 |
+# Since: 8.0
|
|
|
ed5979 |
+##
|
|
|
ed5979 |
+{ 'struct': 'BlockChildInfo',
|
|
|
ed5979 |
+ 'data': {
|
|
|
ed5979 |
+ 'name': 'str',
|
|
|
ed5979 |
+ 'info': 'BlockGraphInfo'
|
|
|
ed5979 |
+ } }
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+##
|
|
|
ed5979 |
+# @BlockGraphInfo:
|
|
|
ed5979 |
+#
|
|
|
ed5979 |
+# Information about all nodes in a block (sub)graph in the form of BlockNodeInfo
|
|
|
ed5979 |
+# data.
|
|
|
ed5979 |
+# The base BlockNodeInfo struct contains the information for the (sub)graph's
|
|
|
ed5979 |
+# root node.
|
|
|
ed5979 |
+#
|
|
|
ed5979 |
+# @children: Array of links to this node's child nodes' information
|
|
|
ed5979 |
+#
|
|
|
ed5979 |
+# Since: 8.0
|
|
|
ed5979 |
+##
|
|
|
ed5979 |
+{ 'struct': 'BlockGraphInfo',
|
|
|
ed5979 |
+ 'base': 'BlockNodeInfo',
|
|
|
ed5979 |
+ 'data': { 'children': ['BlockChildInfo'] } }
|
|
|
ed5979 |
+
|
|
|
ed5979 |
##
|
|
|
ed5979 |
# @ImageCheck:
|
|
|
ed5979 |
#
|
|
|
ed5979 |
--
|
|
|
ed5979 |
2.31.1
|
|
|
ed5979 |
|