]> git.ipfire.org Git - thirdparty/libvirt.git/commit
snapshot: use metaroot node to simplify management
authorEric Blake <eblake@redhat.com>
Wed, 13 Jun 2012 19:13:02 +0000 (13:13 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 18 Jun 2012 21:11:28 +0000 (15:11 -0600)
commit06d4a1e429beee2ffc4e916bf1b8540c2ebe3c88
tree26d8b530a864b0eb0990d09305762ac45a4f1c11
parent7dcee3f9562938c3e25ca2b96fbc01f5e9251055
snapshot: use metaroot node to simplify management

This idea was first suggested by Daniel Veillard here:
https://www.redhat.com/archives/libvir-list/2011-October/msg00353.html

Now that I am about to add more complexity to snapshot listing, it
makes sense to avoid code duplication and special casing for domain
listing (all snapshots) vs. snapshot listing (descendants); adding
a metaroot reduces the number of code lines by having the domain
listing turn into a descendant listing of the metaroot.

Note that this has one minor pessimization - if we are going to list
ALL snapshots without filtering, then virHashForeach is more efficient
than recursing through the child relationships; restoring that minor
optimization will occur in the next patch.

* src/conf/domain_conf.h (_virDomainSnapshotObj)
(_virDomainSnapshotObjList): Repurpose some fields.
(virDomainSnapshotDropParent): Drop unused parameter.
* src/conf/domain_conf.c (virDomainSnapshotObjListGetNames)
(virDomainSnapshotObjListCount): Simplify.
(virDomainSnapshotFindByName, virDomainSnapshotSetRelations)
(virDomainSnapshotDropParent): Match new field semantics.
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML)
(qemuDomainSnapshotReparentChildren, qemuDomainSnapshotDelete):
Adjust clients.
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_driver.c