block: add the optional file entry to query-block
PATCH v2 1/1 block: add the optional file entry to query-block
This patch adds the optional file entry to the query-block output. The value is a json-object representing the information about the underlying file or device (when present).
--- block/qapi.c | 7 +++++++ qapi-schema.json | 4 +++- qmp-commands.hx | 8 ++++++++ tests/qemu-iotests/043.out | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 1 deletions(-)
block/qapi.c +7 -0
@@ -171,6 +171,13 @@ void bdrv_query_image_info(BlockDriverState *bs,return ; } +if (bs->file) { +bdrv_query_image_info (bs->file, &info->file, &err); +if (info->file) { + info->has_file = true; + } + } + *p_info = info; }
qapi-schema.json +3 -1
@@ -238,6 +238,8 @@ # # @backing-image: #optional info of the backing image (since 1.6) # +# @file: #optional info of the underlying file (since 1.6) +# # Since: 1.3 # ##
@@ -248,7 +250,7 @@ '*cluster-size': 'int', '*encrypted': 'bool', '*backing-filename': 'str', '*full-backing-filename': 'str', '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'], - '*backing-image': 'ImageInfo' } } + '*backing-image': 'ImageInfo', '*file': 'ImageInfo' } } ## # @ImageCheck:
qmp-commands.hx +8 -0
@@ -1791,6 +1791,8 @@ Each json-object contain the following: - "backing-image": the detail of the backing image, it is an optional json-object only present when a backing image present for this image + - "file": an optional json-object representing the information + about the underlying file or device (when present) - "io-status": I/O operation status, only present if the device supports it and the VM is configured to stop on errors. It's always reset
@@ -1842,6 +1844,12 @@ Example: "format":"qcow2", "virtual-size":2048000 } + "file":{ + "filename":"disks/test.qcow2", + "format": "file", + "virtual-size": 262144, + "actual-size": 139264 + } } }, "type":"unknown"
tests/qemu-iotests/043.out +15 -0
@@ -44,6 +44,11 @@ cluster_size: 65536 "filename": "TEST_DIR/t.IMGFMT", "cluster-size": 65536, "format": "IMGFMT", + "file": { + "virtual-size": 327680, + "filename": "TEST_DIR/t.IMGFMT", + "format": "file", + }, "backing-filename": "TEST_DIR/t.IMGFMT.2.base", "dirty-flag": false },
@@ -52,6 +57,11 @@ cluster_size: 65536 "filename": "TEST_DIR/t.IMGFMT.2.base", "cluster-size": 65536, "format": "IMGFMT", + "file": { + "virtual-size": 327680, + "filename": "TEST_DIR/t.IMGFMT.2.base", + "format": "file", + }, "backing-filename": "TEST_DIR/t.IMGFMT.1.base", "dirty-flag": false },
@@ -60,6 +70,11 @@ cluster_size: 65536 "filename": "TEST_DIR/t.IMGFMT.1.base", "cluster-size": 65536, "format": "IMGFMT", + "file": { + "virtual-size": 327680, + "filename": "TEST_DIR/t.IMGFMT.1.base", + "format": "file", + }, "dirty-flag": false } ]
Signature · 1 line
1.7.1
Quoted 11 lines · Federico Simoncelli
This patch adds the optional file entry to the query-block output. The value is a json-object representing the information about the underlying file or device (when present).
Signed-off-by Federico Simoncelli <[email protected]>--- block/qapi.c | 7 +++++++ qapi-schema.json | 4 +++- qmp-commands.hx | 8 ++++++++ tests/qemu-iotests/043.out | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 1 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Am 05.07.2013 um 16:28 hat Federico Simoncelli geschrieben:
Quoted 83 lines
This patch adds the optional file entry to the query-block output. The value is a json-object representing the information about the underlying file or device (when present).
Signed-off-by Federico Simoncelli <[email protected]>--- block/qapi.c | 7 +++++++ qapi-schema.json | 4 +++- qmp-commands.hx | 8 ++++++++ tests/qemu-iotests/043.out | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 1 deletions(-)block/qapi.c +7
-0@@ -171,6 +171,13 @@ void bdrv_query_image_info(BlockDriverState *bs,return ; } +if (bs->file) { +bdrv_query_image_info (bs->file, &info->file, &err); +if (info->file) { + info->has_file = true; + } + } + *p_info = info; }qapi-schema.json +3
-1@@ -238,6 +238,8 @@ # # @backing-image: #optional info of the backing image (since 1.6) # +# @file: #optional info of the underlying file (since 1.6) +# # Since: 1.3 # ##@@ -248,7 +250,7 @@ '*cluster-size': 'int', '*encrypted': 'bool', '*backing-filename': 'str', '*full-backing-filename': 'str', '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'], - '*backing-image': 'ImageInfo' } } + '*backing-image': 'ImageInfo', '*file': 'ImageInfo' } } ## # @ImageCheck:qmp-commands.hx +8
-0@@ -1791,6 +1791,8 @@ Each json-object contain the following: - "backing-image": the detail of the backing image, it is an optional json-object only present when a backing image present for this image + - "file": an optional json-object representing the information + about the underlying file or device (when present) - "io-status": I/O operation status, only present if the device supports it and the VM is configured to stop on errors. It's always reset@@ -1842,6 +1844,12 @@ Example: "format":"qcow2", "virtual-size":2048000 } + "file":{ + "filename":"disks/test.qcow2", + "format": "file", + "virtual-size": 262144, + "actual-size": 139264 + } } }, "type":"unknown"tests/qemu-iotests/043.out +0
-0
tests/qemu-iotests/043.out cluster_size: 65536 · line 48
Quoted 5 lines
tests/qemu-iotests/043.out +2
-0@@ -44,6 +44,11 @@ cluster_size: 65536 "filename": "TEST_DIR/t.IMGFMT", "cluster-size": 65536, "format": "IMGFMT", + "file": { + "virtual-size": 327680,
This is the right value for QED, but not for qcow2. I guess we need to filter this out. Ideally in a way that doesn't remove the top-level virtual-size, but I'm not sure if this is possible.
Kevin