[PATCH 1/3] vz: fix for tracking current snapshot

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

 



f1056279 removed virDomainSnapshotDef.current and leaved
using vm->current_snapshot only. Later 4819f54bd moved current snapshot
tracking to virDomainSnapshotObjList. As vz driver never used
vm->current_snaphot this patch includes fixes after both commits.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/vz/vz_driver.c | 31 ++++---------------------------
 src/vz/vz_sdk.c    | 14 ++++++--------
 2 files changed, 10 insertions(+), 35 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 40d3a73..f7a44d4 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2152,29 +2152,6 @@ vzSnapObjFromSnapshot(virDomainSnapshotObjListPtr snapshots,
 }
 
 static int
-vzCurrentSnapshotIterator(void *payload,
-                              const void *name ATTRIBUTE_UNUSED,
-                              void *data)
-{
-    virDomainMomentObjPtr snapshot = payload;
-    virDomainMomentObjPtr *current = data;
-
-    if (snapshot->def->current)
-        *current = snapshot;
-
-    return 0;
-}
-
-static virDomainMomentObjPtr
-vzFindCurrentSnapshot(virDomainSnapshotObjListPtr snapshots)
-{
-    virDomainMomentObjPtr current = NULL;
-
-    virDomainSnapshotForEach(snapshots, vzCurrentSnapshotIterator, &current);
-    return current;
-}
-
-static int
 vzDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
 {
     virDomainObjPtr dom;
@@ -2452,7 +2429,7 @@ vzDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags)
     if (!(snapshots = prlsdkLoadSnapshots(dom)))
         goto cleanup;
 
-    ret = vzFindCurrentSnapshot(snapshots) != NULL;
+    ret = virDomainSnapshotGetCurrent(snapshots) != NULL;
 
  cleanup:
     virDomainSnapshotObjListFree(snapshots);
@@ -2518,7 +2495,7 @@ vzDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags)
     if (!(snapshots = prlsdkLoadSnapshots(dom)))
         goto cleanup;
 
-    if (!(current = vzFindCurrentSnapshot(snapshots))) {
+    if (!(current = virDomainSnapshotGetCurrent(snapshots))) {
         virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, "%s",
                        _("the domain does not have a current snapshot"));
         goto cleanup;
@@ -2552,7 +2529,7 @@ vzDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned int flags)
     if (!(snapshots = prlsdkLoadSnapshots(dom)))
         goto cleanup;
 
-    current = vzFindCurrentSnapshot(snapshots);
+    current = virDomainSnapshotGetCurrent(snapshots);
     ret = current && STREQ(snapshot->name, current->def->name);
 
  cleanup:
@@ -2648,7 +2625,7 @@ vzDomainSnapshotCreateXML(virDomainPtr domain,
     if (!(snapshots = prlsdkLoadSnapshots(dom)))
         goto cleanup;
 
-    if (!(current = vzFindCurrentSnapshot(snapshots))) {
+    if (!(current = virDomainSnapshotGetCurrent(snapshots))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("can't find created snapshot"));
         goto cleanup;
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index f5a5911..92bcb3d 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -4656,7 +4656,6 @@ prlsdkParseSnapshotTree(const char *treexml)
     xmlNodePtr *nodes = NULL;
     virDomainSnapshotDefPtr def = NULL;
     virDomainMomentObjPtr snapshot;
-    virDomainMomentObjPtr current = NULL;
     virDomainSnapshotObjListPtr snapshots = NULL;
     char *xmlstr = NULL;
     int n;
@@ -4743,22 +4742,21 @@ prlsdkParseSnapshotTree(const char *treexml)
         }
         VIR_FREE(xmlstr);
 
-        xmlstr = virXPathString("string(./@current)", ctxt);
-        def->current = xmlstr && STREQ("yes", xmlstr);
-        VIR_FREE(xmlstr);
-
         if (!(snapshot = virDomainSnapshotAssignDef(snapshots, def)))
             goto cleanup;
         def = NULL;
 
-        if (snapshot->def->current) {
-            if (current) {
+        xmlstr = virXPathString("string(./@current)", ctxt);
+        if (xmlstr && STREQ("yes", xmlstr)) {
+            if (virDomainSnapshotGetCurrent(snapshots)) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("too many current snapshots"));
+                VIR_FREE(xmlstr);
                 goto cleanup;
             }
-            current = snapshot;
+            virDomainSnapshotSetCurrent(snapshots, snapshot);
         }
+        VIR_FREE(xmlstr);
     }
 
     if (virDomainSnapshotUpdateRelations(snapshots) < 0) {
-- 
1.8.3.1

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

  Powered by Linux