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

[libvirt] [RFC PATCHv2 2/n] snapshot: prepare to parse new XML



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          | 4 +++-
 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, 10 insertions(+), 5 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 72bdd30..10aa5e5 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -164,12 +164,14 @@ cleanup:

 /* flags is bitwise-or of virDomainSnapshotParseFlags.
  * If flags does not include VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE, then
- * caps and expectedVirtTypes are ignored.
+ * 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 595c452..039cbf3 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


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