On Fri, Oct 07, 2011 at 08:37:04PM -0600, Eric Blake wrote:
With the recent refactoring of qemu snapshot relationships, it
is now trivial to filter on leaves.
* src/conf/domain_conf.c (virDomainSnapshotObjListCount)
(virDomainSnapshotObjListCopyNames): Handle new flag.
* src/qemu/qemu_driver.c (qemuDomainSnapshotListNames)
(qemuDomainSnapshotNum, qemuDomainSnapshotListChildrenNames)
(qemuDomainSnapshotNumChildren): Pass new flag through.
---
src/conf/domain_conf.c | 8 ++++++--
src/qemu/qemu_driver.c | 12 ++++++++----
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d52a79f..c2f599f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12148,7 +12148,9 @@ static void virDomainSnapshotObjListCopyNames(void *payload,
if (data->oom)
return;
- if ((data->flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) &&
obj->def->parent)
+ /* LIST_ROOTS/LIST_DESCENDANTS was handled by caller,
+ * LIST_METADATA is a no-op if we get this far. */
+ if ((data->flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) &&
obj->nchildren)
return;
if (data->numnames < data->maxnames) {
@@ -12233,7 +12235,9 @@ static void virDomainSnapshotObjListCount(void *payload,
virDomainSnapshotObjPtr obj = payload;
struct virDomainSnapshotNumData *data = opaque;
- if ((data->flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) &&
obj->def->parent)
+ /* LIST_ROOTS/LIST_DESCENDANTS was handled by caller,
+ * LIST_METADATA is a no-op if we get this far. */
+ if ((data->flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) &&
obj->nchildren)
return;
data->count++;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7a134e3..3264d2c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9415,7 +9415,8 @@ static int qemuDomainSnapshotListNames(virDomainPtr domain, char
**names,
int n = -1;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+ VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
+ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, domain->uuid);
@@ -9445,7 +9446,8 @@ static int qemuDomainSnapshotNum(virDomainPtr domain,
int n = -1;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+ VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
+ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, domain->uuid);
@@ -9482,7 +9484,8 @@ qemuDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
int n = -1;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+ VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
+ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, snapshot->domain->uuid);
@@ -9521,7 +9524,8 @@ qemuDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
int n = -1;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
+ VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
+ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, snapshot->domain->uuid);
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/