Adding Trim/Unmap support for libvirt / ceph
diff --git a/README.rst b/README.rst
index d6d5dd8..dd27877 100644
--- a/README.rst
+++ b/README.rst
@@ -353,6 +353,24 @@
       # Then add your custom filter on the end (make sure to include all other ones that you need as well)
       scheduler_default_filters: "DifferentHostFilter,RetryFilter,AvailabilityZoneFilter,RamFilter,CoreFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,PciPassthroughFilter,MyCustomFilter"
 
+Hardware Trip/Unmap Support
+---------------------------
+
+To enable TRIM support for ephemeral images (thru nova managed images), libvirt has this option.
+
+.. code-block:: yaml
+
+  nova:
+    compute:
+      libvirt:
+        hw_disk_discard: unmap
+
+In order to actually utilize this feature, the following metadata must be set on the image as well, so the SCSI unmap is supported.
+
+.. code-block:: bash
+
+  glance image-update --property hw_scsi_model=virtio-scsi <image>
+  glance image-update --property hw_disk_bus=scsi <image>
 
 Documentation and Bugs
 ======================
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index 33ccb4a..ba9a0f0 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -126,6 +126,9 @@
 libvirt_inject_password=false
 libvirt_inject_key=false
 {%- endif %}
+{%- if compute.libvirt.hw_disk_discard is defined %}
+hw_disk_discard={{ compute.libvirt.hw_disk_discard }}
+{%- endif %}
 
 {%- if compute.get('libvirt', {}).uri is defined %}
 connection_uri={{ compute.libvirt.uri }}
diff --git a/nova/files/newton/nova-compute.conf.Debian b/nova/files/newton/nova-compute.conf.Debian
index b0ce077..f49529f 100644
--- a/nova/files/newton/nova-compute.conf.Debian
+++ b/nova/files/newton/nova-compute.conf.Debian
@@ -140,6 +140,9 @@
 libvirt_inject_password=false
 libvirt_inject_key=false
 {%- endif %}
+{%- if compute.libvirt.hw_disk_discard is defined %}
+hw_disk_discard={{ compute.libvirt.hw_disk_discard }}
+{%- endif %}
 
 {%- if compute.get('libvirt', {}).uri is defined %}
 connection_uri={{ compute.libvirt.uri }}
diff --git a/nova/files/ocata/nova-compute.conf.Debian b/nova/files/ocata/nova-compute.conf.Debian
index 7039384..e4ba25e 100644
--- a/nova/files/ocata/nova-compute.conf.Debian
+++ b/nova/files/ocata/nova-compute.conf.Debian
@@ -6482,6 +6482,9 @@
 #  (string value)
 # Allowed values: ignore, unmap
 #hw_disk_discard=<None>
+{%- if compute.libvirt.hw_disk_discard is defined %}
+hw_disk_discard={{ compute.libvirt.hw_disk_discard }}
+{%- endif %}
 
 # DEPRECATED: Allows image information files to be stored in non-standard
 # locations (string value)
diff --git a/tests/pillar/compute_cluster.sls b/tests/pillar/compute_cluster.sls
index bd61ecc..c3a2485 100644
--- a/tests/pillar/compute_cluster.sls
+++ b/tests/pillar/compute_cluster.sls
@@ -64,3 +64,5 @@
         port: 11211
       - host: 127.0.2.1
         port: 11211
+    libvirt:
+      hw_disk_discard: unmap