mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
snapshot: implement LIST_LEAVES flag in esx
Relatively straight-forward filtering. * src/esx/esx_vi.h (esxVI_GetNumberOfSnapshotTrees) (esxVI_GetSnapshotTreeNames): Add parameter. * src/esx/esx_vi.c (esxVI_GetNumberOfSnapshotTrees) (esxVI_GetSnapshotTreeNames): Allow leaf filtering. * src/esx/esx_driver.c (esxDomainSnapshotNum) (esxDomainSnapshotListNames, esxDomainSnapshotNumChildren) (esxDomainSnapshotListChildrenNames): Pass new flag through.
This commit is contained in:
parent
9f4b49cdfc
commit
e570d7c4d6
@ -4359,11 +4359,14 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
|
||||
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;
|
||||
@ -4378,7 +4381,8 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList, recurse);
|
||||
count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList, recurse,
|
||||
leaves);
|
||||
|
||||
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
|
||||
|
||||
@ -4395,11 +4399,14 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
|
||||
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"));
|
||||
@ -4420,7 +4427,7 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
|
||||
}
|
||||
|
||||
result = esxVI_GetSnapshotTreeNames(rootSnapshotTreeList, names, nameslen,
|
||||
recurse);
|
||||
recurse, leaves);
|
||||
|
||||
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
|
||||
|
||||
@ -4437,11 +4444,14 @@ esxDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned int flags)
|
||||
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;
|
||||
@ -4462,7 +4472,7 @@ esxDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned int flags)
|
||||
}
|
||||
|
||||
count = esxVI_GetNumberOfSnapshotTrees(snapshotTree->childSnapshotList,
|
||||
recurse);
|
||||
recurse, leaves);
|
||||
|
||||
cleanup:
|
||||
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
|
||||
@ -4482,11 +4492,14 @@ esxDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
|
||||
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"));
|
||||
@ -4516,7 +4529,7 @@ esxDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
|
||||
}
|
||||
|
||||
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
|
||||
names, nameslen, recurse);
|
||||
names, nameslen, recurse, leaves);
|
||||
|
||||
cleanup:
|
||||
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
|
||||
|
@ -2161,17 +2161,19 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
|
||||
|
||||
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;
|
||||
@ -2181,7 +2183,8 @@ esxVI_GetNumberOfSnapshotTrees
|
||||
|
||||
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;
|
||||
@ -2191,15 +2194,17 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
||||
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;
|
||||
}
|
||||
@ -2208,7 +2213,7 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
||||
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
|
||||
names + count,
|
||||
nameslen - count,
|
||||
true);
|
||||
true, leaves);
|
||||
|
||||
if (result < 0) {
|
||||
goto failure;
|
||||
|
@ -359,11 +359,11 @@ int esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
|
||||
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user