1. 16 4月, 2013 4 次提交
    • D
      Refactor cgroups internal data structures · 8d1c141a
      Daniel P. Berrange 提交于
      Currently the virCgroupPtr struct contains 3 pieces of
      information
      
       - path - path of the cgroup, relative to current process'
         cgroup placement
       - placement - current process' placement in each controller
       - mounts - mount point of each controller
      
      When reading/writing cgroup settings, the path & placement
      strings are combined to form the file path. This approach
      only works if we assume all cgroups will be relative to
      the current process' cgroup placement.
      
      To allow support for managing cgroups at any place in the
      heirarchy a change is needed. The 'placement' data should
      reflect the absolute path to the cgroup, and the 'path'
      value should no longer be used to form the paths to the
      cgroup attribute files.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      8d1c141a
    • D
      Rename virCgroupForXXX to virCgroupNewXXX · 04c18d25
      Daniel P. Berrange 提交于
      Rename all the virCgroupForXXX methods to use the form
      virCgroupNewXXX since they are all constructors. Also
      make sure the output parameter is the last one in the
      list, and annotate all pointers as non-null. Fix up
      all callers, and make sure they use true/false not 0/1
      for the boolean parameters
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      04c18d25
    • D
      Pull definition of structs out of vircgroup.c to vircgrouppriv.h · f0e5f924
      Daniel P. Berrange 提交于
      The definition of structs for cgroups are kept in vircgroup.c since
      they are intended to be private from users of the API. To enable
      effective testing, however, they need to be accessible. To address
      the latter issue, without compronmising the former, this introduces
      a new vircgrouppriv.h file to hold the struct definitions.
      
      To prevent other files including this private header, it requires
      that __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__ be defined before inclusion
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      f0e5f924
    • D
      Add missing param to virCgroupForDriver stub · c9b8cdfe
      Daniel P. Berrange 提交于
      The virCgroupForDriver method recently gained an 'int controllers'
      parameter, but the stub impl did not
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c9b8cdfe
  2. 08 4月, 2013 1 次提交
  3. 05 4月, 2013 2 次提交
  4. 21 3月, 2013 1 次提交
  5. 28 2月, 2013 1 次提交
    • D
      Avoid spamming logs with cgroups warnings · 279336c5
      Daniel P. Berrange 提交于
      The code for putting the emulator threads in a separate cgroup
      would spam the logs with warnings
      
      2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 3
      2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 4
      2013-02-27 16:08:26.732+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 6
      
      This is because it has only created child cgroups for 3 of the
      controllers, but was trying to move the processes from all the
      controllers. The fix is to only try to move threads in the
      controllers we actually created. Also remove the warning and
      make it return a hard error to avoid such lazy callers in the
      future.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      279336c5
  6. 21 12月, 2012 4 次提交
  7. 13 12月, 2012 1 次提交
  8. 30 11月, 2012 1 次提交
  9. 29 11月, 2012 1 次提交
  10. 28 11月, 2012 2 次提交
  11. 25 11月, 2012 1 次提交
  12. 12 10月, 2012 1 次提交
  13. 21 9月, 2012 1 次提交
  14. 31 8月, 2012 1 次提交
    • G
      cgroup: read more data from cgroup cpuacct.usage_percpu · c402eebc
      Guannan Ren 提交于
      On NUMA machine, the length of string got from file
      cpuacct.usage_percpu is quite large, so expand the
      limit of 1024 bytes.
      
      errors like:
      Failed to read file \
      '/cgroup/cpuacct/libvirt/qemu/rhel6q/cpuacct.usage_percpu': \
      Value too large for defined data type
      c402eebc
  15. 22 8月, 2012 3 次提交
  16. 10 8月, 2012 1 次提交
    • E
      build: fix PROBE() usage of intptr_t · 51ee43aa
      Eric Blake 提交于
      Otherwise, in locations like virobject.c where PROBE is used,
      for certain configure options, the compiler warns:
      
      util/virobject.c:110:1: error: 'intptr_t' undeclared (first use in this function)
      
      As long as we are making this header always available, we can
      clean up several other files.
      
      * src/internal.h (includes): Pull in <stdint.h>.
      * src/conf/nwfilter_conf.h: Rely on internal.h.
      * src/storage/storage_backend.c: Likewise.
      * src/storage/storage_backend.h: Likewise.
      * src/util/cgroup.c: Likewise.
      * src/util/sexpr.h: Likewise.
      * src/util/virhashcode.h: Likewise.
      * src/util/virnetdevvportprofile.h: Likewise.
      * src/util/virnetlink.h: Likewise.
      * src/util/virrandom.h: Likewise.
      * src/vbox/vbox_driver.c: Likewise.
      * src/xenapi/xenapi_driver.c: Likewise.
      * src/xenapi/xenapi_utils.c: Likewise.
      * src/xenapi/xenapi_utils.h: Likewise.
      * src/xenxs/xenxs_private.h: Likewise.
      * tests/storagebackendsheepdogtest.c: Likewise.
      51ee43aa
  17. 27 7月, 2012 1 次提交
    • O
      maint: Use consistent copyright. · a4bcefbc
      Osier Yang 提交于
      This is a follow up patch of commit f9ce7dad, it modifies all
      the files which declare the copyright like "See COPYING.LIB for
      the License of this software" to use the detailed/consistent one.
      
      And deserts the outdated comments like:
      
       * libvirt-qemu.h:
       * Summary: qemu specific interfaces
       * Description: Provides the interfaces of the libvirt library to handle
       *              qemu specific methods
       *
       * Copy:  Copyright (C) 2010, 2012 Red Hat, Inc.
      
      Uses the more compact style like:
      
       * libvirt-qemu.h: Interfaces specific for QEMU/KVM driver
       *
       * Copyright (C) 2010, 2012 Red Hat, Inc.
      a4bcefbc
  18. 18 5月, 2012 1 次提交
    • H
      Adds support to param 'vcpu_time' in qemu_driver. · fe0aac05
      Hu Tao 提交于
      This involves setting the cpuacct cgroup to a per-vcpu granularity,
      as well as summing the each vcpu accounting into a common array.
      Now that we are reading more than one cgroup file, we double-check
      that cpus weren't hot-plugged between reads to invalidate our
      summing.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      fe0aac05
  19. 12 3月, 2012 1 次提交
    • E
      cpustats: collect VM user and sys times · 0d0b4098
      Eric Blake 提交于
      As documented in linux.git/Documentation/cgroups/cpuacct.txt,
      cpuacct.stat returns user and system time in ticks (the same
      unit used in times(2)).  It would be a bit nicer if it were like
      getrusage(2) and reported timeval contents, or like cpuacct.usage
      and in nanoseconds, but we can't be picky.
      
      * src/util/cgroup.h (virCgroupGetCpuacctStat): New function.
      * src/util/cgroup.c (virCgroupGetCpuacctStat): Implement it.
      (virCgroupGetValueStr): Allow for multi-line files.
      * src/libvirt_private.syms (cgroup.h): Export it.
      0d0b4098
  20. 07 3月, 2012 1 次提交
  21. 02 3月, 2012 1 次提交
    • E
      build: use correct type for pid and similar types · 3e2c3d8f
      Eric Blake 提交于
      No thanks to 64-bit windows, with 64-bit pid_t, we have to avoid
      constructs like 'int pid'.  Our API in libvirt-qemu cannot be
      changed without breaking ABI; but then again, libvirt-qemu can
      only be used on systems that support UNIX sockets, which rules
      out Windows (even if qemu could be compiled there) - so for all
      points on the call chain that interact with this API decision,
      we require a different variable name to make it clear that we
      audited the use for safety.
      
      Adding a syntax-check rule only solves half the battle; anywhere
      that uses printf on a pid_t still needs to be converted, but that
      will be a separate patch.
      
      * cfg.mk (sc_correct_id_types): New syntax check.
      * src/libvirt-qemu.c (virDomainQemuAttach): Document why we didn't
      use pid_t for pid, and validate for overflow.
      * include/libvirt/libvirt-qemu.h (virDomainQemuAttach): Tweak name
      for syntax check.
      * src/vmware/vmware_conf.c (vmwareExtractPid): Likewise.
      * src/driver.h (virDrvDomainQemuAttach): Likewise.
      * tools/virsh.c (cmdQemuAttach): Likewise.
      * src/remote/qemu_protocol.x (qemu_domain_attach_args): Likewise.
      * src/qemu_protocol-structs (qemu_domain_attach_args): Likewise.
      * src/util/cgroup.c (virCgroupPidCode, virCgroupKillInternal):
      Likewise.
      * src/qemu/qemu_command.c(qemuParseProcFileStrings): Likewise.
      (qemuParseCommandLinePid): Use pid_t for pid.
      * daemon/libvirtd.c (daemonForkIntoBackground): Likewise.
      * src/conf/domain_conf.h (_virDomainObj): Likewise.
      * src/probes.d (rpc_socket_new): Likewise.
      * src/qemu/qemu_command.h (qemuParseCommandLinePid): Likewise.
      * src/qemu/qemu_driver.c (qemudGetProcessInfo, qemuDomainAttach):
      Likewise.
      * src/qemu/qemu_process.c (qemuProcessAttach): Likewise.
      * src/qemu/qemu_process.h (qemuProcessAttach): Likewise.
      * src/uml/uml_driver.c (umlGetProcessInfo): Likewise.
      * src/util/virnetdev.h (virNetDevSetNamespace): Likewise.
      * src/util/virnetdev.c (virNetDevSetNamespace): Likewise.
      * tests/testutils.c (virtTestCaptureProgramOutput): Likewise.
      * src/conf/storage_conf.h (_virStoragePerms): Use mode_t, uid_t,
      and gid_t rather than int.
      * src/security/security_dac.c (virSecurityDACSetOwnership): Likewise.
      * src/conf/storage_conf.c (virStorageDefParsePerms): Avoid
      compiler warning.
      3e2c3d8f
  22. 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
  23. 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
  24. 21 12月, 2011 1 次提交
  25. 30 11月, 2011 1 次提交
  26. 29 11月, 2011 1 次提交
  27. 01 9月, 2011 1 次提交
    • D
      Don't leak memory if a cgroup is mounted multiple times · c32536e7
      Daniel P. Berrange 提交于
      It is possible (expected/likely in Fedora 15) for a cgroup controller
      to be mounted in multiple locations at the same time, due to bind
      mounts. Currently we leak memory if this happens, because we overwrite
      the previous 'mountPoint' string. Instead just accept the first match
      we find.
      
      * src/util/cgroup.c: Only accept first match for a cgroup
        controller mount
      c32536e7
  28. 22 7月, 2011 1 次提交
    • E
      build: rename files.h to virfile.h · 8e22e089
      Eric Blake 提交于
      In preparation for a future patch adding new virFile APIs.
      
      * src/util/files.h, src/util/files.c: Move...
      * src/util/virfile.h, src/util/virfile.c: ...here, and rename
      functions to virFile prefix.  Macro names are intentionally
      left alone.
      * *.c: All '#include "files.h"' uses changed.
      * src/Makefile.am (UTIL_SOURCES): Reflect rename.
      * cfg.mk (exclude_file_name_regexp--sc_prohibit_close): Likewise.
      * src/libvirt_private.syms: Likewise.
      * docs/hacking.html.in: Likewise.
      * HACKING: Regenerate.
      8e22e089