---
src/vbox/vbox_common.c | 53 ++++++++++++++++++++++++++++++++++++
src/vbox/vbox_tmpl.c | 59 -----------------------------------------
src/vbox/vbox_uniformed_api.h | 2 ++
3 files changed, 55 insertions(+), 59 deletions(-)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 04e6c2c..32cbe60 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -6319,3 +6319,56 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
vboxIIDUnalloc(&iid);
return ret;
}
+
+virDomainSnapshotPtr
+vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags)
+{
+ VBOX_OBJECT_CHECK(dom->conn, virDomainSnapshotPtr, NULL);
+ vboxIIDUnion iid;
+ IMachine *machine = NULL;
+ ISnapshot *snapshot = NULL;
+ PRUnichar *nameUtf16 = NULL;
+ char *name = NULL;
+ nsresult rc;
+
+ virCheckFlags(0, NULL);
+
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ goto cleanup;
+
+ rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot);
+ if (NS_FAILED(rc)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("could not get current snapshot"));
+ goto cleanup;
+ }
+
+ if (!snapshot) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("domain has no snapshots"));
+ goto cleanup;
+ }
+
+ rc = gVBoxAPI.UISnapshot.GetName(snapshot, &nameUtf16);
+ if (NS_FAILED(rc) || !nameUtf16) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("could not get current snapshot name"));
+ goto cleanup;
+ }
+
+ VBOX_UTF16_TO_UTF8(nameUtf16, &name);
+ if (!name) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ ret = virGetDomainSnapshot(dom, name);
+
+ cleanup:
+ VBOX_UTF8_FREE(name);
+ VBOX_UTF16_FREE(nameUtf16);
+ VBOX_RELEASE(snapshot);
+ VBOX_RELEASE(machine);
+ vboxIIDUnalloc(&iid);
+ return ret;
+}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index d5df286..87200f1 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -1522,65 +1522,6 @@ vboxDomainSnapshotGet(vboxGlobalData *data,
return snapshot;
}
-static virDomainSnapshotPtr
-vboxDomainSnapshotCurrent(virDomainPtr dom,
- unsigned int flags)
-{
- VBOX_OBJECT_CHECK(dom->conn, virDomainSnapshotPtr, NULL);
- vboxIID iid = VBOX_IID_INITIALIZER;
- IMachine *machine = NULL;
- ISnapshot *snapshot = NULL;
- PRUnichar *nameUtf16 = NULL;
- char *name = NULL;
- nsresult rc;
-
- virCheckFlags(0, NULL);
-
- 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;
- }
-
- rc = machine->vtbl->GetCurrentSnapshot(machine, &snapshot);
- if (NS_FAILED(rc)) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("could not get current snapshot"));
- goto cleanup;
- }
-
- if (!snapshot) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("domain has no snapshots"));
- goto cleanup;
- }
-
- rc = snapshot->vtbl->GetName(snapshot, &nameUtf16);
- if (NS_FAILED(rc) || !nameUtf16) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("could not get current snapshot name"));
- goto cleanup;
- }
-
- VBOX_UTF16_TO_UTF8(nameUtf16, &name);
- if (!name) {
- virReportOOMError();
- goto cleanup;
- }
-
- ret = virGetDomainSnapshot(dom, name);
-
- cleanup:
- VBOX_UTF8_FREE(name);
- VBOX_UTF16_FREE(nameUtf16);
- VBOX_RELEASE(snapshot);
- VBOX_RELEASE(machine);
- vboxIIDUnalloc(&iid);
- return ret;
-}
-
static int
vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
unsigned int flags)
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 978da5e..c320ac2 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -587,6 +587,8 @@ int vboxDomainHasCurrentSnapshot(virDomainPtr dom, unsigned int
flags);
virDomainSnapshotPtr
vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
unsigned int flags);
+virDomainSnapshotPtr
+vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags);
/* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
--
1.7.9.5