[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/4] block: Add protocol-specific image info
From: |
Hanna Reitz |
Subject: |
[PATCH 2/4] block: Add protocol-specific image info |
Date: |
Tue, 3 May 2022 16:55:27 +0200 |
The ImageInfo object currently only contains (optional) format-specific
image information. However, perhaps the protocol node can provide some
additional information, so add a new field presenting it.
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
qapi/block-core.json | 6 +++++-
block/qapi.c | 19 +++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index beeb91952a..e7d6c2e0cc 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -236,6 +236,9 @@
# @format-specific: structure supplying additional format-specific
# information (since 1.7)
#
+# @protocol-specific: structure supplying additional protocol-specific
+# information (since 7.1)
+#
# Since: 1.3
#
##
@@ -246,7 +249,8 @@
'*backing-filename': 'str', '*full-backing-filename': 'str',
'*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
'*backing-image': 'ImageInfo',
- '*format-specific': 'ImageInfoSpecific' } }
+ '*format-specific': 'ImageInfoSpecific',
+ '*protocol-specific': 'ImageInfoSpecific' } }
##
# @ImageCheck:
diff --git a/block/qapi.c b/block/qapi.c
index 51202b470a..293983cf82 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -262,6 +262,7 @@ void bdrv_query_image_info(BlockDriverState *bs,
int64_t size;
const char *backing_filename;
BlockDriverInfo bdi;
+ BlockDriverState *protocol_bs;
int ret;
Error *err = NULL;
ImageInfo *info;
@@ -303,6 +304,24 @@ void bdrv_query_image_info(BlockDriverState *bs,
}
info->has_format_specific = info->format_specific != NULL;
+ /* Try to look for an unambiguous protocol node */
+ protocol_bs = bs;
+ while (protocol_bs && !QLIST_EMPTY(&protocol_bs->children)) {
+ protocol_bs = bdrv_primary_bs(protocol_bs);
+ }
+ if (protocol_bs) {
+ /* Assert that this is a protocol node */
+ assert(QLIST_EMPTY(&protocol_bs->children));
+
+ info->protocol_specific = bdrv_get_specific_info(protocol_bs, &err);
+ if (err) {
+ error_propagate(errp, err);
+ qapi_free_ImageInfo(info);
+ goto out;
+ }
+ info->has_protocol_specific = info->protocol_specific != NULL;
+ }
+
backing_filename = bs->backing_file;
if (backing_filename[0] != '\0') {
char *backing_filename2;
--
2.35.1
- [PATCH 3/4] block: Print protocol-specific information, (continued)