]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: block: Pass discard requests through the copy-on-read block filter
authorPeter Krempa <pkrempa@redhat.com>
Tue, 27 Jul 2021 17:12:09 +0000 (19:12 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 28 Jul 2021 13:18:18 +0000 (15:18 +0200)
We need to pass the 'trim' requests through the copy-on-read filter so
if a user configures a discard policy on the disk the requests get
through to the appropriate format layer in the blockdev tree.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1986509
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
src/qemu/qemu_block.c
tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args

index 1610f72d07aaacf2b845fd947872f0cf39b22a3a..4691dff4f730977eb2080e593e8bdd5c0507ab89 100644 (file)
@@ -2157,6 +2157,7 @@ qemuBlockStorageGetCopyOnReadProps(virDomainDiskDef *disk)
                                           "s:driver", "copy-on-read",
                                           "s:node-name", priv->nodeCopyOnRead,
                                           "s:file", disk->src->nodeformat,
+                                          "s:discard", "unmap",
                                           NULL));
 
     return ret;
index 93d3a06c884e68b139566e59f4b4a523a6947d1a..690d4f3ea1e5e6171e8ff10e320b8512f53a1ffa 100644 (file)
@@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-test/.config \
 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \
 -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/f14.img","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"qcow2","file":"libvirt-2-storage"}' \
--blockdev '{"driver":"copy-on-read","node-name":"libvirt-CoR-vda","file":"libvirt-2-format"}' \
+-blockdev '{"driver":"copy-on-read","node-name":"libvirt-CoR-vda","file":"libvirt-2-format","discard":"unmap"}' \
 -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=libvirt-CoR-vda,id=virtio-disk0,bootindex=2 \
 -blockdev '{"driver":"file","filename":"/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-1-format","read-only":true,"driver":"raw","file":"libvirt-1-storage"}' \