• D
    Convert virDomainObjListPtr to use a hash of domain objects · a3adcce7
    Daniel P. Berrange 提交于
    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
    a3adcce7
domain_conf.c 157.8 KB