[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 28/42] block: make bdrv_has_zero_init return false fo
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 28/42] block: make bdrv_has_zero_init return false for copy-on-write-images |
Date: |
Fri, 6 Sep 2013 17:38:59 +0200 |
From: Paolo Bonzini <address@hidden>
This helps implementing is_allocated on top of get_block_status.
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block.c | 5 +++++
qemu-img.c | 9 +--------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/block.c b/block.c
index 5df17de..2a90893 100644
--- a/block.c
+++ b/block.c
@@ -3031,6 +3031,11 @@ int bdrv_has_zero_init(BlockDriverState *bs)
{
assert(bs->drv);
+ /* If BS is a copy on write image, it is initialized to
+ the contents of the base image, which may not be zeroes. */
+ if (bs->backing_hd) {
+ return 0;
+ }
if (bs->drv->bdrv_has_zero_init) {
return bs->drv->bdrv_has_zero_init(bs);
}
diff --git a/qemu-img.c b/qemu-img.c
index 5cc579d..b074fa7 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1537,14 +1537,7 @@ static int img_convert(int argc, char **argv)
should add a specific call to have the info to go faster */
buf1 = buf;
while (n > 0) {
- /* If the output image is being created as a copy on write
image,
- copy all sectors even the ones containing only NUL bytes,
- because they may differ from the sectors in the base image.
-
- If the output is to a host device, we also write out
- sectors that are entirely 0, since whatever data was
- already there is garbage, not 0s. */
- if (!has_zero_init || out_baseimg ||
+ if (!has_zero_init ||
is_allocated_sectors_min(buf1, n, &n1, min_sparse)) {
ret = bdrv_write(out_bs, sector_num, buf1, n1);
if (ret < 0) {
--
1.8.3.1
- [Qemu-devel] [PULL 08/42] w32: Fix access to host devices (regression), (continued)
- [Qemu-devel] [PULL 08/42] w32: Fix access to host devices (regression), Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 07/42] add qemu-img convert -n option (skip target volume creation), Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 10/42] vvfat: use bdrv_new() to allocate BlockDriverState, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 09/42] aio / timers: fix build of test/test-aio.c on non-linux platforms, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 11/42] iscsi: use bdrv_new() instead of stack structure, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 12/42] block: implement reference count for BlockDriverState, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 13/42] block: make bdrv_delete() static, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 14/42] migration: omit drive ref as we have bdrv_ref now, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 15/42] xen_disk: simplify blk_disconnect with refcnt, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 27/42] qemu-img: always probe the input image for allocated sectors, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 28/42] block: make bdrv_has_zero_init return false for copy-on-write-images,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 29/42] block: introduce bdrv_get_block_status API, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 31/42] block: return get_block_status data and flags for formats, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 30/42] block: define get_block_status return value, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 32/42] block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 33/42] block: return BDRV_BLOCK_ZERO past end of backing file, Stefan Hajnoczi, 2013/09/06