diff options
author | Alberto Garcia <berto@igalia.com> | 2020-10-26 17:58:26 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2020-10-27 15:26:20 +0100 |
commit | d40f4a565aa64a1ef1e1ff73caf53d61cac9a67f (patch) | |
tree | 671c8523f8863d8719707f9cd225f94cf65cba31 /block/io.c | |
parent | 0c8c4895a6a54ffb7209402b183297c80c868873 (diff) | |
download | qemu-d40f4a565aa64a1ef1e1ff73caf53d61cac9a67f.zip qemu-d40f4a565aa64a1ef1e1ff73caf53d61cac9a67f.tar.gz qemu-d40f4a565aa64a1ef1e1ff73caf53d61cac9a67f.tar.bz2 |
qcow2: Report BDRV_BLOCK_ZERO more accurately in bdrv_co_block_status()
If a BlockDriverState supports backing files but has none then any
unallocated area reads back as zeroes.
bdrv_co_block_status() is only reporting this is if want_zero is true,
but this is an inexpensive test and there is no reason not to do it in
all cases.
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <66fa0914a0e2b727ab6d1b63ca773d7cd29a9a9e.1603731354.git.berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/io.c')
-rw-r--r-- | block/io.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -2282,17 +2282,17 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs, if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { ret |= BDRV_BLOCK_ALLOCATED; - } else if (want_zero && bs->drv->supports_backing) { + } else if (bs->drv->supports_backing) { BlockDriverState *cow_bs = bdrv_cow_bs(bs); - if (cow_bs) { + if (!cow_bs) { + ret |= BDRV_BLOCK_ZERO; + } else if (want_zero) { int64_t size2 = bdrv_getlength(cow_bs); if (size2 >= 0 && offset >= size2) { ret |= BDRV_BLOCK_ZERO; } - } else { - ret |= BDRV_BLOCK_ZERO; } } |