Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1373545

Summary: Support of discard/fstrim
Product: Red Hat Enterprise Linux 7 Reporter: Pablo Iranzo Gómez <pablo.iranzo>
Component: qemu-kvmAssignee: Ademar Reis <areis>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: chayang, juzhang, knoel, kwolf, qizhu, rbalakri, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-30 14:16:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1203710    

Description Pablo Iranzo Gómez 2016-09-06 14:46:21 UTC
Description of problem:

While trying to create images for usage with 'packer' for a cloud environment, it has been found  tha the RHEL-base included KVM packages doesn't include the machine types that support discard/fstrim.

Updated machine types, like it was done on BZ 1229666 could help here.

Comment 3 Ademar Reis 2016-09-30 14:16:01 UTC
The discussion about machine types is a red herring.

Clarifying:

 - Discard/TRIM support was enabled by default in QEMU-1.5 upstream
 - Downstream, we ship QEMU-1.5.3 with RHEL-7.2
 - Which means yes, Discard/TRIM should work. The test-case verification is
   supposed to be simple: in the host, create the qcow2 (or even raw) image
   on a filesystem that supports sparse files (ext4 and xfs should both work);
   start a guest with this image and mount the fs with discard=on, then
   delete some files; the image size (space ocupied in the host fs) should
   decrease.

If this is not working, then we have a Bug somewhere. I haven't confirmed this personally because I don't have the setup ready.

Machine types enable the DISCARD feature, but this detail is only relevant if the VM is using an old machine-type (from RHEL6, for example, the VM was migrated from there or is reusing some old configuration).

Please *always* inform the qemu command line (from ps -auxw or from the libvirt logs) so we can understand what's being used.

Comment 4 Kevin Wolf 2016-09-30 15:01:57 UTC
(In reply to Ademar Reis from comment #3)
>  - Which means yes, Discard/TRIM should work. The test-case verification is
>    supposed to be simple: in the host, create the qcow2 (or even raw) image
>    on a filesystem that supports sparse files (ext4 and xfs should both
> work);
>    start a guest with this image and mount the fs with discard=on, then
>    delete some files; the image size (space ocupied in the host fs) should
>    decrease.

Please also make sure that discard='unmap' is set for the disk in the libvirt
XML so that the feature is actually enabled and discards don't get ignored.