[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 43/48] vmdk: Fix calculation of block status's offset
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 43/48] vmdk: Fix calculation of block status's offset |
Date: |
Fri, 29 Jan 2016 18:37:49 +0100 |
From: Fam Zheng <address@hidden>
"offset" is the offset of cluster and sector_num doesn't necessarily
refer to the start of it, it should add index_in_cluster.
Signed-off-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/vmdk.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 109fd5f..9d5a18a 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1278,6 +1278,7 @@ static int64_t coroutine_fn
vmdk_co_get_block_status(BlockDriverState *bs,
0, 0);
qemu_co_mutex_unlock(&s->lock);
+ index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);
switch (ret) {
case VMDK_ERROR:
ret = -EIO;
@@ -1291,13 +1292,14 @@ static int64_t coroutine_fn
vmdk_co_get_block_status(BlockDriverState *bs,
case VMDK_OK:
ret = BDRV_BLOCK_DATA;
if (extent->file == bs->file && !extent->compressed) {
- ret |= BDRV_BLOCK_OFFSET_VALID | offset;
+ ret |= BDRV_BLOCK_OFFSET_VALID;
+ ret |= (offset + (index_in_cluster << BDRV_SECTOR_BITS))
+ & BDRV_BLOCK_OFFSET_MASK;
}
break;
}
- index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);
n = extent->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
--
1.8.3.1
- [Qemu-devel] [PULL 36/48] raw: Assign bs to file in raw_co_get_block_status, (continued)
- [Qemu-devel] [PULL 36/48] raw: Assign bs to file in raw_co_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 41/48] vdi: Assign bs->file->bs to file in vdi_co_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 28/48] block: Add blk_remove_all_bs(), Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 40/48] sheepdog: Assign bs to file in sd_co_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 38/48] parallels: Assign bs->file->bs to file in parallels_co_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 42/48] vpc: Assign bs->file->bs to file in vpc_co_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 44/48] vmdk: Return extent's file in bdrv_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 33/48] block: Add "file" output parameter to block status query functions, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 31/48] iotests: Add test for block jobs and BDS ejection, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 47/48] qemu-img: Make MapEntry a QAPI struct, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 43/48] vmdk: Fix calculation of block status's offset,
Kevin Wolf <=
- [Qemu-devel] [PULL 46/48] qemu-img: In "map", use the returned "file" from bdrv_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 48/48] iotests: Add "qemu-img map" test for VMDK extents, Kevin Wolf, 2016/01/29
- [Qemu-devel] [PULL 45/48] block: Use returned *file in bdrv_co_get_block_status, Kevin Wolf, 2016/01/29
- Re: [Qemu-devel] [PULL 00/48] Block patches, Peter Maydell, 2016/01/29