]> git.ipfire.org Git - thirdparty/libvirt.git/commit
snapshot: framework for more efficient relation traversal
authorEric Blake <eblake@redhat.com>
Fri, 7 Oct 2011 18:41:50 +0000 (12:41 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 11 Oct 2011 23:08:43 +0000 (17:08 -0600)
commit7ec6f7bd339e665ea0769890763f08cae735391b
tree52d2ef09260d15ccec3e181ee58c7e0624b95138
parent59f179ce646698354fde59f12331d56a94d5164d
snapshot: framework for more efficient relation traversal

No one was using virDomainSnapshotHasChildren, but that was an
O(n) function.  Exposing and tracking a bit more metadata for each
snapshot will allow the same query to be made with an O(1) query
of the member field.  For single snapshot operations (create,
delete), callers can be trusted to maintain the metadata themselves,
but for reloading, we can't compute parents as we go since there
is no guarantee that parents were parsed before children, so we also
provide a function to refresh the relationships, and which can
be used to detect if the user has ignored our warnings and been
directly modifying files in /var/lib/libvirt/qemu/snapshot.  This
patch only adds metadata; later patches will actually use it.

This layout intentionally hardcodes the size of each snapshot struct,
by tracking sibling pointers, rather than having to deal with the
headache of yet more memory management by directly sticking a
dynamically sized child[] on each parent.

* src/conf/domain_conf.h (_virDomainSnapshotObj)
(_virDomainSnapshotObjList): Add members.
(virDomainSnapshotUpdateRelations, virDomainSnapshotDropParent):
New prototypes.
(virDomainSnapshotHasChildren): Delete.
* src/conf/domain_conf.c (virDomainSnapshotSetRelations)
(virDomainSnapshotUpdateRelations, virDomainSnapshotDropParent):
New functions.
(virDomainSnapshotHasChildren): Drop unused function.
* src/libvirt_private.syms (domain_conf): Update exports.
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms