diff options
Diffstat (limited to 'block/qcow2.c')
-rw-r--r-- | block/qcow2.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index 71f870d829..66ca12f94e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -799,7 +799,7 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, } ret = qcow2_alloc_cluster_offset(bs, sector_num << 9, - index_in_cluster, n_end, &cur_nr_sectors, l2meta); + index_in_cluster, n_end, &cur_nr_sectors, &cluster_offset, l2meta); if (ret < 0) { goto fail; } @@ -809,7 +809,6 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, qcow2_mark_dirty(bs); } - cluster_offset = l2meta->cluster_offset; assert((cluster_offset & 511) == 0); qemu_iovec_reset(&hd_qiov); @@ -1132,6 +1131,7 @@ static int preallocate(BlockDriverState *bs) { uint64_t nb_sectors; uint64_t offset; + uint64_t host_offset = 0; int num; int ret; QCowL2Meta meta; @@ -1139,18 +1139,18 @@ static int preallocate(BlockDriverState *bs) nb_sectors = bdrv_getlength(bs) >> 9; offset = 0; qemu_co_queue_init(&meta.dependent_requests); - meta.cluster_offset = 0; while (nb_sectors) { num = MIN(nb_sectors, INT_MAX >> 9); - ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta); + ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, + &host_offset, &meta); if (ret < 0) { return ret; } ret = qcow2_alloc_cluster_link_l2(bs, &meta); if (ret < 0) { - qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters); + qcow2_free_any_clusters(bs, meta.alloc_offset, meta.nb_clusters); return ret; } @@ -1169,10 +1169,10 @@ static int preallocate(BlockDriverState *bs) * all of the allocated clusters (otherwise we get failing reads after * EOF). Extend the image to the last allocated sector. */ - if (meta.cluster_offset != 0) { + if (host_offset != 0) { uint8_t buf[512]; memset(buf, 0, 512); - ret = bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1); + ret = bdrv_write(bs->file, (host_offset >> 9) + num - 1, buf, 1); if (ret < 0) { return ret; } |