1. 17 2月, 2011 1 次提交
    • O
      storage: Allow to delete device mapper disk partition · df1011ca
      Osier Yang 提交于
      The name convention of device mapper disk is different, and 'parted'
      can't be used to delete a device mapper disk partition. e.g.
      
      Name                 Path
      -----------------------------------------
      3600a0b80005ad1d7000093604cae912fp1 /dev/mapper/3600a0b80005ad1d7000093604cae912fp1
      
      Error: Expecting a partition number.
      
      This patch introduces 'dmsetup' to fix it.
      
      Changes:
        - New function "virIsDevMapperDevice" in "src/utils/utils.c"
        - remove "is_dm_device" in "src/storage/parthelper.c", use
          "virIsDevMapperDevice" instead.
        - Requires "device-mapper" for 'with-storage-disk" in "libvirt.spec.in"
        - Check "dmsetup" in 'configure.ac' for "with-storage-disk"
        - Changes on "src/Makefile.am" to link against libdevmapper
        - New entry for "virIsDevMapperDevice" in "src/libvirt_private.syms"
      
      Changes from v1 to v3:
        - s/virIsDeviceMapperDevice/virIsDevMapperDevice/g
        - replace "virRun" with "virCommand"
        - sort the list of util functions in "libvirt_private.syms"
        - ATTRIBUTE_NONNULL(1) for virIsDevMapperDevice declaration.
      
      e.g.
      
      Name                 Path
      -----------------------------------------
      3600a0b80005ad1d7000093604cae912fp1 /dev/mapper/3600a0b80005ad1d7000093604cae912fp1
      
      Vol /dev/mapper/3600a0b80005ad1d7000093604cae912fp1 deleted
      
      Name                 Path
      -----------------------------------------
      df1011ca
  2. 10 2月, 2011 2 次提交
  3. 30 1月, 2011 1 次提交
    • E
      build: avoid close, system · e67ae619
      Eric Blake 提交于
      * src/fdstream.c (virFDStreamOpenFile, virFDStreamCreateFile):
      Use VIR_FORCE_CLOSE instead of close.
      * tests/commandtest.c (mymain): Likewise.
      * tools/virsh.c (editFile): Use virCommand instead of system.
      * src/util/util.c (__virExec): Special case preservation of std
      file descriptors to child.
      e67ae619
  4. 14 1月, 2011 1 次提交
    • E
      util: add missing string->integer conversion functions · 1ff03b28
      Eric Blake 提交于
      It was awkward having only int conversion in the virStrToLong family,
      but only long conversion in the virXPath family.  Make both families
      support both types.
      
      * src/util/util.h (virStrToLong_l, virStrToLong_ul): New
      prototypes.
      * src/util/xml.h (virXPathInt, virXPathUInt): Likewise.
      * src/util/util.c (virStrToLong_l, virStrToLong_ul): New
      functions.
      * src/util/xml.c (virXPathInt, virXPathUInt): Likewise.
      * src/libvirt_private.syms (util.h, xml.h): Export them.
      1ff03b28
  5. 13 1月, 2011 1 次提交
    • E
      virFindFileInPath: only find executable non-directory · 9ae992f2
      Eric Blake 提交于
      Without this patch, at least tests/daemon-conf (which sticks
      $builddir/src in the PATH) tries to execute the directory
      $builddir/src/qemu rather than a real qemu binary.
      
      * src/util/util.h (virFileExists): Adjust prototype.
      (virFileIsExecutable): New prototype.
      * src/util/util.c (virFindFileInPath): Reject non-executables and
      directories.  Avoid huge stack allocation.
      (virFileExists): Use lighter-weight syscall.
      (virFileIsExecutable): New function.
      * src/libvirt_private.syms (util.h): Export new function.
      9ae992f2
  6. 04 1月, 2011 1 次提交
    • E
      build: avoid compilation warnings · c685993d
      Eric Blake 提交于
      Detected on cygwin:
      util/util.c: In function 'virSetUIDGID':
      util/util.c:2824: warning: format '%d' expects type 'int', but argument 7 has type 'gid_t' [-Wformat]
      (and three other lines)
      
      * src/util/util.c (virSetUIDGID): Cast, as is done elsewhere in
      this file, to avoid printf type mismatch warnings.
      c685993d
  7. 01 1月, 2011 1 次提交
  8. 24 12月, 2010 1 次提交
    • L
      new virSetUIDGID() utility function · d596c6dc
      Laine Stump 提交于
      virSetUIDGID() sets both the real and effective group and user of the
      process, and additionally calls initgroups() to assure that the
      process joins all the auxiliary groups that the given uid is a member
      of.
      d596c6dc
  9. 14 12月, 2010 2 次提交
  10. 11 12月, 2010 1 次提交
  11. 03 12月, 2010 3 次提交
    • 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
    • E
      util: add virVasprintf · fce3baee
      Eric Blake 提交于
      * src/util/util.h (virVasprintf): New declaration.
      * src/util/util.c (virVasprintf): New function.
      (virAsprintf): Use it.
      * src/util/virtaudit.c (virAuditSend): Likewise.
      * src/libvirt_private.syms: Export it.
      * cfg.mk (sc_prohibit_asprintf): Also prohibit vasprintf.
      * .x-sc_prohibit_asprintf: Add exemption.
      fce3baee
    • E
      util: fix saferead type · dbab6bb5
      Eric Blake 提交于
      * src/util/util.c (saferead): Fix return type.
      (safewrite): Fix indentation.
      dbab6bb5
  12. 23 11月, 2010 2 次提交
    • D
      Remove trailing ':' from timestamp · dbf405bf
      Daniel P. Berrange 提交于
      The QEMU logger appends a ':' to the timestamp when it deems
      it neccessary, so the virTimestamp API should not duplicate
      this
      
      * src/util/util.c: Remove trailing ':' from timestamp
      dbf405bf
    • D
      Ensure virExec preserves logging environment · 882f78c3
      Daniel P. Berrange 提交于
      The virFork call resets all logging handlers that may have been
      set. Re-enable them after fork in virExec, so that env variables
      fir LIBVIRT_LOG_OUTPUTS and LIBVIRT_LOG_FILTERS take effect
      until the execve()
      
      * src/util/util.c: Preserve logging in child in virExec
      882f78c3
  13. 19 11月, 2010 1 次提交
  14. 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
  15. 10 11月, 2010 1 次提交
    • S
      bye to close(), welcome to VIR_(FORCE_)CLOSE() · 60ae1c34
      Stefan Berger 提交于
      Using automated replacement with sed and editing I have now replaced all
      occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
      course. Some replacements were straight forward, others I needed to pay
      attention. I hope I payed attention in all the right places... Please
      have a look. This should have at least solved one more double-close
      error.
      60ae1c34
  16. 09 11月, 2010 1 次提交
  17. 03 11月, 2010 1 次提交
    • D
      Fix virPipeReadUntilEOF on more than 1024 bytes of data · 04cbfa4f
      Daniel Veillard 提交于
      virPipeReadUntilEOF is used to read the stdout of exec'ed
      and this could fail to capture the full output and read only
      1024 bytes.
        The problem is that this is based on a poll loop, and in the
      loop we read at most 1024 bytes per file descriptor, but we also
      note in the loop if poll indicates that the process won't output
      more than that on that fd by setting finished[i] = 1.
        The simplest way is that if we read a full buffer make sure
      finished[i] is still 0 because we will need another pass in the
      loop.
      04cbfa4f
  18. 02 11月, 2010 1 次提交
  19. 28 10月, 2010 1 次提交
  20. 23 9月, 2010 1 次提交
    • E
      maint: update to latest gnulib · 76d87a59
      Eric Blake 提交于
      * .gnulib: Update to latest.
      * bootstrap.conf (gnulib_modules): Add new termios module.
      (gnulib_tool_option_extras): Make libtool usage explicit.
      * src/util/util.c (includes): Gnulib now guarantees termios.h.
      * bootstrap: Resync from gnulib.
      76d87a59
  21. 31 8月, 2010 1 次提交
  22. 13 8月, 2010 1 次提交
  23. 10 8月, 2010 1 次提交
  24. 22 7月, 2010 2 次提交
    • L
      Change virDirCreate to return -errno on failure. · 3e0f05fc
      Laine Stump 提交于
      virDirCreate also previously returned 0 on success and errno on
      failure. This makes it fit the recommended convention of returning 0
      on success, -errno (ie a negative number) on failure.
      3e0f05fc
    • L
      Change virFileOperation to return -errno (ie < 0) on error. · 2ad04f78
      Laine Stump 提交于
      virFileOperation previously returned 0 on success, or the value of
      errno on failure. Although there are other functions in libvirt that
      use this convention, the preferred (and more common) convention is to
      return 0 on success and -errno (or simply -1 in some cases) on
      failure. This way the check for failure is always (ret < 0).
      
      * src/util/util.c - change virFileOperation and virFileOperationNoFork to
                          return -errno on failure.
      
      * src/storage/storage_backend.c, src/qemu/qemu_driver.c
        - change the hook functions passed to virFileOperation to return
          -errno on failure.
      2ad04f78
  25. 02 7月, 2010 1 次提交
    • C
      util: virExec: Dispatch all errors raised after fork · e190754e
      Cole Robinson 提交于
      Any error message raised after the process has forked needs
      to be followed by virDispatchError, otherwise we have no chance of
      ever seeing it. This was selectively done for hook functions in the past,
      but really applies to all post-fork errors.
      e190754e
  26. 29 6月, 2010 1 次提交
  27. 11 6月, 2010 1 次提交
  28. 26 5月, 2010 2 次提交
    • C
      Fix failing virGetHostname. · 0117b7da
      Chris Lalancette 提交于
      We've been running into a lot of situations where
      virGetHostname() is returning "localhost", where a plain
      gethostname() would have returned the correct thing.  This
      is because virGetHostname() is *always* trying to canonicalize
      the name returned from gethostname(), even when it doesn't
      have to.
      
      This patch changes virGetHostname so that if the value returned
      from gethostname() is already FQDN or localhost, it returns
      that string directly.  If the value returned from gethostname()
      is a shortened hostname, then we try to canonicalize it.  If
      that succeeds, we returned the canonicalized hostname.  If
      that fails, and/or returns "localhost", then we just return
      the original string we got from gethostname() and hope for
      the best.
      
      Note that after this patch it is up to clients to check whether
      "localhost" is an allowed return value.  The only place
      where it's currently not is in qemu migration.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      0117b7da
    • C
      storage: Sanitize pool target paths · a7fb2258
      Cole Robinson 提交于
      Spurious / in a pool target path makes life difficult for apps using the
      GetVolByPath, and doing other path based comparisons with pools. This
      has caused a few issues for virt-manager users:
      
      https://bugzilla.redhat.com/show_bug.cgi?id=494005
      https://bugzilla.redhat.com/show_bug.cgi?id=593565
      
      Add a new util API which removes spurious /, virFileSanitizePath. Sanitize
      target paths when parsing pool XML, and for paths passed to GetVolByPath.
      
      v2: Leading // must be preserved, properly sanitize path=/, sanitize
          away /./ -> /
      
      v3: Properly handle starting ./ and ending /.
      
      v4: Drop all '.' handling, just sanitize / for now.
      a7fb2258
  29. 21 5月, 2010 1 次提交
  30. 18 5月, 2010 1 次提交
    • E
      virFileResolveLink: fix return value · d533a98e
      Eric Blake 提交于
      virFileResolveLink was returning a positive value on error,
      thus confusing callers that assumed failure was < 0.  The
      confusion is further evidenced by callers that would have
      ended up calling virReportSystemError with a negative value
      instead of a valid errno.
      
      Fixes Red Hat BZ #591363.
      
      * src/util/util.c (virFileResolveLink): Live up to documentation.
      * src/qemu/qemu_security_dac.c
      (qemuSecurityDACRestoreSecurityFileLabel): Adjust callers.
      * src/security/security_selinux.c
      (SELinuxRestoreSecurityFileLabel): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskDeleteVol): Likewise.
      d533a98e
  31. 07 5月, 2010 2 次提交
    • E
      build: use gnulib's sys/wait.h · 8acaeb73
      Eric Blake 提交于
      * configure.ac: Drop sys/wait.h check.
      * src/libvirt.c (includes): Use header unconditionally.
      * src/remote/remote_driver.c (includes): Likewise.
      * src/storage/storage_backend.c (includes): Likewise.
      * src/util/ebtables.c (includes): Likewise.
      * src/util/hooks.c (includes): Likewise.
      * src/util/iptables.c (includes): Likewise.
      * src/util/util.c (includes): Likewise.
      8acaeb73
    • E
      build: rely on gnulib's pthread module · 9017b9bc
      Eric Blake 提交于
      Gnulib can guarantee that pthread.h exists, but for now, it is a dummy
      header with no support for most pthread_* functions.  Modify our
      use of pthread to use function checks, rather than header checks,
      to determine how much pthread support is present.
      
      * bootstrap.conf (gnulib_modules): Add pthread.
      * configure.ac: Drop all pthread.h checks.  Optimize function
      checks.  Add check for pthread functions.
      * src/Makefile.am (libvirt_lxc_LDADD): Ensure proper link.
      * src/remote/remote_driver.c (remoteIOEventLoop): Depend on
      pthread_sigmask, now that gnulib guarantees pthread.h.
      * src/util/util.c (virFork): Likewise.
      * src/util/threads.c (threads-pthread.c): Depend on
      pthread_mutexattr_init, as a witness of full pthread support.
      * src/util/threads.h (threads-pthread.h): Likewise.
      9017b9bc
  32. 05 5月, 2010 1 次提交
    • E
      util: fix va_start usage bug · 62ee19c7
      Eric Blake 提交于
      Detected by clang.  POSIX requires that the second argument to
      va_start be the name of the last variable; and in some implementations,
      passing *path instead of path would dereference bogus memory instead
      of pulling arguments off the stack.
      
      * src/util/util.c (virBuildPathInternal): Use correct argument to
      va_start.
      62ee19c7