mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
snapshot: simplify esx snapshot name lookup
No need to request the parent of a snapshot if we aren't going to use it. * src/esx/esx_vi.c (esxVI_GetSnapshotTreeByName): Make parent optional. * src/esx/esx_driver.c (esxDomainSnapshotCreateXML) (esxDomainSnapshotLookupByName, esxDomainRevertToSnapshot) (esxDomainSnapshotDelete): Simplify accordingly.
This commit is contained in:
parent
827a992a13
commit
f045583372
@ -4228,7 +4228,6 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
|
|||||||
esxVI_ObjectContent *virtualMachine = NULL;
|
esxVI_ObjectContent *virtualMachine = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
|
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
|
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL;
|
|
||||||
esxVI_ManagedObjectReference *task = NULL;
|
esxVI_ManagedObjectReference *task = NULL;
|
||||||
esxVI_TaskInfoState taskInfoState;
|
esxVI_TaskInfoState taskInfoState;
|
||||||
char *taskInfoErrorMessage = NULL;
|
char *taskInfoErrorMessage = NULL;
|
||||||
@ -4259,7 +4258,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
|
|||||||
esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
|
esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
|
||||||
&rootSnapshotList) < 0 ||
|
&rootSnapshotList) < 0 ||
|
||||||
esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name,
|
esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name,
|
||||||
&snapshotTree, &snapshotTreeParent,
|
&snapshotTree, NULL,
|
||||||
esxVI_Occurrence_OptionalItem) < 0) {
|
esxVI_Occurrence_OptionalItem) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -4437,7 +4436,6 @@ esxDomainSnapshotLookupByName(virDomainPtr domain, const char *name,
|
|||||||
esxPrivate *priv = domain->conn->privateData;
|
esxPrivate *priv = domain->conn->privateData;
|
||||||
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
|
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
|
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL;
|
|
||||||
virDomainSnapshotPtr snapshot = NULL;
|
virDomainSnapshotPtr snapshot = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
@ -4449,7 +4447,7 @@ esxDomainSnapshotLookupByName(virDomainPtr domain, const char *name,
|
|||||||
if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
|
if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
|
||||||
&rootSnapshotTreeList) < 0 ||
|
&rootSnapshotTreeList) < 0 ||
|
||||||
esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, name, &snapshotTree,
|
esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, name, &snapshotTree,
|
||||||
&snapshotTreeParent,
|
NULL,
|
||||||
esxVI_Occurrence_RequiredItem) < 0) {
|
esxVI_Occurrence_RequiredItem) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -4567,7 +4565,6 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags)
|
|||||||
esxPrivate *priv = snapshot->domain->conn->privateData;
|
esxPrivate *priv = snapshot->domain->conn->privateData;
|
||||||
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
|
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
|
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL;
|
|
||||||
esxVI_ManagedObjectReference *task = NULL;
|
esxVI_ManagedObjectReference *task = NULL;
|
||||||
esxVI_TaskInfoState taskInfoState;
|
esxVI_TaskInfoState taskInfoState;
|
||||||
char *taskInfoErrorMessage = NULL;
|
char *taskInfoErrorMessage = NULL;
|
||||||
@ -4581,7 +4578,7 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags)
|
|||||||
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
|
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
|
||||||
&rootSnapshotList) < 0 ||
|
&rootSnapshotList) < 0 ||
|
||||||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
|
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
|
||||||
&snapshotTree, &snapshotTreeParent,
|
&snapshotTree, NULL,
|
||||||
esxVI_Occurrence_RequiredItem) < 0) {
|
esxVI_Occurrence_RequiredItem) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -4621,7 +4618,6 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
|
|||||||
esxPrivate *priv = snapshot->domain->conn->privateData;
|
esxPrivate *priv = snapshot->domain->conn->privateData;
|
||||||
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
|
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
|
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL;
|
|
||||||
esxVI_Boolean removeChildren = esxVI_Boolean_False;
|
esxVI_Boolean removeChildren = esxVI_Boolean_False;
|
||||||
esxVI_ManagedObjectReference *task = NULL;
|
esxVI_ManagedObjectReference *task = NULL;
|
||||||
esxVI_TaskInfoState taskInfoState;
|
esxVI_TaskInfoState taskInfoState;
|
||||||
@ -4641,7 +4637,7 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
|
|||||||
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
|
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
|
||||||
&rootSnapshotList) < 0 ||
|
&rootSnapshotList) < 0 ||
|
||||||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
|
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
|
||||||
&snapshotTree, &snapshotTreeParent,
|
&snapshotTree, NULL,
|
||||||
esxVI_Occurrence_RequiredItem) < 0) {
|
esxVI_Occurrence_RequiredItem) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -2243,7 +2243,7 @@ esxVI_GetSnapshotTreeByName
|
|||||||
esxVI_VirtualMachineSnapshotTree *candidate;
|
esxVI_VirtualMachineSnapshotTree *candidate;
|
||||||
|
|
||||||
if (snapshotTree == NULL || *snapshotTree != NULL ||
|
if (snapshotTree == NULL || *snapshotTree != NULL ||
|
||||||
snapshotTreeParent == NULL || *snapshotTreeParent != NULL) {
|
(snapshotTreeParent && *snapshotTreeParent != NULL)) {
|
||||||
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2252,14 +2252,15 @@ esxVI_GetSnapshotTreeByName
|
|||||||
candidate = candidate->_next) {
|
candidate = candidate->_next) {
|
||||||
if (STREQ(candidate->name, name)) {
|
if (STREQ(candidate->name, name)) {
|
||||||
*snapshotTree = candidate;
|
*snapshotTree = candidate;
|
||||||
*snapshotTreeParent = NULL;
|
if (snapshotTreeParent)
|
||||||
|
*snapshotTreeParent = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_GetSnapshotTreeByName(candidate->childSnapshotList, name,
|
if (esxVI_GetSnapshotTreeByName(candidate->childSnapshotList, name,
|
||||||
snapshotTree, snapshotTreeParent,
|
snapshotTree, snapshotTreeParent,
|
||||||
occurrence) > 0) {
|
occurrence) > 0) {
|
||||||
if (*snapshotTreeParent == NULL) {
|
if (snapshotTreeParent && *snapshotTreeParent == NULL) {
|
||||||
*snapshotTreeParent = candidate;
|
*snapshotTreeParent = candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user