mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
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>
This commit is contained in:
committed by
Kevin Wolf
parent
2848289168
commit
52b10c9c0c
@ -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 ||
|
||||
|
Reference in New Issue
Block a user