[PATCH] qemu: block: Always enable discard forwarding for 'throttle' filter layer

Peter Krempa via Devel posted 1 patch 1 day, 18 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/f5cf91eb25ff5fa4a5014d9fc7baf9875dcaff64.1757060034.git.pkrempa@redhat.com
src/qemu/qemu_block.c                                  |  1 +
.../qemuxmlconfdata/throttlefilter.x86_64-latest.args  | 10 +++++-----
2 files changed, 6 insertions(+), 5 deletions(-)
[PATCH] qemu: block: Always enable discard forwarding for 'throttle' filter layer
Posted by Peter Krempa via Devel 1 day, 18 hours ago
From: Peter Krempa <pkrempa@redhat.com>

Discards ought to be forwarded to the protocol nodes where we control
if discard actually happens.

Unconditionally enable discard='unmap' for the intermediate layer.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/810
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_block.c                                  |  1 +
 .../qemuxmlconfdata/throttlefilter.x86_64-latest.args  | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index daefeb2f45..194f8407e3 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -2751,6 +2751,7 @@ qemuBlockThrottleFilterGetProps(virDomainThrottleFilterDef *filter,
                               "s:node-name", qemuBlockThrottleFilterGetNodename(filter),
                               "s:throttle-group", prefixed_group_name,
                               "s:file", parentNodeName,
+                              "s:discard", "unmap",
                               NULL) < 0)
         return NULL;

diff --git a/tests/qemuxmlconfdata/throttlefilter.x86_64-latest.args b/tests/qemuxmlconfdata/throttlefilter.x86_64-latest.args
index 6a37f5835a..95914ef5ce 100644
--- a/tests/qemuxmlconfdata/throttlefilter.x86_64-latest.args
+++ b/tests/qemuxmlconfdata/throttlefilter.x86_64-latest.args
@@ -34,18 +34,18 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
 -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-8-storage","auto-read-only":true,"discard":"unmap","cache":{"direct":true,"no-flush":false}}' \
 -blockdev '{"node-name":"libvirt-8-format","read-only":false,"cache":{"direct":true,"no-flush":false},"driver":"qcow2","file":"libvirt-8-storage"}' \
--blockdev '{"driver":"throttle","node-name":"libvirt-9-filter","throttle-group":"throttle-limit0","file":"libvirt-8-format"}' \
+-blockdev '{"driver":"throttle","node-name":"libvirt-9-filter","throttle-group":"throttle-limit0","file":"libvirt-8-format","discard":"unmap"}' \
 -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"libvirt-9-filter","id":"virtio-disk0","bootindex":1,"write-cache":"on"}' \
 -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest2","node-name":"libvirt-5-storage","auto-read-only":true,"discard":"unmap","cache":{"direct":true,"no-flush":false}}' \
 -blockdev '{"node-name":"libvirt-5-format","read-only":false,"cache":{"direct":true,"no-flush":false},"driver":"qcow2","file":"libvirt-5-storage"}' \
--blockdev '{"driver":"throttle","node-name":"libvirt-6-filter","throttle-group":"throttle-limit1","file":"libvirt-5-format"}' \
--blockdev '{"driver":"throttle","node-name":"libvirt-7-filter","throttle-group":"throttle-limit12","file":"libvirt-6-filter"}' \
+-blockdev '{"driver":"throttle","node-name":"libvirt-6-filter","throttle-group":"throttle-limit1","file":"libvirt-5-format","discard":"unmap"}' \
+-blockdev '{"driver":"throttle","node-name":"libvirt-7-filter","throttle-group":"throttle-limit12","file":"libvirt-6-filter","discard":"unmap"}' \
 -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"libvirt-7-filter","id":"virtio-disk1","write-cache":"on"}' \
 -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest3","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap","cache":{"direct":true,"no-flush":false}}' \
 -blockdev '{"node-name":"libvirt-2-format","read-only":false,"cache":{"direct":true,"no-flush":false},"driver":"qcow2","file":"libvirt-2-storage"}' \
 -blockdev '{"driver":"copy-on-read","node-name":"libvirt-CoR-vdc","file":"libvirt-2-format","discard":"unmap"}' \
--blockdev '{"driver":"throttle","node-name":"libvirt-3-filter","throttle-group":"throttle-limit2","file":"libvirt-CoR-vdc"}' \
--blockdev '{"driver":"throttle","node-name":"libvirt-4-filter","throttle-group":"throttle-limit12","file":"libvirt-3-filter"}' \
+-blockdev '{"driver":"throttle","node-name":"libvirt-3-filter","throttle-group":"throttle-limit2","file":"libvirt-CoR-vdc","discard":"unmap"}' \
+-blockdev '{"driver":"throttle","node-name":"libvirt-4-filter","throttle-group":"throttle-limit12","file":"libvirt-3-filter","discard":"unmap"}' \
 -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"libvirt-4-filter","id":"virtio-disk2","write-cache":"on"}' \
 -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest4","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap","cache":{"direct":true,"no-flush":false}}' \
 -blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"direct":true,"no-flush":false},"driver":"qcow2","file":"libvirt-1-storage"}' \
-- 
2.51.0