On Fri, Oct 23, 2009 at 02:05:30PM +0100, Daniel P. Berrange wrote:
The current virDomainObjListPtr object stores domain objects in
an array. This means that to find a particular objects requires
O(n) time, and more critically acquiring O(n) mutex locks.
The new impl replaces the array with a virHashTable, keyed off
UUID. Finding a object based on UUID is now O(1) time, and only
requires a single mutex lock. Finding by name/id is unchanged
in complexity.
In changing this, all code which iterates over the array had
to be updated to use a hash table iterator function callback.
Several of the functions which were identically duplicating
across all drivers were pulled into domain_conf.c
* src/conf/domain_conf.h, src/conf/domain_conf.c: Change
virDomainObjListPtr to use virHashTable. Add a initializer
method virDomainObjListInit, and rename virDomainObjListFree
to virDomainObjListDeinit, since its not actually freeing
the container, only its contents. Also add some convenient
methods virDomainObjListGetInactiveNames,
virDomainObjListGetActiveIDs and virDomainObjListNumOfDomains
which can be used to implement the correspondingly named
public API entry points in drivers
* src/libvirt_private.syms: Export new methods from domain_conf.h
* src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
src/openvz/openvz_conf.c, src/openvz/openvz_driver.c,
src/qemu/qemu_driver.c, src/test/test_driver.c,
src/uml/uml_driver.c, src/vbox/vbox_tmpl.c: Update all code
to deal with hash tables instead of arrays for domains
---
src/conf/domain_conf.c | 274 ++++++++++++++++++++++++++++++-------------
src/conf/domain_conf.h | 19 +++-
src/libvirt_private.syms | 6 +-
src/lxc/lxc_driver.c | 247 +++++++++++++++++----------------------
src/opennebula/one_driver.c | 68 +++--------
src/openvz/openvz_conf.c | 7 +-
src/openvz/openvz_driver.c | 25 ++---
src/qemu/qemu_driver.c | 221 ++++++++++++++--------------------
src/test/test_driver.c | 60 +++-------
src/uml/uml_driver.c | 125 +++++++++-----------
src/vbox/vbox_tmpl.c | 2 -
11 files changed, 519 insertions(+), 535 deletions(-)
Okay, this is a fairly intrusive patch, I looked but didn't spot
anything, I guess this is best handled by testing it as much as
possible. Since this is not directly related to the monitor handling
change, I would suggest to push it now to benefit from amximum testing.
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/