1. 10 7月, 2015 1 次提交
  2. 07 4月, 2014 1 次提交
    • E
      hash: add common utility functions · 09567144
      Eric Blake 提交于
      I almost wrote a hash value free function that just called
      VIR_FREE, then realized I couldn't be the first person to
      do that.  Sure enough, it was worth factoring into a common
      helper routine.
      
      * src/util/virhash.h (virHashValueFree): New function.
      * src/util/virhash.c (virHashValueFree): Implement it.
      * src/util/virobject.h (virObjectFreeHashData): New function.
      * src/libvirt_private.syms (virhash.h, virobject.h): Export them.
      * src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnInit): Use
      common function.
      * src/qemu/qemu_capabilities.c (virQEMUCapsCacheNew): Likewise.
      * src/qemu/qemu_command.c (qemuDomainCCWAddressSetCreate):
      Likewise.
      * src/qemu/qemu_monitor.c (qemuMonitorGetBlockInfo): Likewise.
      * src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
      * src/util/virclosecallbacks.c (virCloseCallbacksNew): Likewise.
      * src/util/virkeyfile.c (virKeyFileParseGroup): Likewise.
      * tests/qemumonitorjsontest.c
      (testQemuMonitorJSONqemuMonitorJSONGetBlockInfo): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      09567144
  3. 15 10月, 2013 1 次提交
    • E
      maint: avoid 'const fooPtr' in hashes · b43efdaa
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up virhash to provide a const-correct interface: all actions
      that don't modify the table take a const table.  Note that in
      one case (virHashSearch), we actually strip const away - we aren't
      modifying the contents of the table, so much as associated data
      for ensuring that the code uses the table correctly (if this were
      C++, it would be a case for the 'mutable' keyword).
      
      * src/util/virhash.h (virHashKeyComparator, virHashEqual): Use
      intended type.
      (virHashSize, virHashTableSize, virHashLookup, virHashSearch):
      Make const-correct.
      * src/util/virhash.c (virHashEqualData, virHashEqual)
      (virHashLookup, virHashSize, virHashTableSize, virHashSearch)
      (virHashComputeKey): Fix fallout.
      * src/conf/nwfilter_params.c
      (virNWFilterFormatParameterNameSorter): Likewise.
      * src/nwfilter/nwfilter_ebiptables_driver.c
      (ebiptablesFilterOrderSort): Likewise.
      * tests/virhashtest.c (testHashGetItemsCompKey)
      (testHashGetItemsCompValue): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b43efdaa
  4. 19 4月, 2012 1 次提交
  5. 27 1月, 2012 1 次提交
  6. 26 1月, 2012 3 次提交
    • D
      Replace hashing algorithm with murmurhash · 72b41397
      Daniel P. Berrange 提交于
      Recent discussions have illustrated the potential for DOS attacks
      with the hash table implementations used by most languages and
      libraries.
      
         https://lwn.net/Articles/474912/
      
      libvirt has an internal hash table impl, and uses hash tables for
      a variety of purposes. The hash key generation code is pretty
      simple and thus not strongly collision resistant.
      
      This patch replaces the current libvirt hash key generator with
      the (public domain) Murmurhash3 code. In addition every hash
      table now gets a random seed value which is used to perturb the
      hashing code. This should make it impossible to mount any
      practical attack against libvirt hashing code.
      
      * bootstrap.conf: Import bitrotate module
      * src/Makefile.am: Add virhashcode.[ch]
      * src/util/util.c: Make virRandom() return a fixed 32 bit
        integer value.
      * src/util/hash.c, src/util/hash.h, src/util/cgroup.c: Replace
        hash code generation with a call to virHashCodeGen()
      * src/util/virhashcode.h, src/util/virhashcode.c: Add a new
        virHashCodeGen() API using the Murmurhash3 algorithm.
      72b41397
    • D
      Rename hash.h and hash.c to virhash.h and virhash.c · 1d5c7a9f
      Daniel P. Berrange 提交于
      In preparation for the patch to include Murmurhash3, which
      introduces a virhashcode.h and virhashcode.c files, rename
      the existing hash.h and hash.c to virhash.h and virhash.c
      respectively.
      1d5c7a9f
    • D
      Convert various virHash functions to use size_t / uint32 · 9f2bf8fd
      Daniel P. Berrange 提交于
      In preparation for conversion over to use the Murmurhash3
      algorithm, convert various virHash APIs to use size_t or
      uint32 for their return values/parameters, instead of the
      variable size 'unsigned long' or 'int' types
      9f2bf8fd
  7. 24 1月, 2012 1 次提交
  8. 19 11月, 2011 1 次提交
  9. 27 4月, 2011 1 次提交
    • J
      tests: More unit tests for internal hash APIs · 91e12a50
      Jiri Denemark 提交于
      This adds several tests for remaining hash APIs (custom
      hasher/comparator functions are not covered yet, though).
      
      All tests pass both before and after the "Simplify hash implementation".
      91e12a50
  10. 25 2月, 2011 2 次提交
    • D
      Allow hash tables to use generic pointers as keys · 16ba2aaf
      Daniel P. Berrange 提交于
      Relax the restriction that the hash table key must be a string
      by allowing an arbitrary hash code generator + comparison func
      to be provided
      
      * util/hash.c, util/hash.h: Allow any pointer as a key
      * internal.h: Include stdbool.h as standard.
      * conf/domain_conf.c, conf/domain_conf.c,
        conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
        nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
        qemu/qemu_command.c, qemu/qemu_driver.c,
        qemu/qemu_process.c, uml/uml_driver.c,
        xen/xm_internal.c: s/char */void */ in hash callbacks
      16ba2aaf
    • D
      Remove deallocator parameter from hash functions · 6952708c
      Daniel P. Berrange 提交于
      Since the deallocator is passed into the constructor of
      a hash table it is not desirable to pass it into each
      function again. Remove it from all functions, but provide
      a virHashSteal to allow a item to be removed from a hash
      table without deleteing it.
      
      * src/util/hash.c, src/util/hash.h: Remove deallocator
        param from all functions. Add virHashSteal
      * src/libvirt_private.syms: Add virHashSteal
      * src/conf/domain_conf.c, src/conf/nwfilter_params.c,
        src/nwfilter/nwfilter_learnipaddr.c,
        src/qemu/qemu_command.c, src/xen/xm_internal.c: Update
        for changed hash API
      6952708c
  11. 21 2月, 2011 1 次提交
    • E
      hash: make virHashFree more free-like · 03ba07cb
      Eric Blake 提交于
      Two-argument free functions are uncommon; match the style elsewhere
      by caching the callback at creation.
      
      * src/util/hash.h (virHashCreate, virHashFree): Move deallocator
      argument to creation.
      * cfg.mk (useless_free_options): Add virHashFree.
      * src/util/hash.c (_virHashTable): Track deallocator.
      (virHashCreate, virHashFree): Update to new signature.
      * src/conf/domain_conf.c (virDomainObjListDeinit)
      (virDomainObjListInit, virDomainDiskDefForeachPath)
      (virDomainSnapshotObjListDeinit, virDomainSnapshotObjListInit):
      Update callers.
      * src/conf/nwfilter_params.c (virNWFilterHashTableFree)
      (virNWFilterHashTableCreate): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterTriggerVMFilterRebuild):
      Likewise.
      * src/cpu/cpu_generic.c (genericHashFeatures, genericBaseline):
      Likewise.
      * src/xen/xm_internal.c (xenXMOpen, xenXMClose): Likewise.
      * src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnInit)
      (virNWFilterLearnShutdown): Likewise.
      * src/qemu/qemu_command.c (qemuDomainPCIAddressSetCreate)
      (qemuDomainPCIAddressSetFree): Likewise.
      * src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
      03ba07cb
  12. 10 3月, 2010 1 次提交
  13. 19 10月, 2009 1 次提交
    • D
      Remove bogus const annotations to hash iterator · cf577653
      Daniel P. Berrange 提交于
      Most of the hash iterators need to modify either payload of
      data args. The const annotation prevents this.
      
      * src/util/hash.h, src/util/hash.c: Remove const-ness from
        virHashForEach/Iterator
      * src/xen/xm_internal.c: Remove bogus casts
      cf577653
  14. 21 9月, 2009 1 次提交
    • D
      Move all shared utility files to src/util/ · 1355e055
      Daniel P. Berrange 提交于
      * src/bridge.c, src/bridge.h, src/buf.c, src/buf.h, src/cgroup.c,
        src/cgroup.h, src/conf.c, src/conf.h, src/event.c, src/event.h,
        src/hash.c, src/hash.h, src/hostusb.c, src/hostusb.h,
        src/iptables.c, src/iptables.h, src/logging.c, src/logging.h,
        src/memory.c, src/memory.h, src/pci.c, src/pci.h, src/qparams.c,
        src/qparams.h, src/stats_linux.c, src/stats_linux.h,
        src/threads-pthread.c, src/threads-pthread.h, src/threads-win32.c,
        src/threads-win32.h, src/threads.c, src/threads.h, src/util.c,
        src/util.h, src/uuid.c, src/uuid.h, src/virterror.c,
        src/virterror_internal.h, src/xml.c, src/xml.h: Move all files
        into src/util/
      * daemon/Makefile.am: Add -Isrc/util/ to build flags
      * src/Makefile.am: Add -Isrc/util/ to build flags and update for
        moved files
      * src/libvirt_private.syms: Export cgroup APIs since they're now
        in util rather than linking directly to drivers
      * src/xen/xs_internal.c: Disable bogus virEventRemoveHandle call
        when built under PROXY
      * proxy/Makefile.am: Update for changed file locations. Remove
        bogus build of event.c
      * tools/Makefile.am, tests/Makefile.am: Add -Isrc/util/ to build flags
      1355e055
  15. 21 8月, 2008 1 次提交
  16. 11 4月, 2008 1 次提交
  17. 16 11月, 2006 1 次提交
  18. 09 4月, 2006 1 次提交
    • D
      * TODO src/hash.[ch] src/internal.h src/libvirt.c src/xend_internal.c · 572806a9
      Daniel Veillard 提交于
        src/xs_internal.c: implementing domain pointers unification, thread
        safety and reference counting for domain and connections, this was
        the last critical change needed before making further progresses at
        the API level. Still a couple fo things TODO for this, unification
        at the Python level and adding UUID to hash. All domain/connect alloc
        and free routines are now centralized in hash.c
      * docs/APIchunk1.html docs/libvirt-api.xml docs/libvirt-refs.xml
        docs/html/libvirt-libvirt.html: regenerated the docs, that doesn't
        change the API.
      Daniel
      572806a9
  19. 15 3月, 2006 1 次提交
  20. 20 12月, 2005 1 次提交
  21. 05 12月, 2005 1 次提交
  22. 30 11月, 2005 1 次提交