forked from pool/libvirt
803ff43893
- Move 'Requires' of qemu from libvirt-daemon-qemu subpackage to libvirt-daemon-driver-qemu bnc#885267 - Temporarily disable virt-aa-helper-test, which fails in Factory - Update to libvirt 1.2.6 - libxl: add migration support and fixes - Many incremental improvements and bug fixes, see http://libvirt.org/news.html - Drop upstream patch libxl-migration-support.patch - Drop ia64-clone.patch since libvirt is not built for IA64 OBS-URL: https://build.opensuse.org/request/show/239388 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=388
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.6/docs/schemas/storagevol.rng
|
|
===================================================================
|
|
--- libvirt-1.2.6.orig/docs/schemas/storagevol.rng
|
|
+++ libvirt-1.2.6/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.6/src/conf/storage_conf.c
|
|
===================================================================
|
|
--- libvirt-1.2.6.orig/src/conf/storage_conf.c
|
|
+++ libvirt-1.2.6/src/conf/storage_conf.c
|
|
@@ -1397,6 +1397,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.6/src/storage/storage_backend.c
|
|
===================================================================
|
|
--- libvirt-1.2.6.orig/src/storage/storage_backend.c
|
|
+++ libvirt-1.2.6/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.6/src/util/virstoragefile.h
|
|
===================================================================
|
|
--- libvirt-1.2.6.orig/src/util/virstoragefile.h
|
|
+++ libvirt-1.2.6/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;
|