On 07/08/2014 08:47 AM, Chunyan Liu wrote:
Add 'nocow' to storage volume xml so that user can have an
option
to set NOCOW flag to the newly created volume. It's useful on btrfs
file system to enhance performance.
Btrfs has low performance when hosting VM images, even more when the guest
in those VM are also using btrfs as file system. One way to mitigate this
bad performance is to turn off COW attributes on VM files. Generally, there
are two ways to turn off NOCOW on btrfs: a) by mounting fs with nodatacow,
s/turn off NOCOW/turn off COW/
then all newly created files will be NOCOW. b) per file. Add the
NOCOW file
attribute. It could only be done to empty or new files.
This patch tries the second way, according to 'nocow' option, it could set
NOCOW flag per file:
for raw file images, handle 'nocow' in libvirt code; for non-raw file images,
pass 'nocow=on' option to qemu-img, and let qemu-img to handle that (requires
qemu-img version >= 2.1).
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
Changes:
- now qemu-img can handle 'nocow=on' option, just pass 'nocow=on' to
qemu-img for non-raw file images. No need to handle all file type
in libvirt code.
Pervious version is here:
http://www.redhat.com/archives/libvir-list/2013-December/msg01257.html
---
docs/formatstorage.html.in | 7 +++++++
docs/schemas/storagevol.rng | 5 +++++
Adding a test case to storagevolxml2argvtest would be nice. Also, by adding
the volume XML to storagevolxml2xmlin for this test, it will get validated
against the rng schema in 'storagevolschematest'.
src/conf/storage_conf.c | 3 +++
src/storage/storage_backend.c | 22 ++++++++++++++++++++++
src/util/virstoragefile.h | 1 +
5 files changed, 38 insertions(+)
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 1cd82b4..e8862bf 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -385,6 +385,7 @@
<label>virt_image_t</label>
</permissions>
<compat>1.1</compat>
+ <nocow/>
<features>
<lazy_refcounts/>
</features>
@@ -424,6 +425,12 @@
1.1 is used. If omitted, qemu-img default is used.
<span class="since">Since 1.1.0</span>
</dd>
+ <dt><code>nocow</code></dt>
+ <dd>Turn off COW of the newly created volume. So far, this is only valid
+ to a file image in btrfs file system. It will improve performance when
s/to a file/for a file/
+ the file image is used in VM. To create non-raw file images,
it
+ requires QEMU version since 2.1. <span class="since">Since
1.2.6</span>
1.2.7
Otherwise looks good to me.
Jan