Bug 1091516

Summary: RFE: enable underlying QEMU discard support in virt-install
Product: [Community] Virtualization Tools Reporter: Jim Minter <jminter>
Component: virt-managerAssignee: Cole Robinson <crobinso>
Status: CLOSED UPSTREAM QA Contact:
Severity: low Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: acathrow, berrange, crobinso, gscrivan
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-29 14:38:48 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:
Attachments:
Description Flags
example patch to implement requested functionality none

Description Jim Minter 2014-04-25 19:21:00 UTC
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.

Comment 1 Jim Minter 2014-04-27 07:12:54 UTC
Created attachment 890154 [details]
example patch to implement requested functionality

Comment 2 Cole Robinson 2014-04-29 14:38:48 UTC
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