qcow2: Use offset_into_cluster()
There's a couple of places left in the qcow2 code that still do the calculation manually, so let's replace them. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
4688c4e32e
commit
74e60fb56a
|
@ -367,7 +367,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitmaps_ext.bitmap_directory_offset & (s->cluster_size - 1)) {
|
if (offset_into_cluster(s, bitmaps_ext.bitmap_directory_offset)) {
|
||||||
error_setg(errp, "bitmaps_ext: "
|
error_setg(errp, "bitmaps_ext: "
|
||||||
"invalid bitmap directory offset");
|
"invalid bitmap directory offset");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -1959,9 +1959,8 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
|
||||||
{
|
{
|
||||||
BDRVQcow2State *s = bs->opaque;
|
BDRVQcow2State *s = bs->opaque;
|
||||||
uint64_t cluster_offset;
|
uint64_t cluster_offset;
|
||||||
int index_in_cluster, ret;
|
|
||||||
unsigned int bytes;
|
unsigned int bytes;
|
||||||
int status = 0;
|
int ret, status = 0;
|
||||||
|
|
||||||
qemu_co_mutex_lock(&s->lock);
|
qemu_co_mutex_lock(&s->lock);
|
||||||
|
|
||||||
|
@ -1982,8 +1981,7 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
|
||||||
|
|
||||||
if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) &&
|
if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) &&
|
||||||
!s->crypto) {
|
!s->crypto) {
|
||||||
index_in_cluster = offset & (s->cluster_size - 1);
|
*map = cluster_offset | offset_into_cluster(s, offset);
|
||||||
*map = cluster_offset | index_in_cluster;
|
|
||||||
*file = s->data_file->bs;
|
*file = s->data_file->bs;
|
||||||
status |= BDRV_BLOCK_OFFSET_VALID;
|
status |= BDRV_BLOCK_OFFSET_VALID;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue