提交 827a992a 编写于 作者: E Eric Blake

snapshot: implement snapshot roots listing in esx

Commit 9f5e53e2 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.
上级 12062abb
......@@ -4359,8 +4359,12 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
int count;
esxPrivate *priv = domain->conn->privateData;
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) {
return -1;
......@@ -4375,7 +4379,7 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
return -1;
}
count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList);
count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList, recurse);
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
......@@ -4391,8 +4395,12 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
int result;
esxPrivate *priv = domain->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
bool recurse;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0;
if (names == NULL || nameslen < 0) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
......@@ -4412,7 +4420,8 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
return -1;
}
result = esxVI_GetSnapshotTreeNames(rootSnapshotTreeList, names, nameslen);
result = esxVI_GetSnapshotTreeNames(rootSnapshotTreeList, names, nameslen,
recurse);
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
......
......@@ -2164,15 +2164,17 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
int
esxVI_GetNumberOfSnapshotTrees
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList)
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, bool recurse)
{
int count = 0;
esxVI_VirtualMachineSnapshotTree *snapshotTree;
for (snapshotTree = snapshotTreeList; snapshotTree != NULL;
snapshotTree = snapshotTree->_next) {
count += 1 + esxVI_GetNumberOfSnapshotTrees
(snapshotTree->childSnapshotList);
count++;
if (recurse)
count += esxVI_GetNumberOfSnapshotTrees
(snapshotTree->childSnapshotList, true);
}
return count;
......@@ -2182,7 +2184,7 @@ esxVI_GetNumberOfSnapshotTrees
int
esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
char **names, int nameslen)
char **names, int nameslen, bool recurse)
{
int count = 0;
int result;
......@@ -2205,14 +2207,18 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
break;
}
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
names + count, nameslen - count);
if (recurse) {
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
names + count,
nameslen - count,
true);
if (result < 0) {
goto failure;
}
if (result < 0) {
goto failure;
}
count += result;
count += result;
}
}
return count;
......
......@@ -2,6 +2,7 @@
/*
* 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>
*
* 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 esxVI_GetNumberOfSnapshotTrees
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList);
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
bool recurse);
int esxVI_GetSnapshotTreeNames
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, char **names,
int nameslen);
int nameslen, bool recurse);
int esxVI_GetSnapshotTreeByName
(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, const char *name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册