1. 29 11月, 2011 1 次提交
  2. 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
  3. 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
  4. 21 7月, 2011 2 次提交
  5. 04 7月, 2011 1 次提交
    • E
      cgroup: silence coverity warning · 3f81f8e4
      Eric Blake 提交于
      Coverity noted that most clients reacted to failure to hash; but in
      a best-effort kill loop, we can ignore failure.
      
      * src/util/cgroup.c (virCgroupKillInternal): Ignore hash failure.
      3f81f8e4
  6. 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
  7. 04 5月, 2011 1 次提交
    • E
      cgroup: avoid leaking a file · ead2b433
      Eric Blake 提交于
      Clang detected a dead store to rc.  It turns out that in fixing this,
      I also found a FILE* leak.
      
      This is a subtle change in behavior, although unlikely to hit.  The
      pidfile is a kernel file, so we've probably got more serious problems
      under foot if we fail to parse one.  However, the previous behavior
      was that even if one pid file failed to parse, we tried others,
      whereas now we give up on the first failure.  Either way, though,
      the function returns -1, so the caller will know that something is
      going wrong, and that not all pids were necessarily reaped.  Besides,
      there were other instances already in the code where failure in the
      inner loop aborted the outer loop.
      
      * src/util/cgroup.c (virCgroupKillInternal): Abort rather than
      resuming loop on fscanf failure, and cleanup file on error.
      ead2b433
  8. 19 3月, 2011 1 次提交
  9. 18 3月, 2011 1 次提交
  10. 10 3月, 2011 2 次提交
    • E
      cgroup: allow fine-tuning of device ACL permissions · 5564c575
      Eric Blake 提交于
      Adding audit points showed that we were granting too much privilege
      to qemu; it should not need any mknod rights to recreate any
      devices.  On the other hand, lxc should have all device privileges.
      The solution is adding a flag parameter.
      
      This also lets us restrict write access to read-only disks.
      
      * src/util/cgroup.h (virCgroup*Device*): Adjust prototypes.
      * src/util/cgroup.c (virCgroupAllowDevice)
      (virCgroupAllowDeviceMajor, virCgroupAllowDevicePath)
      (virCgroupDenyDevice, virCgroupDenyDeviceMajor)
      (virCgroupDenyDevicePath): Add parameter.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update clients.
      * src/lxc/lxc_controller.c (lxcSetContainerResources): Likewise.
      * src/qemu/qemu_cgroup.c: Likewise.
      (qemuSetupDiskPathAllow): Also, honor read-only disks.
      5564c575
    • E
      audit: also audit cgroup controller path · f2512684
      Eric Blake 提交于
      Although the cgroup device ACL controller path can be worked out
      by researching the code, it is more efficient to include that
      information directly in the audit message.
      
      * src/util/cgroup.h (virCgroupPathOfController): New prototype.
      * src/util/cgroup.c (virCgroupPathOfController): Export.
      * src/libvirt_private.syms: Likewise.
      * src/qemu/qemu_audit.c (qemuAuditCgroup): Use it.
      f2512684
  11. 09 3月, 2011 1 次提交
    • E
      build: fix build on cygwin · b1a5aefc
      Eric Blake 提交于
      On cygwin:
      
        CC        libvirt_util_la-cgroup.lo
      util/cgroup.c: In function 'virCgroupKillRecursiveInternal':
      util/cgroup.c:1458: warning: implicit declaration of function 'virCgroupNew' [-Wimplicit-function-declaration]
      
      * src/util/cgroup.c (virCgroupKill): Don't build on platforms
      where virCgroupNew is unsupported.
      b1a5aefc
  12. 28 2月, 2011 1 次提交
  13. 25 2月, 2011 2 次提交
    • D
      Add APIs for killing off processes inside a cgroup · 33191b41
      Daniel P. Berrange 提交于
      The virCgroupKill method kills all PIDs found in a cgroup
      
      The virCgroupKillRecursively method does this recursively
      for child cgroups.
      
      The virCgroupKillPainfully method does a recursive kill
      several times in a row until everything has really died
      33191b41
    • E
      cgroup: determine when skipping non-devices · 06173876
      Eric Blake 提交于
      * src/util/cgroup.c (virCgroupAllowDevicePath)
      (virCgroupDenyDevicePath): Don't fail with EINVAL for
      non-devices.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update caller.
      * src/qemu/qemu_cgroup.c (qemuSetupDiskPathAllow)
      (qemuSetupChardevCgroup, qemuSetupHostUsbDeviceCgroup)
      (qemuSetupCgroup, qemuTeardownDiskPathDeny): Likewise.
      06173876
  14. 24 2月, 2011 1 次提交
  15. 16 2月, 2011 1 次提交
    • E
      cgroup: preserve correct errno on failure · 76c57a7c
      Eric Blake 提交于
      * src/util/cgroup.c (virCgroupSetValueStr, virCgroupGetValueStr)
      (virCgroupRemoveRecursively): VIR_DEBUG can clobber errno.
      (virCgroupRemove): Use VIR_DEBUG rather than DEBUG.
      76c57a7c
  16. 15 2月, 2011 1 次提交
    • E
      build: silence false positive clang report · bd6ea303
      Eric Blake 提交于
      clang complained that STREQ(group->controllers[i].mountPoint,...)  was
      a NULL dereference when i==VIR_CGROUP_CONTROLLER_CPUSET, because it
      assumes the worst about virCgroupPathOfController.  Marking the
      argument const doesn't yet have an effect, per this clang bug:
      http://llvm.org/bugs/show_bug.cgi?id=7758
      
      So, we use sa_assert, which was designed to shut up false positives
      from tools like clang.
      
      * src/util/cgroup.c (virCgroupMakeGroup): Teach clang that there
      is no NULL dereference.
      bd6ea303
  17. 09 2月, 2011 2 次提交
  18. 15 1月, 2011 1 次提交
  19. 03 12月, 2010 1 次提交
    • J
      Create file in virFileWriteStr() if it doesn't exist · 966a1bfe
      Jean-Baptiste Rouault 提交于
      This patch adds a mode_t parameter to virFileWriteStr().
      If mode is different from 0, virFileWriteStr() will try
      to create the file if it doesn't exist.
      
      * src/util/util.h (virFileWriteStr): Alter signature.
      * src/util/util.c (virFileWriteStr): Allow file creation.
      * src/network/bridge_driver.c (networkEnableIpForwarding)
      (networkDisableIPV6): Adjust clients.
      * src/node_device/node_device_driver.c
      (nodeDeviceVportCreateDelete): Likewise.
      * src/util/cgroup.c (virCgroupSetValueStr): Likewise.
      * src/util/pci.c (pciBindDeviceToStub, pciUnBindDeviceFromStub):
      Likewise.
      966a1bfe
  20. 17 11月, 2010 1 次提交
    • S
      deprecate fclose() and introduce VIR_{FORCE_}FCLOSE() · 7b7cb1ec
      Stefan Berger 提交于
      Similarly to deprecating close(), I am now deprecating fclose() and
      introduce VIR_FORCE_FCLOSE() and VIR_FCLOSE(). Also, fdopen() is replaced with
      VIR_FDOPEN().
      
      Most of the files are opened in read-only mode, so usage of
      VIR_FORCE_CLOSE() seemed appropriate. Others that are opened in write
      mode already had the fclose()<  0 check and I converted those to
      VIR_FCLOSE()<  0.
      
      I did not find occurrences of possible double-closed files on the way.
      7b7cb1ec
  21. 29 10月, 2010 1 次提交
    • L
      qemu_driver: add virCgroupMounted · 41b2cee2
      Lai Jiangshan 提交于
      When we mount any cgroup without "-o devices", we will fail to start vms:
      
      error: Failed to start domain vm1
      error: Unable to deny all devices for vm1: No such file or directory
      
      When we mount any cgroup without "-o cpu", we will fail to get schedinfo:
      Scheduler      : posix
      error: unable to get cpu shares tunable: No such file or directory
      
      We should only use the cgroup controllers which are mounted on host.
      So I add virCgroupMounted() for qemuCgroupControllerActive()
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      41b2cee2
  22. 13 10月, 2010 1 次提交
  23. 30 6月, 2010 2 次提交
  24. 25 6月, 2010 1 次提交
    • D
      Set labelling for character devices in security drivers · 2bad82f7
      Daniel P. Berrange 提交于
      When configuring serial, parallel, console or channel devices
      with a file, dev or pipe backend type, it is necessary to label
      the file path in the security drivers. For char devices of type
      file, it is neccessary to pre-create (touch) the file if it does
      not already exist since QEMU won't be allowed todo so itself.
      dev/pipe configs already require the admin to pre-create before
      starting the guest.
      
      * src/qemu/qemu_security_dac.c: set file ownership for character
        devices
      * src/security/security_selinux.c: Set file labeling for character
        devices
      * src/qemu/qemu_driver.c: Add character devices to cgroup ACL
      2bad82f7
  25. 24 6月, 2010 2 次提交
    • R
      cgroup: Enable memory.use_hierarchy of cgroup for domain · 4a4eb13e
      Ryota Ozaki 提交于
      Through conversation with Kumar L Srikanth-B22348, I found
      that the function of getting memory usage (e.g., virsh dominfo)
      doesn't work for lxc with ns subsystem of cgroup enabled.
      
      This is because of features of ns and memory subsystems.
      Ns creates child cgroup on every process fork and as a result
      processes in a container are not assigned in a cgroup for
      domain (e.g., libvirt/lxc/test1/). For example, libvirt_lxc
      and init (or somewhat specified in XML) are assigned into
      libvirt/lxc/test1/8839/ and libvirt/lxc/test1/8839/8849/,
      respectively. On the other hand, memory subsystem accounts
      memory usage within a group of processes by default, i.e.,
      it does not take any child (and descendant) groups into
      account. With the two features, virsh dominfo which just
      checks memory usage of a cgroup for domain always returns
      zero because the cgroup has no process.
      
      Setting memory.use_hierarchy of a group allows to account
      (and limit) memory usage of every descendant groups of the group.
      By setting it of a cgroup for domain, we can get proper memory
      usage of lxc with ns subsystem enabled. (To be exact, the
      setting is required only when memory and ns subsystems are
      enabled at the same time, e.g., mount -t cgroup none /cgroup.)
      4a4eb13e
    • R
      cgroup: Change virCgroupRemove to remove all descendant groups at first · 842b51ff
      Ryota Ozaki 提交于
      As same as normal directories, a cgroup cannot be removed if it
      contains sub groups. This patch changes virCgroupRemove to remove
      all descendant groups (subdirectories) of a target group before
      removing the target group.
      
      The handling is required when we run lxc with ns subsystem of cgroup.
      Ns subsystem automatically creates child cgroups on every process
      forks, but unfortunately the groups are not removed on process exits,
      so we have to remove them by ourselves.
      
      With this patch, such child (and descendant) groups are surely removed
      at lxc shutdown, i.e., lxcVmCleanup which calls virCgroupRemove.
      842b51ff
  26. 21 5月, 2010 2 次提交
  27. 04 5月, 2010 1 次提交
  28. 24 4月, 2010 1 次提交
  29. 01 4月, 2010 1 次提交
    • M
      cgroup: Replace sscanf with virStrToLong_ll · 73b45bfb
      Matthias Bolte 提交于
      The switch from %lli to %lld in virCgroupGetValueI64 is intended,
      as virCgroupGetValueU64 uses base 10 too, and virCgroupSetValueI64
      uses %lld to format the number to string.
      
      Parsing is stricter now and doesn't accept trailing characters
      after the actual value anymore.
      73b45bfb
  30. 22 3月, 2010 1 次提交
    • J
      Avoid libvirtd crash when cgroups is not configured on host · 09fafa1e
      Jim Fehlig 提交于
      Invoking virDomainSetMemory() on lxc driver results in libvirtd
      segfault when cgroups has not been configured on the host.
      
      Ensure driver->cgroup is non-null before invoking
      virCgroupForDomain().  To prevent similar segfaults in the future,
      ensure driver parameter to virCgroupForDomain() is non-null before
      dereferencing.
      09fafa1e
  31. 10 3月, 2010 1 次提交
  32. 05 3月, 2010 1 次提交
  33. 09 2月, 2010 1 次提交