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. 18 3月, 2014 1 次提交
  4. 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
  5. 10 7月, 2013 1 次提交
  6. 24 5月, 2013 1 次提交
  7. 21 5月, 2013 1 次提交
  8. 21 12月, 2012 3 次提交
  9. 23 8月, 2012 1 次提交
  10. 19 4月, 2012 1 次提交
  11. 27 3月, 2012 1 次提交
    • M
      Cleanup for a return statement in source files · 9943276f
      Martin Kletzander 提交于
      Return statements with parameter enclosed in parentheses were modified
      and parentheses were removed. The whole change was scripted, here is how:
      
      List of files was obtained using this command:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$'
      
      Found files were modified with this command:
      sed -i -e                                                                 \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      
      Then checked for nonsense.
      
      The whole command looks like this:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e                            \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      9943276f
  12. 27 1月, 2012 1 次提交
    • E
      hash: minor touchups · 19896423
      Eric Blake 提交于
      On RHEL5, I got:
      util/virrandom.c:66: warning: nested extern declaration of '_gl_verify_function66' [-Wnested-externs]
      
      The fix is to hoist the verify earlier.  Also some other hodge-podge
      fixes I noticed while reviewing Dan's recent series.
      
      * .gitignore: Ignore new test.
      * src/util/cgroup.c: Bump copyright year.
      * src/util/virhash.c: Fix typo in description.
      * src/util/virrandom.c (virRandomBits): Mark doc comment, and
      hoist assert to silence older gcc.
      19896423
  13. 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
  14. 24 1月, 2012 1 次提交
  15. 19 11月, 2011 1 次提交
  16. 11 10月, 2011 1 次提交
    • E
      maint: typo fixes · dbbe16c2
      Eric Blake 提交于
      I noticed a couple typos in recent commits, and fixed the remaining
      instances of them.
      
      * docs/internals/command.html.in: Fix spelling errors.
      * include/libvirt/libvirt.h.in (virConnectDomainEventCallback):
      Likewise.
      * python/libvirt-override.py (virEventAddHandle): Likewise.
      * src/lxc/lxc_container.c (lxcContainerChild): Likewise.
      * src/util/hash.c (virHashCreateFull): Likewise.
      * src/storage/storage_backend_logical.c
      (virStorageBackendLogicalMakeVol): Likewise.
      * src/esx/esx_driver.c (esxFormatVMXFileName): Likewise.
      * src/vbox/vbox_tmpl.c (vboxIIDIsEqual_v3_x): Likewise.
      dbbe16c2
  17. 12 5月, 2011 1 次提交
    • L
      libvirt,logging: cleanup VIR_XXX0() · b65f37a4
      Lai Jiangshan 提交于
      These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.
      
      How do these coversions works? The magic is using the gcc extension of ##.
      When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to
      avoid compile error.
      
      example: origin				after CPP
      	high_level_api("%d", a_int)	low_level_api("%d", a_int)
      	high_level_api("a  string")	low_level_api("a  string")
      
      About 400 conversions.
      
      8 special conversions:
      VIR_XXXX0("") -> VIR_XXXX("msg") (avoid empty format) 2 conversions
      VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions
      VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal)
        (for security) 6 conversions
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      b65f37a4
  18. 30 4月, 2011 1 次提交
    • E
      hash: fix memory leak regression · 701bee01
      Eric Blake 提交于
      Commit 1671d1dc introduced a memory leak in virHashFree, and
      wholesale table corruption in virHashRemoveSet (elements not
      requested to be freed are lost).
      
      * src/util/hash.c (virHashFree): Free bucket array.
      (virHashRemoveSet): Don't lose elements.
      * tests/hashtest.c (testHashCheckForEachCount): New method.
      (testHashCheckCount): Expose the bug.
      701bee01
  19. 27 4月, 2011 2 次提交
    • J
      util: Simplify hash implementation · 1671d1dc
      Jiri Denemark 提交于
      So far first entries for each hash key are stored directly in the hash
      table while other entries mapped to the same key are linked through
      pointers. As a result of that, the code is cluttered with special
      handling for the first items.
      
      This patch makes all entries (even the first ones) linked through
      pointers, which significantly simplifies the code and makes it more
      maintainable.
      1671d1dc
    • 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
  20. 13 4月, 2011 1 次提交
  21. 18 3月, 2011 1 次提交
    • J
      util: Forbid calling hash APIs from iterator callback · fba550f6
      Jiri Denemark 提交于
      Calling most hash APIs is not safe from inside of an iterator callback.
      Exceptions are APIs that do not modify the hash table and removing
      current hash entry from virHashFroEach callback.
      
      This patch make all APIs which are not safe fail instead of just relying
      on the callback being nice not calling any unsafe APIs.
      fba550f6
  22. 03 3月, 2011 1 次提交
    • J
      util: Allow removing hash entries in virHashForEach · 9677cd33
      Jiri Denemark 提交于
      This fixes a possible crash of libvirtd during its startup. When qemu
      driver reconnects to running domains, it iterates over all domain
      objects in a hash. When reconnecting to an associated qemu monitor
      fails and the domain is transient, it's immediately removed from the
      hash. Despite the fact that it's explicitly forbidden to do so. If
      libvirtd is lucky enough, virHashForEach will access random memory when
      the callback finishes and the deamon will crash.
      
      Since it's trivial to fix virHashForEach to allow removal of hash
      entries while iterating through them, I went this way instead of fixing
      qemuReconnectDomain callback (and possibly others) to avoid deleting the
      entries.
      9677cd33
  23. 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
  24. 24 2月, 2011 1 次提交
  25. 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
  26. 18 2月, 2011 3 次提交
    • C
      factor common code in virHashAddEntry and virHashUpdateEntry · 7f1c65e5
      Christophe Fergeau 提交于
      The only difference between these 2 functions is that one errors
      out when the entry is already present while the other modifies
      the existing entry. Add an helper function with a boolean argument
      indicating whether existing entries should be updated or not, and
      use this helper in both functions.
      7f1c65e5
    • C
      add hash table rebalancing in virHashUpdateEntry · 5c5880e0
      Christophe Fergeau 提交于
      The code in virHashUpdateEntry and virHashAddEntry is really
      similar. However, the latter rebalances the hash table when
      one of its buckets contains too many elements while the former
      does not. Fix this discrepancy.
      5c5880e0
    • E
      hash: modernize debug code · aebe04d7
      Eric Blake 提交于
      * src/util/hash.c (virHashGrow) [DEBUG_GROW]: Use modern logging.
      Reported by Christophe Fergeau.
      aebe04d7
  27. 15 2月, 2011 1 次提交
  28. 14 2月, 2011 1 次提交
  29. 01 2月, 2010 1 次提交
  30. 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
  31. 21 9月, 2009 2 次提交
    • 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
    • D
      Move all XML configuration handling to src/conf/ · e0a48c99
      Daniel P. Berrange 提交于
      * src/capabilities.c, src/capabilities.h, src/domain_conf.c,
        src/domain_conf.h, src/domain_event.c, src/domain_event.h,
        src/interface_conf.c, src/interface_conf.h,
        src/network_conf.c, src/network_conf.h, src/node_device_conf.c,
        src/node_device_conf.h, src/secret_conf.c, src/secret_conf.h,
        src/storage_conf.c, src/storage_conf.h, src/storage_encryption_conf.c,
        src/storage_encryption_conf.h: Move to src/conf/
      * src/Makefile.am: Add -Isrc/conf to the individual build targets
        which need to use XML config APIs. Remove LIBXML_CFLAGS, LIBSSH2_CFLAGS
        and SELINUX_CFLAGS from global INCLUDES and only have them in build
        targets which actually need them.  Create a libvirt_conf.la
        convenience library for all config parsers
      * src/hostusb.h: Remove bogus include of domain_conf.h
      * tests/Makefile.am: Add -Isrc/conf. Remove bogus -I$builddir/src
        since it never has any generated header files
      * daemon/Makefile.am: Add -Isrc/conf
      * proxy/Makefile.am: Add -Isrc/conf and cope with renamed files
      * src/hash.c: Remove bogus include of libxml/threads.h
      e0a48c99