[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/28] qcow2: make is_allocated return true for zero
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 15/28] qcow2: make is_allocated return true for zero clusters |
Date: |
Fri, 15 Mar 2013 16:14:12 +0100 |
From: Paolo Bonzini <address@hidden>
Otherwise, live migration of the top layer will miss zero clusters and
let the backing file show through. This also matches what is done in qed.
QCOW2_CLUSTER_ZERO clusters are invalid in v2 image files. Check this
directly in qcow2_get_cluster_offset instead of replicating the test
everywhere.
Cc: address@hidden
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/qcow2-cluster.c | 3 +++
block/qcow2.c | 6 +-----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index ff9ae18..d72d063 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -454,6 +454,9 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t
offset,
*cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK;
break;
case QCOW2_CLUSTER_ZERO:
+ if (s->qcow_version < 3) {
+ return -EIO;
+ }
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0,
QCOW_OFLAG_COMPRESSED | QCOW_OFLAG_ZERO);
diff --git a/block/qcow2.c b/block/qcow2.c
index ad43a13..1f99866 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -621,7 +621,7 @@ static int coroutine_fn
qcow2_co_is_allocated(BlockDriverState *bs,
*pnum = 0;
}
- return (cluster_offset != 0);
+ return (cluster_offset != 0) || (ret == QCOW2_CLUSTER_ZERO);
}
/* handle reading after the end of the backing file */
@@ -702,10 +702,6 @@ static coroutine_fn int qcow2_co_readv(BlockDriverState
*bs, int64_t sector_num,
break;
case QCOW2_CLUSTER_ZERO:
- if (s->qcow_version < 3) {
- ret = -EIO;
- goto fail;
- }
qemu_iovec_memset(&hd_qiov, 0, 0, 512 * cur_nr_sectors);
break;
--
1.8.1.4
- [Qemu-devel] [PATCH 02/28] block: Add options QDict to bdrv_open() prototype, (continued)
- [Qemu-devel] [PATCH 02/28] block: Add options QDict to bdrv_open() prototype, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 01/28] block: Add options QDict to .bdrv_open(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 10/28] qcow2: flush refcount cache correctly in qcow2_write_snapshots(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 11/28] qcow2: set L2 cache dependency in qcow2_alloc_bytes(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 09/28] qcow2: flush refcount cache correctly in alloc_refcount_block(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 07/28] block: Support driver specific options in drive_init(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 14/28] qcow2: drop unnecessary flush in qcow2_update_snapshot_refcount(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 06/28] blockdev: Keep a copy of DriveInfo.serial, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 12/28] qcow2: flush in qcow2_update_snapshot_refcount(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 13/28] qcow2: drop flush in update_cluster_refcount(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 15/28] qcow2: make is_allocated return true for zero clusters,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 16/28] sheepdog: use non-blocking fd in coroutine context, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 17/28] sheepdog: set io_flush handler in do_co_req, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 19/28] threadpool: move globals into struct ThreadPool, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 20/28] threadpool: add thread_pool_new() and thread_pool_free(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 22/28] block: add bdrv_get_aio_context(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 18/28] main-loop: add qemu_get_aio_context(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 21/28] aio: add a ThreadPool instance to AioContext, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 24/28] coroutine: use AioContext for CoQueue BH, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 25/28] dataplane: fix hang introduced by AioContext transition, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 26/28] qemu-iotests: add tests for rebasing zero clusters, Stefan Hajnoczi, 2013/03/15