mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
snapshot: implement snapshot roots listing in esx
Commit 9f5e53e
introduced the ability to filter snapshots to
just roots, but it was never implemented for ESX until now.
* src/esx/esx_vi.h (esxVI_GetNumberOfSnapshotTrees)
(esxVI_GetSnapshotTreeNames): Add parameter.
* src/esx/esx_vi.c (esxVI_GetNumberOfSnapshotTrees)
(esxVI_GetSnapshotTreeNames): Allow choice of recursion or not.
* src/esx/esx_driver.c (esxDomainSnapshotNum)
(esxDomainSnapshotListNames): Use it to limit to roots.
This commit is contained in:
parent
12062abb89
commit
827a992a13
@ -4359,8 +4359,12 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
|
|||||||
int count;
|
int count;
|
||||||
esxPrivate *priv = domain->conn->privateData;
|
esxPrivate *priv = domain->conn->privateData;
|
||||||
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
|
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
|
||||||
|
bool recurse;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
|
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
|
||||||
|
VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
|
||||||
|
|
||||||
|
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0;
|
||||||
|
|
||||||
if (esxVI_EnsureSession(priv->primary) < 0) {
|
if (esxVI_EnsureSession(priv->primary) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -4375,7 +4379,7 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList);
|
count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList, recurse);
|
||||||
|
|
||||||
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
|
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
|
||||||
|
|
||||||
@ -4391,8 +4395,12 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
|
|||||||
int result;
|
int result;
|
||||||
esxPrivate *priv = domain->conn->privateData;
|
esxPrivate *priv = domain->conn->privateData;
|
||||||
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
|
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
|
||||||
|
bool recurse;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
|
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
|
||||||
|
VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
|
||||||
|
|
||||||
|
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0;
|
||||||
|
|
||||||
if (names == NULL || nameslen < 0) {
|
if (names == NULL || nameslen < 0) {
|
||||||
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
|
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
|
||||||
@ -4412,7 +4420,8 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = esxVI_GetSnapshotTreeNames(rootSnapshotTreeList, names, nameslen);
|
result = esxVI_GetSnapshotTreeNames(rootSnapshotTreeList, names, nameslen,
|
||||||
|
recurse);
|
||||||
|
|
||||||
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
|
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
|
||||||
|
|
||||||
|
@ -2164,15 +2164,17 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
|
|||||||
|
|
||||||
int
|
int
|
||||||
esxVI_GetNumberOfSnapshotTrees
|
esxVI_GetNumberOfSnapshotTrees
|
||||||
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList)
|
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, bool recurse)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
esxVI_VirtualMachineSnapshotTree *snapshotTree;
|
esxVI_VirtualMachineSnapshotTree *snapshotTree;
|
||||||
|
|
||||||
for (snapshotTree = snapshotTreeList; snapshotTree != NULL;
|
for (snapshotTree = snapshotTreeList; snapshotTree != NULL;
|
||||||
snapshotTree = snapshotTree->_next) {
|
snapshotTree = snapshotTree->_next) {
|
||||||
count += 1 + esxVI_GetNumberOfSnapshotTrees
|
count++;
|
||||||
(snapshotTree->childSnapshotList);
|
if (recurse)
|
||||||
|
count += esxVI_GetNumberOfSnapshotTrees
|
||||||
|
(snapshotTree->childSnapshotList, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@ -2182,7 +2184,7 @@ esxVI_GetNumberOfSnapshotTrees
|
|||||||
|
|
||||||
int
|
int
|
||||||
esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
||||||
char **names, int nameslen)
|
char **names, int nameslen, bool recurse)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int result;
|
int result;
|
||||||
@ -2205,14 +2207,18 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
|
if (recurse) {
|
||||||
names + count, nameslen - count);
|
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
|
||||||
|
names + count,
|
||||||
|
nameslen - count,
|
||||||
|
true);
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
goto failure;
|
goto failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
count += result;
|
||||||
}
|
}
|
||||||
|
|
||||||
count += result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* esx_vi.h: client for the VMware VI API 2.5 to manage ESX hosts
|
* esx_vi.h: client for the VMware VI API 2.5 to manage ESX hosts
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2011 Red Hat, Inc.
|
||||||
* Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte@googlemail.com>
|
* Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte@googlemail.com>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -357,11 +358,12 @@ int esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
|
|||||||
int *id, char **name, unsigned char *uuid);
|
int *id, char **name, unsigned char *uuid);
|
||||||
|
|
||||||
int esxVI_GetNumberOfSnapshotTrees
|
int esxVI_GetNumberOfSnapshotTrees
|
||||||
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList);
|
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
||||||
|
bool recurse);
|
||||||
|
|
||||||
int esxVI_GetSnapshotTreeNames
|
int esxVI_GetSnapshotTreeNames
|
||||||
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, char **names,
|
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, char **names,
|
||||||
int nameslen);
|
int nameslen, bool recurse);
|
||||||
|
|
||||||
int esxVI_GetSnapshotTreeByName
|
int esxVI_GetSnapshotTreeByName
|
||||||
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, const char *name,
|
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, const char *name,
|
||||||
|
Loading…
Reference in New Issue
Block a user