[PATCH 0/2] qemu: block: Pass discard requests through the copy-on-read block filter (for 7.6?)

See 1/2 Peter Krempa (2): qemu: block: Pass discard requests through the copy-on-read block filter NEWS: Mention fix for 'copy_on_read' disks with trimming enabled NEWS.rst | 6 ++++++ src/qemu/qemu_block.c | 1 + tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) -- 2.31.1

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> --- src/qemu/qemu_block.c | 1 + tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 1610f72d07..4691dff4f7 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -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; diff --git a/tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args b/tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args index 93d3a06c88..690d4f3ea1 100644 --- a/tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args @@ -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"}' \ -- 2.31.1

On Wed, Jul 28, 2021 at 09:51:38AM +0200, Peter Krempa wrote:
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> --- src/qemu/qemu_block.c | 1 + tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 618f478b81..b4adde9f82 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -46,6 +46,12 @@ v7.6.0 (unreleased) in the top layer. The intention was to emit two events only when the original registration was done without the index. + * qemu: Pass discard requests for disks with ``copy_on_read='on'`` + + When a disk using the ``copy_on_read='on'`` option is configured also with + ``discard='unmap'`` the discard requests will now be passed to the + underlying image freeing up the space. + v7.5.0 (2021-07-01) =================== -- 2.31.1

On Wed, Jul 28, 2021 at 09:51:39AM +0200, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 7/28/21 9:51 AM, Peter Krempa wrote:
See 1/2
Peter Krempa (2): qemu: block: Pass discard requests through the copy-on-read block filter NEWS: Mention fix for 'copy_on_read' disks with trimming enabled
NEWS.rst | 6 ++++++ src/qemu/qemu_block.c | 1 + tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-)
Yes, I think this is 7.6 material. It's a bug fix after all and those are 'safe for freeze' even without explicit statement. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal

On Wed, Jul 28, 2021 at 09:51:37AM +0200, Peter Krempa wrote:
See 1/2
Peter Krempa (2): qemu: block: Pass discard requests through the copy-on-read block filter NEWS: Mention fix for 'copy_on_read' disks with trimming enabled
NEWS.rst | 6 ++++++ src/qemu/qemu_block.c | 1 + tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-)
Reviewed-by: Richard W.M. Jones <rjones@redhat.com> Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
participants (4)
-
Daniel P. Berrangé
-
Michal Prívozník
-
Peter Krempa
-
Richard W.M. Jones