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:
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.