It'd be handy if virt-install made it easy to enable QEMU's underlying discard capability (-drive discard=unmap). The rationale for this is that at the end of installation of a VM, the kickstart script could then call fstrim, which would then minimise the size of the resulting VM image on disk.
Created attachment 890154 [details] example patch to implement requested functionality
Thanks for the patch Jim! @@ -830,6 +835,8 @@ class VirtualDisk(VirtualDevice): # be nice if qemu did this for us but that time has long passed. if not self.driver_cache: self.driver_cache = self.CACHE_MODE_NONE + if not self.driver_discard: + self.driver_discard = self.DRIVER_MODE_IGNORE if not self.driver_io: self.driver_io = self.IO_MODE_NATIVE This bit is unnecessary, we should just differ to the qemu default here (which is ignore AFAIK). I dropped that bit and added some test cases, and push the patch: commit 764063dfe92111d93a0bbd17cf3d1f26312c01c9 Author: Jim Minter <jminter> Date: Tue Apr 29 10:29:33 2014 -0400 virt-install --disk discard= support