[PATCH] conf: add caps to virDomainSnapshotDefFormat

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

 



The virDomainSnapshotDefFormat calls into virDomainDefFormat,
so should be providing a non-NULL virCapsPtr instance. On the
qemu driver we change qemuDomainSnapshotWriteMetadata to also
include caps since it calls virDomainSnapshotDefFormat.

Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
---
 src/conf/snapshot_conf.c          |  3 ++-
 src/conf/snapshot_conf.h          |  1 +
 src/esx/esx_driver.c              |  2 +-
 src/qemu/qemu_domain.c            |  5 +++--
 src/qemu/qemu_domain.h            |  1 +
 src/qemu/qemu_driver.c            | 16 ++++++++++------
 src/test/test_driver.c            |  3 ++-
 src/vbox/vbox_common.c            |  4 ++--
 tests/domainsnapshotxml2xmltest.c |  2 +-
 9 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index ffa1bf2..1eda7c2 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -659,6 +659,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
 
 char *virDomainSnapshotDefFormat(const char *domain_uuid,
                                  virDomainSnapshotDefPtr def,
+                                 virCapsPtr caps,
                                  unsigned int flags,
                                  int internal)
 {
@@ -702,7 +703,7 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
         virBufferAddLit(&buf, "</disks>\n");
     }
     if (def->dom) {
-        if (virDomainDefFormatInternal(def->dom, NULL, flags, &buf) < 0) {
+        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) {
             virBufferFreeAndReset(&buf);
             return NULL;
         }
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index 4f0d096..fcf7a1e 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -113,6 +113,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(xmlDocPtr xml,
 void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
 char *virDomainSnapshotDefFormat(const char *domain_uuid,
                                  virDomainSnapshotDefPtr def,
+                                 virCapsPtr caps,
                                  unsigned int flags,
                                  int internal);
 int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index ce5f799..00d0e0a 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4292,7 +4292,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
     virUUIDFormat(snapshot->domain->uuid, uuid_string);
 
-    xml = virDomainSnapshotDefFormat(uuid_string, &def,
+    xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps,
                                      virDomainDefFormatConvertXMLFlags(flags),
                                      0);
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a70b866..0b02c68 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2605,6 +2605,7 @@ qemuFindQemuImgBinary(virQEMUDriverPtr driver)
 int
 qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
                                 virDomainSnapshotObjPtr snapshot,
+                                virCapsPtr caps,
                                 char *snapshotDir)
 {
     char *newxml = NULL;
@@ -2615,7 +2616,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
 
     virUUIDFormat(vm->def->uuid, uuidstr);
     newxml = virDomainSnapshotDefFormat(
-        uuidstr, snapshot->def,
+        uuidstr, snapshot->def, caps,
         virDomainDefFormatConvertXMLFlags(QEMU_DOMAIN_FORMAT_LIVE_FLAGS),
         1);
     if (newxml == NULL)
@@ -2775,7 +2776,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
                          snap->def->parent);
             } else {
                 parentsnap->def->current = true;
-                if (qemuDomainSnapshotWriteMetadata(vm, parentsnap,
+                if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver->caps,
                                                     cfg->snapshotDir) < 0) {
                     VIR_WARN("failed to set parent snapshot '%s' as current",
                              snap->def->parent);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 6a8cf70..7cabf10 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -375,6 +375,7 @@ const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
 
 int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
                                     virDomainSnapshotObjPtr snapshot,
+                                    virCapsPtr caps,
                                     char *snapshotDir);
 
 int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d623831..2e283a9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14908,6 +14908,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
         if (update_current) {
             vm->current_snapshot->def->current = false;
             if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
+                                                driver->caps,
                                                 cfg->snapshotDir) < 0)
                 goto endjob;
             vm->current_snapshot = NULL;
@@ -14956,7 +14957,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
 
  endjob:
     if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
-        if (qemuDomainSnapshotWriteMetadata(vm, snap,
+        if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
                                             cfg->snapshotDir) < 0) {
             /* if writing of metadata fails, error out rather than trying
              * to silently carry on without completing the snapshot */
@@ -15275,6 +15276,7 @@ static char *
 qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
                              unsigned int flags)
 {
+    virQEMUDriverPtr driver = snapshot->domain->conn->privateData;
     virDomainObjPtr vm = NULL;
     char *xml = NULL;
     virDomainSnapshotObjPtr snap = NULL;
@@ -15293,7 +15295,7 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
     virUUIDFormat(snapshot->domain->uuid, uuidstr);
 
-    xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
+    xml = virDomainSnapshotDefFormat(uuidstr, snap->def, driver->caps,
                                      virDomainDefFormatConvertXMLFlags(flags),
                                      0);
 
@@ -15474,7 +15476,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
     if (vm->current_snapshot) {
         vm->current_snapshot->def->current = false;
         if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
-                                            cfg->snapshotDir) < 0)
+                                            driver->caps, cfg->snapshotDir) < 0)
             goto endjob;
         vm->current_snapshot = NULL;
         /* XXX Should we restore vm->current_snapshot after this point
@@ -15709,7 +15711,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
 
  cleanup:
     if (ret == 0) {
-        if (qemuDomainSnapshotWriteMetadata(vm, snap,
+        if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
                                             cfg->snapshotDir) < 0)
             ret = -1;
         else
@@ -15736,6 +15738,7 @@ struct _virQEMUSnapReparent {
     virQEMUDriverConfigPtr cfg;
     virDomainSnapshotObjPtr parent;
     virDomainObjPtr vm;
+    virCapsPtr caps;
     int err;
     virDomainSnapshotObjPtr last;
 };
@@ -15764,7 +15767,7 @@ qemuDomainSnapshotReparentChildren(void *payload,
     if (!snap->sibling)
         rep->last = snap;
 
-    rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap,
+    rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap, rep->caps,
                                                rep->cfg->snapshotDir);
 }
 
@@ -15833,7 +15836,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
         if (rem.current) {
             if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
                 snap->def->current = true;
-                if (qemuDomainSnapshotWriteMetadata(vm, snap,
+                if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
                                                     cfg->snapshotDir) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("failed to set snapshot '%s' as current"),
@@ -15850,6 +15853,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
         rep.vm = vm;
         rep.err = 0;
         rep.last = NULL;
+        rep.caps = driver->caps;
         virDomainSnapshotForEachChild(snap,
                                       qemuDomainSnapshotReparentChildren,
                                       &rep);
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 89973f6..fde5e2d 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -6087,6 +6087,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
     char *xml = NULL;
     virDomainSnapshotObjPtr snap = NULL;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
+    testDriverPtr privconn = snapshot->domain->conn->privateData;
 
     virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
 
@@ -6098,7 +6099,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
     virUUIDFormat(snapshot->domain->uuid, uuidstr);
 
-    xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
+    xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->caps,
                                      virDomainDefFormatConvertXMLFlags(flags),
                                      0);
 
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index cf38d2a..d1eb09a 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -5221,7 +5221,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
         VIR_FREE(currentSnapshotXmlFilePath);
         if (virAsprintf(&currentSnapshotXmlFilePath, "%s%s.xml", machineLocationPath, snapshotMachineDesc->currentSnapshot) < 0)
             goto cleanup;
-        char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
+        char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
         if (snapshotContent == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Unable to get snapshot content"));
@@ -6146,7 +6146,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
     virUUIDFormat(dom->uuid, uuidstr);
     memcpy(def->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
-    ret = virDomainSnapshotDefFormat(uuidstr, def,
+    ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps,
                                       virDomainDefFormatConvertXMLFlags(flags),
                                       0);
 
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index cf91447..714d64f 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -100,7 +100,7 @@ testCompareXMLToXMLFiles(const char *inxml,
                                                 flags)))
         goto cleanup;
 
-    if (!(actual = virDomainSnapshotDefFormat(uuid, def,
+    if (!(actual = virDomainSnapshotDefFormat(uuid, def, driver.caps,
                                               VIR_DOMAIN_DEF_FORMAT_SECURE,
                                               internal)))
         goto cleanup;
-- 
2.1.4

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