From 0664d41b55ca69003fb5ec3c692d161c45050c2a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 29 Sep 2011 14:11:56 -0600 Subject: [PATCH] snapshot: implement getparent for esx Pretty easy to paste together compared to existing functions. * src/esx/esx_driver.c (esxDomainSnapshotGetParent): New function. --- src/esx/esx_driver.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index c15c0d6950..ab93efd12c 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4483,6 +4483,46 @@ esxDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags) +static virDomainSnapshotPtr +esxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned int flags) +{ + esxPrivate *priv = snapshot->domain->conn->privateData; + esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL; + esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL; + esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL; + virDomainSnapshotPtr parent = NULL; + + virCheckFlags(0, NULL); + + if (esxVI_EnsureSession(priv->primary) < 0) { + return NULL; + } + + if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, + &rootSnapshotList) < 0 || + esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name, + &snapshotTree, &snapshotTreeParent, + esxVI_Occurrence_RequiredItem) < 0) { + goto cleanup; + } + + if (!snapshotTreeParent) { + ESX_ERROR(VIR_ERR_NO_DOMAIN_SNAPSHOT, + _("snapshot '%s' does not have a parent"), + snapshotTree->name); + goto cleanup; + } + + parent = virGetDomainSnapshot(snapshot->domain, snapshotTreeParent->name); + +cleanup: + esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotList); + + return parent; +} + + + static virDomainSnapshotPtr esxDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags) { @@ -4831,6 +4871,7 @@ static virDriver esxDriver = { .domainSnapshotListNames = esxDomainSnapshotListNames, /* 0.8.0 */ .domainSnapshotLookupByName = esxDomainSnapshotLookupByName, /* 0.8.0 */ .domainHasCurrentSnapshot = esxDomainHasCurrentSnapshot, /* 0.8.0 */ + .domainSnapshotGetParent = esxDomainSnapshotGetParent, /* 0.9.7 */ .domainSnapshotCurrent = esxDomainSnapshotCurrent, /* 0.8.0 */ .domainRevertToSnapshot = esxDomainRevertToSnapshot, /* 0.8.0 */ .domainSnapshotDelete = esxDomainSnapshotDelete, /* 0.8.0 */ -- GitLab