summaryrefslogtreecommitdiffstats
path: root/tests/qemu-iotests/046
diff options
context:
space:
mode:
authorAlberto Garcia2020-03-31 13:43:45 +0200
committerMax Reitz2020-04-07 13:51:09 +0200
commit80f5c01183597b075157eb7bedbcb8691f8fa1d1 (patch)
treee1716cf4029012456fe1a8acb64de45302e26a12 /tests/qemu-iotests/046
parentMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20200406'... (diff)
downloadqemu-80f5c01183597b075157eb7bedbcb8691f8fa1d1.tar.gz
qemu-80f5c01183597b075157eb7bedbcb8691f8fa1d1.tar.xz
qemu-80f5c01183597b075157eb7bedbcb8691f8fa1d1.zip
qcow2: Forbid discard in qcow2 v2 images with backing files
A discard request deallocates the selected clusters so they read back as zeroes. This is done by clearing the cluster offset field and setting QCOW_OFLAG_ZERO in the L2 entry. This flag is however only supported when qcow_version >= 3. In older images the cluster is simply deallocated, exposing any possible stale data from the backing file. Since discard is an advisory operation it's safer to simply forbid it in this scenario. Note that we are adding this check to qcow2_co_pdiscard() and not to qcow2_cluster_discard() or discard_in_l2_slice() because the last two are also used by qcow2_snapshot_create() to discard the clusters used by the VM state. In this case there's no risk of exposing stale data to the guest and we really want that the clusters are always discarded. Signed-off-by: Alberto Garcia <berto@igalia.com> Message-Id: <20200331114345.29993-1-berto@igalia.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/046')
-rwxr-xr-xtests/qemu-iotests/04610
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046
index a066eec605..ecbe5fc0f4 100755
--- a/tests/qemu-iotests/046
+++ b/tests/qemu-iotests/046
@@ -193,8 +193,8 @@ echo "== Verify image content =="
verify_io()
{
if ($QEMU_IMG info -U -f "$IMGFMT" "$TEST_IMG" | grep "compat: 0.10" > /dev/null); then
- # For v2 images, discarded clusters are read from the backing file
- # Keep the variable empty so that the backing file value can be used as
+ # In v2 images clusters are not discarded when there is a backing file.
+ # Keep the variable empty so that the previous value can be used as
# the default below
discarded=
else
@@ -230,14 +230,16 @@ verify_io()
echo read -P 70 0x78000 0x6000
echo read -P 7 0x7e000 0x2000
- echo read -P ${discarded:-8} 0x80000 0x6000
+ echo read -P ${discarded:-89} 0x80000 0x1000
+ echo read -P ${discarded:-8} 0x81000 0x5000
echo read -P 80 0x86000 0x2000
echo read -P ${discarded:-8} 0x88000 0x2000
echo read -P 81 0x8a000 0xe000
echo read -P 90 0x98000 0x6000
echo read -P 9 0x9e000 0x2000
- echo read -P ${discarded:-10} 0xa0000 0x6000
+ echo read -P ${discarded:-109} 0xa0000 0x1000
+ echo read -P ${discarded:-10} 0xa1000 0x5000
echo read -P 100 0xa6000 0x2000
echo read -P ${discarded:-10} 0xa8000 0x2000
echo read -P 101 0xaa000 0xe000