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