[PATCHv1 13/13] Add qcow2 features to snapshot XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows creating an external qcow2 snapshot with
qcow2 features, e.g:

<disk name='hda' snapshot='external' type='file'>
  <source file='/path/to/file'/>
  <compat>1.1</compat>
  <features>
    <lazy_refcounts/>
  </features>
</disk>

https://bugzilla.redhat.com/show_bug.cgi?id=980327
---
 docs/formatsnapshot.html.in                        |  9 +++++++
 docs/schemas/domainsnapshot.rng                    | 10 +++++++-
 src/conf/snapshot_conf.c                           | 12 +++++++++
 .../disk_snapshot_features.xml                     | 30 ++++++++++++++++++++++
 .../disk_snapshot_features.xml                     | 30 ++++++++++++++++++++++
 tests/domainsnapshotxml2xmltest.c                  |  2 ++
 6 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 tests/domainsnapshotxml2xmlin/disk_snapshot_features.xml
 create mode 100644 tests/domainsnapshotxml2xmlout/disk_snapshot_features.xml

diff --git a/docs/formatsnapshot.html.in b/docs/formatsnapshot.html.in
index c3ab516..569dd24 100644
--- a/docs/formatsnapshot.html.in
+++ b/docs/formatsnapshot.html.in
@@ -180,6 +180,15 @@
               as qcow2), of the new file created by the external
               snapshot of the new file.
               </dd>
+              <dt><code>compat</code></dt>
+              <dd>Optional. Allows specifying the compatibility level for qcow2 volumes.
+              So far, this is only used for type='qcow2' volumes. Valid values are 0.10 and 1.1,
+              specifying QEMU version the images should be compatible with.
+              If the feature element is present, 1.1 is used. If omitted, 0.10 is used.
+              <span class="since">Since 1.2.15</span></dd>
+              <dt><code>features</code></dt>
+              <dd>Format-specific features. See the features element in
+              <a href="formatstorage.html">volume target elements</a> for valid features</dd>
             </dl>
 
             <span class="since">Since 1.2.2</span> the <code>disk</code> element
diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng
index 4ab1b82..a6d0202 100644
--- a/docs/schemas/domainsnapshot.rng
+++ b/docs/schemas/domainsnapshot.rng
@@ -109,7 +109,15 @@
 
   <define name='storageSourceExtra' combine='choice'>
     <!-- overrides the no-op version in storagecommon.rng -->
-    <ref name='disksnapshotdriver'/>
+    <interleave>
+      <ref name='disksnapshotdriver'/>
+      <optional>
+        <ref name='compat'/>
+      </optional>
+      <optional>
+        <ref name='fileFormatFeatures'/>
+      </optional>
+    </interleave>
   </define>
 
   <define name='disksnapshot'>
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index ca6796a..c2b36e2 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -41,6 +41,7 @@
 #include "nwfilter_conf.h"
 #include "secret_conf.h"
 #include "snapshot_conf.h"
+#include "storage_feature_conf.h"
 #include "virstoragefile.h"
 #include "viruuid.h"
 #include "virfile.h"
@@ -169,6 +170,15 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
         }
     }
 
+    def->src->compat = virXPathString("string(./compat)", ctxt);
+    if (!virStorageFileCheckCompat(def->src->compat))
+        goto cleanup;
+
+    if (virStorageFeaturesParse(ctxt, "./features",
+                                &def->src->compat,
+                                &def->src->features) < 0)
+        goto cleanup;
+
     /* validate that the passed path is absolute */
     if (virStorageSourceIsLocalStorage(def->src) &&
         def->src->path &&
@@ -656,6 +666,8 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
         virBufferEscapeString(buf, "<driver type='%s'/>\n",
                               virStorageFileFormatTypeToString(disk->src->format));
     virDomainDiskSourceFormat(buf, disk->src, 0, 0);
+    virBufferEscapeString(buf, "<compat>%s</compat>\n", disk->src->compat);
+    virStorageFeaturesFormat(buf, disk->src->features);
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</disk>\n");
diff --git a/tests/domainsnapshotxml2xmlin/disk_snapshot_features.xml b/tests/domainsnapshotxml2xmlin/disk_snapshot_features.xml
new file mode 100644
index 0000000..499c28f
--- /dev/null
+++ b/tests/domainsnapshotxml2xmlin/disk_snapshot_features.xml
@@ -0,0 +1,30 @@
+<domainsnapshot>
+  <name>my snap name</name>
+  <description>!@#$%^</description>
+  <disks>
+    <disk name='hda' snapshot='external' type='file'>
+      <driver type='qcow2'/>
+      <source file='/path/to/new'/>
+      <compat>0.10</compat>
+    </disk>
+    <disk name='hdb' snapshot='external' type='file'>
+      <source file='/path/to/new2'/>
+      <compat>1.1</compat>
+      <features>
+        <lazy_refcounts/>
+      </features>
+    </disk>
+    <disk name='hdc' snapshot='external' type='file'>
+      <source file='/path/to/new2'/>
+      <compat>1.1</compat>
+      <features/>
+    </disk>
+    <disk name='hdd' snapshot='external' type='file'>
+      <source file='/path/to/new2'/>
+      <compat>1.1</compat>
+      <features>
+        <lazy_refcounts/>
+      </features>
+    </disk>
+  </disks>
+</domainsnapshot>
diff --git a/tests/domainsnapshotxml2xmlout/disk_snapshot_features.xml b/tests/domainsnapshotxml2xmlout/disk_snapshot_features.xml
new file mode 100644
index 0000000..499c28f
--- /dev/null
+++ b/tests/domainsnapshotxml2xmlout/disk_snapshot_features.xml
@@ -0,0 +1,30 @@
+<domainsnapshot>
+  <name>my snap name</name>
+  <description>!@#$%^</description>
+  <disks>
+    <disk name='hda' snapshot='external' type='file'>
+      <driver type='qcow2'/>
+      <source file='/path/to/new'/>
+      <compat>0.10</compat>
+    </disk>
+    <disk name='hdb' snapshot='external' type='file'>
+      <source file='/path/to/new2'/>
+      <compat>1.1</compat>
+      <features>
+        <lazy_refcounts/>
+      </features>
+    </disk>
+    <disk name='hdc' snapshot='external' type='file'>
+      <source file='/path/to/new2'/>
+      <compat>1.1</compat>
+      <features/>
+    </disk>
+    <disk name='hdd' snapshot='external' type='file'>
+      <source file='/path/to/new2'/>
+      <compat>1.1</compat>
+      <features>
+        <lazy_refcounts/>
+      </features>
+    </disk>
+  </disks>
+</domainsnapshot>
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 845d52f..a25871b 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -219,10 +219,12 @@ mymain(void)
     DO_TEST_INOUT("noparent", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", false, false);
     DO_TEST_INOUT("disk_snapshot", NULL, false, false);
     DO_TEST_INOUT("disk_driver_name_null", NULL, false, false);
+    DO_TEST_INOUT("disk_snapshot_features", NULL, false, false);
 
     DO_TEST_IN("name_and_description", NULL);
     DO_TEST_IN("description_only", NULL);
     DO_TEST_IN("name_only", NULL);
+    DO_TEST_IN("disk_snapshot_features", NULL);
 
  cleanup:
     if (testSnapshotXMLVariableLineRegex)
-- 
2.0.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]