diff mbox series

[v2,3/3] Add VHDX specific image info

Message ID 20241206000751.34694-4-takeshibaconsuzuki@gmail.com (mailing list archive)
State New
Headers show
Series Add RW support for 4k sector size vhdx | expand

Commit Message

Takeshi Suzuki Dec. 6, 2024, 12:07 a.m. UTC
Show logical sector size as follows:

```
Format specific information:
    logical sector size: 4096
```

Signed-off-by: Takeshi Suzuki <takeshibaconsuzuki@gmail.com>
---
 block/vhdx.c         | 21 +++++++++++++++++++++
 qapi/block-core.json | 27 +++++++++++++++++++++++++--
 2 files changed, 46 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/block/vhdx.c b/block/vhdx.c
index 495ddc2815..957aa99c2d 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -2270,6 +2270,26 @@  static int GRAPH_RDLOCK vhdx_has_zero_init(BlockDriverState *bs)
     return 1;
 }
 
+static ImageInfoSpecific * GRAPH_RDLOCK
+vhdx_get_specific_info(BlockDriverState *bs, Error **errp)
+{
+    const BDRVVHDXState *const s = bs->opaque;
+    ImageInfoSpecific *const spec_info = g_new0(ImageInfoSpecific, 1);
+
+    *spec_info = (ImageInfoSpecific){
+        .type = IMAGE_INFO_SPECIFIC_KIND_VHDX,
+        .u = {
+            .vhdx.data = g_new0(ImageInfoSpecificVHDX, 1),
+        },
+    };
+
+    *spec_info->u.vhdx.data = (ImageInfoSpecificVHDX) {
+        .logical_sector_size = s->logical_sector_size,
+    };
+
+    return spec_info;
+}
+
 static QemuOptsList vhdx_create_opts = {
     .name = "vhdx-create-opts",
     .head = QTAILQ_HEAD_INITIALIZER(vhdx_create_opts.head),
@@ -2321,6 +2341,7 @@  static BlockDriver bdrv_vhdx = {
     .bdrv_co_writev         = vhdx_co_writev,
     .bdrv_co_create         = vhdx_co_create,
     .bdrv_co_create_opts    = vhdx_co_create_opts,
+    .bdrv_get_specific_info = vhdx_get_specific_info,
     .bdrv_co_get_info       = vhdx_co_get_info,
     .bdrv_co_check          = vhdx_co_check,
     .bdrv_has_zero_init     = vhdx_has_zero_init,
diff --git a/qapi/block-core.json b/qapi/block-core.json
index fd3bcc1c17..7d6ac22776 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -179,6 +179,18 @@ 
       '*extent-size-hint': 'size'
   } }
 
+##
+# @ImageInfoSpecificVHDX:
+#
+# @logical-sector-size: Logical sector size
+#
+# Since: 9.2
+##
+{ 'struct': 'ImageInfoSpecificVHDX',
+  'data': {
+      'logical-sector-size': 'int'
+  } }
+
 ##
 # @ImageInfoSpecificKind:
 #
@@ -191,7 +203,7 @@ 
 # Since: 1.7
 ##
 { 'enum': 'ImageInfoSpecificKind',
-  'data': [ 'qcow2', 'vmdk', 'luks', 'rbd', 'file' ] }
+  'data': [ 'qcow2', 'vmdk', 'luks', 'rbd', 'file', 'vhdx' ] }
 
 ##
 # @ImageInfoSpecificQCow2Wrapper:
@@ -246,6 +258,16 @@ 
 { 'struct': 'ImageInfoSpecificFileWrapper',
   'data': { 'data': 'ImageInfoSpecificFile' } }
 
+##
+# @ImageInfoSpecificVHDXWrapper:
+#
+# @data: image information specific to VHDX
+#
+# Since: 9.2
+##
+{ 'struct': 'ImageInfoSpecificVHDXWrapper',
+  'data': { 'data': 'ImageInfoSpecificVHDX' } }
+
 ##
 # @ImageInfoSpecific:
 #
@@ -264,7 +286,8 @@ 
       'vmdk': 'ImageInfoSpecificVmdkWrapper',
       'luks': 'ImageInfoSpecificLUKSWrapper',
       'rbd': 'ImageInfoSpecificRbdWrapper',
-      'file': 'ImageInfoSpecificFileWrapper'
+      'file': 'ImageInfoSpecificFileWrapper',
+      'vhdx': 'ImageInfoSpecificVHDXWrapper'
   } }
 
 ##