diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-09-04 19:00:30 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2013-09-06 15:25:09 +0200 |
commit | 4bc74be997a72922170f4f272fd5e8074a3ecc27 (patch) | |
tree | c3b466014f752398a8b9543e99da0651bb12c759 /block/vdi.c | |
parent | 4333bb71405f58a8dc8d3255feb3ca5960b0daf8 (diff) |
block: return get_block_status data and flags for formats
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/vdi.c')
-rw-r--r-- | block/vdi.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/block/vdi.c b/block/vdi.c index 7ab256776e..1bf7dc575a 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -479,12 +479,23 @@ static int64_t coroutine_fn vdi_co_get_block_status(BlockDriverState *bs, size_t sector_in_block = sector_num % s->block_sectors; int n_sectors = s->block_sectors - sector_in_block; uint32_t bmap_entry = le32_to_cpu(s->bmap[bmap_index]); + uint64_t offset; + int result; + logout("%p, %" PRId64 ", %d, %p\n", bs, sector_num, nb_sectors, pnum); if (n_sectors > nb_sectors) { n_sectors = nb_sectors; } *pnum = n_sectors; - return VDI_IS_ALLOCATED(bmap_entry); + result = VDI_IS_ALLOCATED(bmap_entry); + if (!result) { + return 0; + } + + offset = s->header.offset_data + + (uint64_t)bmap_entry * s->block_size + + sector_in_block * SECTOR_SIZE; + return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset; } static int vdi_co_read(BlockDriverState *bs, |