qemu: Support discard for disk

QEMU introduced "discard" option for drive since commit a9384aff53,

<...>
@var{discard} is one of "ignore" (or "off") or "unmap" (or "on") and
controls whether @dfn{discard} (also known as @dfn{trim} or @dfn{unmap})
requests are ignored or passed to the filesystem.  Some machine types
may not support discard requests.
</...>

This patch exposes the support in libvirt.

QEMU supported "discard" for "-drive" since v1.5.0-rc0:

% git tag --contains a9384aff53
contains
v1.5.0-rc0
v1.5.0-rc1

So this only detects the capability bit using virQEMUCapsProbeQMPCommandLine.
This commit is contained in:
Osier Yang
2013-05-14 20:44:54 +08:00
parent f60bd7c7a7
commit a7c4202cdd
12 changed files with 112 additions and 0 deletions

View File

@@ -1702,6 +1702,14 @@
network. By default copy-on-read is off.
<span class='since'>Since 0.9.10 (QEMU and KVM only)</span>
</li>
<li>
The optional <code>discard</code> attribute controls whether
to discard (also known as "trim" or "unmap") requests are
ignored or passed to the filesystem. The value can be either
"on" (allow the discard request to be passed) or "off" (ingore
the discard request).
<span class='since'>Since 1.0.6 (QEMU and KVM only)</span>
</li>
</ul>
</dd>
<dt><code>boot</code></dt>

View File

@@ -1311,6 +1311,9 @@
<optional>
<ref name="copy_on_read"/>
</optional>
<optional>
<ref name="discard"/>
</optional>
<empty/>
</element>
</define>
@@ -1406,6 +1409,14 @@
<value>off</value>
</choice>
</attribute>
</define>
<define name="discard">
<attribute name='discard'>
<choice>
<value>on</value>
<value>off</value>
</choice>
</attribute>
</define>
<define name="controller">
<element name="controller">