Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1986509 - libvirt does not pass discard flag to copy-on-read blockdev layers
Summary: libvirt does not pass discard flag to copy-on-read blockdev layers
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: beta
: ---
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks: TRACKER-bugs-affecting-libguestfs
TreeView+ depends on / blocked
 
Reported: 2021-07-27 17:42 UTC by Richard W.M. Jones
Modified: 2021-12-07 22:01 UTC (History)
7 users (show)

Fixed In Version: libvirt-7.6.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-12-07 21:57:54 UTC
Type: Bug
Target Upstream Version: 7.6.0
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2021-07-27 17:42:23 UTC
Description of problem:

The long description is here:
https://listman.redhat.com/archives/libguestfs/2021-July/msg00067.html

The short description is: When we use the copy_on_read="on"
and discard="unmap" attributes together on a <disk/> element,
libvirt does not set up blockdev correctly, so the unmap
flag is dropped.  This results in trim messages being
dropped in the copy-on-read layer.

Version-Release number of selected component (if applicable):

libvirt-7.5.0-1.el9

How reproducible:

100%

Steps to Reproduce:

See https://listman.redhat.com/archives/libguestfs/2021-July/msg00067.html
for a full reproducer.

Peter has suggested this patch to libvirt:
https://gitlab.com/pipo.sk/libvirt/-/commit/13d30ec012b258105678356e504c0f5e79881956

I tested Peter's patch and it works for me.

Comment 1 Richard W.M. Jones 2021-07-28 09:41:19 UTC
Upstream fix:
https://listman.redhat.com/archives/libvir-list/2021-July/thread.html#00823

Comment 2 Peter Krempa 2021-07-28 13:22:05 UTC
Fixed upstream:

commit dc0b9c8376afb88eb3a3156d7e991d29d9c196a8
Author: Peter Krempa <pkrempa>
Date:   Tue Jul 27 19:12:09 2021 +0200

    qemu: block: Pass discard requests through the copy-on-read block filter
    
    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>
    Tested-by: Richard W.M. Jones <rjones>
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Daniel P. Berrangé <berrange>
    Reviewed-by: Michal Privoznik <mprivozn>
    Reviewed-by: Richard W.M. Jones <rjones>

v7.6.0-rc1-4-gdc0b9c8376

Comment 3 Han Han 2021-08-02 02:24:41 UTC
Reproduced on libvirt-7.5.0-1.module+el8.5.0+11664+59f87560.x86_64:
For an VM with XML:
<domain>
...
  <disk>
  ...
      <driver name='qemu' type='qcow2' copy_on_read='on' discard='unmap'/>
  ...
  </disk>
...
</domain>


Extract its qemu cmdline by `virsh domxml-to-native --domain VM qemu-argv`
The qemu cmdline of -blockdev is:
-blockdev '{"driver":"gluster","volume":"gv0","path":"hhan.qcow2","server":[{"type":"inet","host":"10.0.148.14","port":"24007"}],"debug":4,"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' -blockdev '{"node-name":"libvirt-1-format","read-only":false,"discard":"unmap","driver":"qcow2","file":"libvirt-1-storage"}' -blockdev '{"driver":"copy-on-read","node-name":"libvirt-CoR-vda","file":"libvirt-1-format"}'

The "discard":"unmap" is not in the copy-on-read layer.


The libvirt upstream has covered this unit test.

Comment 6 Han Han 2021-08-23 02:11:50 UTC
Tested on libvirt-7.6.0-2.el9.x86_64 as comment3:
Results:
-blockdev {"node-name":"libvirt-1-format","read-only":false,"discard":"unmap","driver":"qcow2","file":"libvirt-1-storage","backing":null} -blockdev {"driver":"copy-on-read","node-name":"libvirt-CoR-sda","file":"libvirt-1-format","discard":"unmap"}

"discard":"unmap" is in copy-on-read blockdev node.


Note You need to log in before you can comment on or make changes to this bug.