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

[libvirt] [PATCH 52/66] vbox: Rewrite vboxDomainSnapshotNum



---
 src/vbox/vbox_common.c        |   40 +++++++++++++++++++++++++++++++++++
 src/vbox/vbox_tmpl.c          |   47 -----------------------------------------
 src/vbox/vbox_uniformed_api.h |    1 +
 3 files changed, 41 insertions(+), 47 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 36260de..074eab0 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -6081,3 +6081,43 @@ char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
     vboxIIDUnalloc(&domiid);
     return ret;
 }
+
+int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags)
+{
+    VBOX_OBJECT_CHECK(dom->conn, int, -1);
+    vboxIIDUnion iid;
+    IMachine *machine = NULL;
+    nsresult rc;
+    PRUint32 snapshotCount;
+
+    virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
+                  VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+
+    if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+        goto cleanup;
+
+    /* VBox snapshots do not require libvirt to maintain any metadata.  */
+    if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) {
+        ret = 0;
+        goto cleanup;
+    }
+
+    rc = gVBoxAPI.UIMachine.GetSnapshotCount(machine, &snapshotCount);
+    if (NS_FAILED(rc)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("could not get snapshot count for domain %s"),
+                       dom->name);
+        goto cleanup;
+    }
+
+    /* VBox has at most one root snapshot.  */
+    if (snapshotCount && (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS))
+        ret = 1;
+    else
+        ret = snapshotCount;
+
+ cleanup:
+    VBOX_RELEASE(machine);
+    vboxIIDUnalloc(&iid);
+    return ret;
+}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 4b5f993..f384741 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -1523,53 +1523,6 @@ vboxDomainSnapshotGet(vboxGlobalData *data,
 }
 
 static int
-vboxDomainSnapshotNum(virDomainPtr dom,
-                      unsigned int flags)
-{
-    VBOX_OBJECT_CHECK(dom->conn, int, -1);
-    vboxIID iid = VBOX_IID_INITIALIZER;
-    IMachine *machine = NULL;
-    nsresult rc;
-    PRUint32 snapshotCount;
-
-    virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
-                  VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
-
-    vboxIIDFromUUID(&iid, dom->uuid);
-    rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
-    if (NS_FAILED(rc)) {
-        virReportError(VIR_ERR_NO_DOMAIN, "%s",
-                       _("no domain with matching UUID"));
-        goto cleanup;
-    }
-
-    /* VBox snapshots do not require libvirt to maintain any metadata.  */
-    if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) {
-        ret = 0;
-        goto cleanup;
-    }
-
-    rc = machine->vtbl->GetSnapshotCount(machine, &snapshotCount);
-    if (NS_FAILED(rc)) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("could not get snapshot count for domain %s"),
-                       dom->name);
-        goto cleanup;
-    }
-
-    /* VBox has at most one root snapshot.  */
-    if (snapshotCount && (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS))
-        ret = 1;
-    else
-        ret = snapshotCount;
-
- cleanup:
-    VBOX_RELEASE(machine);
-    vboxIIDUnalloc(&iid);
-    return ret;
-}
-
-static int
 vboxDomainSnapshotListNames(virDomainPtr dom,
                             char **names,
                             int nameslen,
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 6b04b57..ba75d00 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -577,6 +577,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
                             unsigned int flags);
 char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
                                    unsigned int flags);
+int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags);
 
 /* Version specified functions for installing uniformed API */
 void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
-- 
1.7.9.5


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