esxPrivate *priv = domain->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
bool recurse;
+ bool leaves;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+ VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
+ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0;
+ leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
return -1;
}
- count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList, recurse);
+ count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList, recurse,
+ leaves);
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
esxPrivate *priv = domain->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
bool recurse;
+ bool leaves;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+ VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
+ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0;
+ leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
if (names == NULL || nameslen < 0) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
}
result = esxVI_GetSnapshotTreeNames(rootSnapshotTreeList, names, nameslen,
- recurse);
+ recurse, leaves);
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
bool recurse;
+ bool leaves;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+ VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
+ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) != 0;
+ leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
count = esxVI_GetNumberOfSnapshotTrees(snapshotTree->childSnapshotList,
- recurse);
+ recurse, leaves);
cleanup:
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
bool recurse;
+ bool leaves;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+ VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
+ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) != 0;
+ leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
if (names == NULL || nameslen < 0) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
}
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
- names, nameslen, recurse);
+ names, nameslen, recurse, leaves);
cleanup:
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
int
esxVI_GetNumberOfSnapshotTrees
- (esxVI_VirtualMachineSnapshotTree *snapshotTreeList, bool recurse)
+ (esxVI_VirtualMachineSnapshotTree *snapshotTreeList, bool recurse,
+ bool leaves)
{
int count = 0;
esxVI_VirtualMachineSnapshotTree *snapshotTree;
for (snapshotTree = snapshotTreeList; snapshotTree != NULL;
snapshotTree = snapshotTree->_next) {
- count++;
+ if (!(leaves && snapshotTree->childSnapshotList))
+ count++;
if (recurse)
count += esxVI_GetNumberOfSnapshotTrees
- (snapshotTree->childSnapshotList, true);
+ (snapshotTree->childSnapshotList, true, leaves);
}
return count;
int
esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
- char **names, int nameslen, bool recurse)
+ char **names, int nameslen, bool recurse,
+ bool leaves)
{
int count = 0;
int result;
for (snapshotTree = snapshotTreeList;
snapshotTree != NULL && count < nameslen;
snapshotTree = snapshotTree->_next) {
- names[count] = strdup(snapshotTree->name);
+ if (!(leaves && snapshotTree->childSnapshotList)) {
+ names[count] = strdup(snapshotTree->name);
- if (names[count] == NULL) {
- virReportOOMError();
- goto failure;
- }
+ if (names[count] == NULL) {
+ virReportOOMError();
+ goto failure;
+ }
- count++;
+ count++;
+ }
if (count >= nameslen) {
break;
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
names + count,
nameslen - count,
- true);
+ true, leaves);
if (result < 0) {
goto failure;
int esxVI_GetNumberOfSnapshotTrees
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
- bool recurse);
+ bool recurse, bool leaves);
int esxVI_GetSnapshotTreeNames
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, char **names,
- int nameslen, bool recurse);
+ int nameslen, bool recurse, bool leaves);
int esxVI_GetSnapshotTreeByName
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, const char *name,