forked from pool/libvirt
e5c6318b4d
- Update to libvirt 1.2.5 - Introduce virDomain{Get,Set}Time APIs - Introduce virDomainFSFreeze() and virDomainFSThaw() public API - Many incremental improvements and bug fixes, see http://libvirt.org/news.html - Drop upstream patches: b98bf811-add-paravirt-shutdown-flag.patch, c4fe29f8-use-shutdown-flag.patch, da744120-use-reboot-flag.patch, d6b27d3e-CVE-2014-0179.patch, fd43d1f8-libxl-iface-hostdev.patch, 99f50208-managed-hostdev-iface.patch, 292d3f2d-libselinux-build-fix1.patch, b109c097-libselinux-build-fix2.patch OBS-URL: https://build.opensuse.org/request/show/235993 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=381
114 lines
4.0 KiB
Diff
114 lines
4.0 KiB
Diff
commit ccc0b45917fa76a77ff83f1ddfd30836c8c3805e
|
|
Author: Chunyan Liu <cyliu@suse.com>
|
|
Date: Wed May 7 12:45:40 2014 +0800
|
|
|
|
add nocow to vol xml
|
|
|
|
Updated patch. Rebase to git master.
|
|
|
|
Signed-off-by: Chunyan Liu <cyliu@suse.com>
|
|
|
|
Index: libvirt-1.2.5/docs/schemas/storagevol.rng
|
|
===================================================================
|
|
--- libvirt-1.2.5.orig/docs/schemas/storagevol.rng
|
|
+++ libvirt-1.2.5/docs/schemas/storagevol.rng
|
|
@@ -138,6 +138,11 @@
|
|
<ref name='compat'/>
|
|
</optional>
|
|
<optional>
|
|
+ <element name='nocow'>
|
|
+ <empty/>
|
|
+ </element>
|
|
+ </optional>
|
|
+ <optional>
|
|
<ref name='fileFormatFeatures'/>
|
|
</optional>
|
|
</interleave>
|
|
Index: libvirt-1.2.5/src/conf/storage_conf.c
|
|
===================================================================
|
|
--- libvirt-1.2.5.orig/src/conf/storage_conf.c
|
|
+++ libvirt-1.2.5/src/conf/storage_conf.c
|
|
@@ -1395,6 +1395,9 @@ virStorageVolDefParseXML(virStoragePoolD
|
|
virStringFreeList(version);
|
|
}
|
|
|
|
+ if (virXPathNode("./target/nocow", ctxt))
|
|
+ ret->target.nocow = true;
|
|
+
|
|
if (options->featureFromString && virXPathNode("./target/features", ctxt)) {
|
|
if ((n = virXPathNodeSet("./target/features/*", ctxt, &nodes)) < 0)
|
|
goto error;
|
|
Index: libvirt-1.2.5/src/storage/storage_backend.c
|
|
===================================================================
|
|
--- libvirt-1.2.5.orig/src/storage/storage_backend.c
|
|
+++ libvirt-1.2.5/src/storage/storage_backend.c
|
|
@@ -37,6 +37,9 @@
|
|
#ifdef __linux__
|
|
# include <sys/ioctl.h>
|
|
# include <linux/fs.h>
|
|
+# ifndef FS_NOCOW_FL
|
|
+# define FS_NOCOW_FL 0x00800000 /* Do not cow file */
|
|
+# endif
|
|
#endif
|
|
|
|
#if WITH_SELINUX
|
|
@@ -452,6 +455,21 @@ virStorageBackendCreateRaw(virConnectPtr
|
|
goto cleanup;
|
|
}
|
|
|
|
+ if (vol->target.nocow) {
|
|
+#ifdef __linux__
|
|
+ int attr;
|
|
+
|
|
+ /* Set NOCOW flag. This is an optimisation for btrfs.
|
|
+ * The FS_IOC_SETFLAGS ioctl return value will be ignored since any
|
|
+ * failure of this operation should not block the left work.
|
|
+ */
|
|
+ if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) {
|
|
+ attr |= FS_NOCOW_FL;
|
|
+ ioctl(fd, FS_IOC_SETFLAGS, &attr);
|
|
+ }
|
|
+#endif
|
|
+ }
|
|
+
|
|
if ((ret = createRawFile(fd, vol, inputvol)) < 0)
|
|
/* createRawFile already reported the exact error. */
|
|
ret = -1;
|
|
@@ -717,6 +735,7 @@ virStorageBackendCreateQemuImgOpts(char
|
|
bool preallocate,
|
|
int format,
|
|
const char *compat,
|
|
+ bool nocow,
|
|
virBitmapPtr features)
|
|
{
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
@@ -729,6 +748,8 @@ virStorageBackendCreateQemuImgOpts(char
|
|
virBufferAddLit(&buf, "encryption=on,");
|
|
if (preallocate)
|
|
virBufferAddLit(&buf, "preallocation=metadata,");
|
|
+ if (nocow)
|
|
+ virBufferAddLit(&buf, "nocow=on,");
|
|
|
|
if (compat)
|
|
virBufferAsprintf(&buf, "compat=%s,", compat);
|
|
@@ -950,6 +971,7 @@ virStorageBackendCreateQemuImgCmd(virCon
|
|
do_encryption, preallocate,
|
|
vol->target.format,
|
|
compat,
|
|
+ vol->target.nocow,
|
|
vol->target.features) < 0) {
|
|
virCommandFree(cmd);
|
|
return NULL;
|
|
Index: libvirt-1.2.5/src/util/virstoragefile.h
|
|
===================================================================
|
|
--- libvirt-1.2.5.orig/src/util/virstoragefile.h
|
|
+++ libvirt-1.2.5/src/util/virstoragefile.h
|
|
@@ -232,6 +232,7 @@ struct _virStorageSource {
|
|
* pool-specific enum for storage volumes */
|
|
virBitmapPtr features;
|
|
char *compat;
|
|
+ bool nocow;
|
|
|
|
virStoragePermsPtr perms;
|
|
virStorageTimestampsPtr timestamps;
|