diff options
author | Andrey Drobyshev via <qemu-block@nongnu.org> | 2023-09-08 00:02:26 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-09-20 17:46:01 +0200 |
commit | 52b10c9c0c68e90f9503ba578f2eaf8975c1977f (patch) | |
tree | 7f605b83196e95f5b70c7b653fc4dc1f89c45d26 /qemu-img.c | |
parent | 2848289168fbbd9a6855c84ec8fde8929a2b042b (diff) | |
download | qemu-52b10c9c0c68e90f9503ba578f2eaf8975c1977f.zip qemu-52b10c9c0c68e90f9503ba578f2eaf8975c1977f.tar.gz qemu-52b10c9c0c68e90f9503ba578f2eaf8975c1977f.tar.bz2 |
qemu-img: map: report compressed data blocks
Right now "qemu-img map" reports compressed blocks as containing data
but having no host offset. This is not very informative. Instead,
let's add another boolean field named "compressed" in case JSON output
mode is specified. This is achieved by utilizing new allocation status
flag BDRV_BLOCK_COMPRESSED for bdrv_block_status().
Also update the expected qemu-iotests outputs to contain the new field.
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Message-ID: <20230907210226.953821-3-andrey.drobyshev@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -3108,10 +3108,12 @@ static int dump_map_entry(OutputFormat output_format, MapEntry *e, case OFORMAT_JSON: printf("{ \"start\": %"PRId64", \"length\": %"PRId64"," " \"depth\": %"PRId64", \"present\": %s, \"zero\": %s," - " \"data\": %s", e->start, e->length, e->depth, + " \"data\": %s, \"compressed\": %s", + e->start, e->length, e->depth, e->present ? "true" : "false", e->zero ? "true" : "false", - e->data ? "true" : "false"); + e->data ? "true" : "false", + e->compressed ? "true" : "false"); if (e->has_offset) { printf(", \"offset\": %"PRId64"", e->offset); } @@ -3172,6 +3174,7 @@ static int get_block_status(BlockDriverState *bs, int64_t offset, .length = bytes, .data = !!(ret & BDRV_BLOCK_DATA), .zero = !!(ret & BDRV_BLOCK_ZERO), + .compressed = !!(ret & BDRV_BLOCK_COMPRESSED), .offset = map, .has_offset = has_offset, .depth = depth, @@ -3189,6 +3192,7 @@ static inline bool entry_mergeable(const MapEntry *curr, const MapEntry *next) } if (curr->zero != next->zero || curr->data != next->data || + curr->compressed != next->compressed || curr->depth != next->depth || curr->present != next->present || !curr->filename != !next->filename || |