diff options
author | Eric Blake <eblake@redhat.com> | 2019-03-30 20:28:37 -0500 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2019-03-30 20:52:29 -0500 |
commit | a62a85ef5ccd764d03d72d6c3cd558f9755b3457 (patch) | |
tree | 91ded8c66681fc0f25fdda3f9511db835eabe179 /block | |
parent | 7da537f70d929800ba9c657b8a47a7b827695ccc (diff) | |
download | qemu-a62a85ef5ccd764d03d72d6c3cd558f9755b3457.zip qemu-a62a85ef5ccd764d03d72d6c3cd558f9755b3457.tar.gz qemu-a62a85ef5ccd764d03d72d6c3cd558f9755b3457.tar.bz2 |
nbd/client: Report offsets in bdrv_block_status
It is desirable for 'qemu-img map' to have the same output for a file
whether it is served over file or nbd protocols. However, ever since
we implemented block status for NBD (2.12), the NBD protocol forgot to
inform the block layer that as the final layer in the chain, the
offset is valid; without an offset, the human-readable form of
qemu-img map gives up with the unhelpful:
$ nbdkit -U - data data="1" size=512 --run 'qemu-img map $nbd'
Offset Length Mapped to File
qemu-img: File contains external, encrypted or compressed clusters.
The --output=json form always works, because it is reporting the
lower-level bdrv_block_status results directly rather than trying to
filter out sparse ranges for human consumption - but now it also
shows the offset member.
With this patch, the human output changes to:
Offset Length Mapped to File
0 0x200 0 nbd+unix://?socket=/tmp/nbdkitOxeoLa/socket
This change is observable to several iotests.
Fixes: 78a33ab5
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190329042750.14704-4-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/nbd-client.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c index 150af9c..3edb508 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -972,7 +972,9 @@ int coroutine_fn nbd_client_co_block_status(BlockDriverState *bs, if (!client->info.base_allocation) { *pnum = bytes; - return BDRV_BLOCK_DATA; + *map = offset; + *file = bs; + return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID; } ret = nbd_co_send_request(bs, &request, NULL); @@ -995,8 +997,11 @@ int coroutine_fn nbd_client_co_block_status(BlockDriverState *bs, assert(extent.length); *pnum = extent.length; + *map = offset; + *file = bs; return (extent.flags & NBD_STATE_HOLE ? 0 : BDRV_BLOCK_DATA) | - (extent.flags & NBD_STATE_ZERO ? BDRV_BLOCK_ZERO : 0); + (extent.flags & NBD_STATE_ZERO ? BDRV_BLOCK_ZERO : 0) | + BDRV_BLOCK_OFFSET_VALID; } void nbd_client_detach_aio_context(BlockDriverState *bs) |