[PATCHv3 2/5] snapshot: prepare to parse new XML

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

 



No semantic change, but prepare for a new mode of parsing where
a new _BRANCH flag requests that the parse look up the existing
snapshot to branch from.

* src/conf/snapshot_conf.h (VIR_DOMAIN_SNAPSHOT_PARSE_BRANCH): New
flag, unused for now.
(virDomainSnapshotDefParseString): Add parameter.
* src/conf/snapshot_conf.c (virDomainSnapshotDefParseString):
Update signature.
* src/esx/esx_driver.c (esxDomainSnapshotCreateXML): Update caller.
* src/qemu/qemu_driver.c (qemuDomainSnapshotLoad): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSnapshotCreateXML): Likewise.
* tests/domainsnapshotxml2xmltest.c (testCompareXMLToXMLFiles):
Likewise.
---
 src/conf/snapshot_conf.c          | 8 +++++---
 src/conf/snapshot_conf.h          | 2 ++
 src/esx/esx_driver.c              | 2 +-
 src/qemu/qemu_driver.c            | 3 ++-
 src/vbox/vbox_tmpl.c              | 2 +-
 tests/domainsnapshotxml2xmltest.c | 2 +-
 6 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 72bdd30..8a3146f 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -162,14 +162,16 @@ cleanup:
     return ret;
 }

-/* flags is bitwise-or of virDomainSnapshotParseFlags.
- * If flags does not include VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE, then
- * caps and expectedVirtTypes are ignored.
+/* flags is bitwise-or of virDomainSnapshotParseFlags.  If flags does
+ * not include VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE, then 'caps' and
+ * 'expectedVirtTypes' are ignored.  If flags does not include
+ * VIR_DOMAIN_SNAPSHOT_PARSE_BRANCH, then 'snapshots' is ignored.
  */
 virDomainSnapshotDefPtr
 virDomainSnapshotDefParseString(const char *xmlStr,
                                 virCapsPtr caps,
                                 unsigned int expectedVirtTypes,
+                                virDomainSnapshotObjListPtr snapshots ATTRIBUTE_UNUSED,
                                 unsigned int flags)
 {
     xmlXPathContextPtr ctxt = NULL;
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index b0f8760..c06f3b3 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -97,11 +97,13 @@ typedef enum {
     VIR_DOMAIN_SNAPSHOT_PARSE_DISKS    = 1 << 1,
     VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL = 1 << 2,
     VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE  = 1 << 3,
+    VIR_DOMAIN_SNAPSHOT_PARSE_BRANCH   = 1 << 4,
 } virDomainSnapshotParseFlags;

 virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
                                                         virCapsPtr caps,
                                                         unsigned int expectedVirtTypes,
+                                                        virDomainSnapshotObjListPtr snapshots,
                                                         unsigned int flags);
 void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
 char *virDomainSnapshotDefFormat(const char *domain_uuid,
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 56f31bb..3c869d7 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4267,7 +4267,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
         return NULL;
     }

-    def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, 0);
+    def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, NULL, 0);

     if (def == NULL) {
         return NULL;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d4cafcc..f5bbc52 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -509,7 +509,7 @@ qemuDomainSnapshotLoad(void *payload,

         def = virDomainSnapshotDefParseString(xmlStr, qemu_driver->caps,
                                               QEMU_EXPECTED_VIRT_TYPES,
-                                              flags);
+                                              NULL, flags);
         if (def == NULL) {
             /* Nothing we can do here, skip this one */
             VIR_ERROR(_("Failed to parse snapshot XML from file '%s'"),
@@ -11511,6 +11511,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,

     if (!(def = virDomainSnapshotDefParseString(xmlDesc, driver->caps,
                                                 QEMU_EXPECTED_VIRT_TYPES,
+                                                vm->snapshots,
                                                 parse_flags)))
         goto cleanup;

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index bcffb2f..4fd0505 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -5929,7 +5929,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
     /* VBox has no snapshot metadata, so this flag is trivial.  */
     virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL);

-    if (!(def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, 0)))
+    if (!(def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, NULL, 0)))
         goto cleanup;

     if (def->ndisks) {
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 84278d6..2c631c3 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -35,7 +35,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int internal)
         flags |= VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL;
     if (!(def = virDomainSnapshotDefParseString(inXmlData, driver.caps,
                                                 QEMU_EXPECTED_VIRT_TYPES,
-                                                flags)))
+                                                NULL, flags)))
         goto fail;

     if (!(actual = virDomainSnapshotDefFormat(uuid, def,
-- 
1.7.11.7

--
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]