Hide Forgot
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.
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.
(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.