On 30.03.20 12:05, Max Reitz wrote: > On 27.03.20 19:59, Alberto Garcia wrote: >> 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 <be...@igalia.com> >> --- >> v4: >> - Show output of qemu-img map when there's no backing file [Eric] >> >> v3: >> - Rebase and change iotest number >> - Show output of qemu-img map in iotest 290 [Kevin] >> - Use the l2_offset and rb_offset variables in iotest 060 >> >> v2: >> >> - Don't create the image with compat=0.10 in iotest 060 [Max] >> - Use $TEST_IMG.base for the backing image name in iotest 289 [Max] >> - Add list of unsupported options to iotest 289 [Max] >> >> block/qcow2.c | 6 +++ >> tests/qemu-iotests/060 | 12 ++--- >> tests/qemu-iotests/060.out | 2 - >> tests/qemu-iotests/290 | 97 ++++++++++++++++++++++++++++++++++++++ >> tests/qemu-iotests/290.out | 61 ++++++++++++++++++++++++ >> tests/qemu-iotests/group | 1 + >> 6 files changed, 170 insertions(+), 9 deletions(-) >> create mode 100755 tests/qemu-iotests/290 >> create mode 100644 tests/qemu-iotests/290.out > > Thanks, applied to my block branch: > > https://git.xanclic.moe/XanClic/qemu/commits/branch/block
I’ll have to dequeue it again, because it breaks iotests 046 and 177 (both of which already have special handling for v2-specific discard; but it needs to be adjusted now that the discard operation no longer reveals the backing file contents). Max
signature.asc
Description: OpenPGP digital signature