1. 26 9月, 2012 3 次提交
  2. 21 9月, 2012 1 次提交
  3. 18 9月, 2012 1 次提交
    • O
      conf: Parse and format disk <wwn> · facc1c00
      Osier Yang 提交于
      Validates the wwn while parsing, error out if it's malformed.
      
      * src/util/util.h: Declare virValidateWWN
      * src/util/util.c: Implement virValidateWWN
      * src/libvirt_private.syms: Export virValidateWWN.
      * src/conf/domain_conf.h: New member 'wwn' for disk def.
      * src/conf/domain_conf.c: Parse and format disk <wwn>
      facc1c00
  4. 29 8月, 2012 1 次提交
    • P
      util: Fix error message when getpwuid_r fails to find the user · f2bb32b1
      Peter Krempa 提交于
      getpwuid_r returns success but sets the return structure to NULL when it
      fails to deliver data about the requested uid. In our helper code this
      created following strange error messages:
      
      " ... cannot getpwuid_r(1234): Success"
      
      This patch creates a more helpful message:
      " ... getpwuid_r failed to retrieve data for uid '1234'"
      f2bb32b1
  5. 14 8月, 2012 2 次提交
    • M
      util: typos in fallback code fo virDoubleToStr · 0a6504d4
      Martin Kletzander 提交于
      Fixes for some typos that somehow didn't get to the final push of the
      commit 43bfa23e.
      0a6504d4
    • M
      json: fix interface locale dependency · 43bfa23e
      Martin Kletzander 提交于
      libvirt creates invalid commands if wrong locale is selected. For
      example with locale that uses comma as a decimal point, JSON commands
      created with decimal numbers are invalid because comma separates the
      entries in JSON. Fortunately even when decimal point is affected,
      thousands grouping is not, because for grouping to be enabled with
      *printf, there has to be an apostrophe flag specified (and supported).
      
      This patch adds specific internal function for converting doubles to
      strings with C locale.
      43bfa23e
  6. 23 7月, 2012 1 次提交
    • O
      Desert the FSF address in copyright · f9ce7dad
      Osier Yang 提交于
      Per the FSF address could be changed from time to time, and GNU
      recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)
      
        You should have received a copy of the GNU General Public License
        along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
      
      This patch removes the explicit FSF address, and uses above instead
      (of course, with inserting 'Lesser' before 'General').
      
      Except a bunch of files for security driver, all others are changed
      automatically, the copyright for securify files are not complete,
      that's why to do it manually:
      
        src/security/security_selinux.h
        src/security/security_driver.h
        src/security/security_selinux.c
        src/security/security_apparmor.h
        src/security/security_apparmor.c
        src/security/security_driver.c
      f9ce7dad
  7. 18 7月, 2012 1 次提交
  8. 10 7月, 2012 2 次提交
  9. 25 6月, 2012 1 次提交
    • D
      winsock2.h must always be included before windows.h · 931b7d19
      Daniel P. Berrange 提交于
      Some GNULIB headers (eg unistd.h) will often need to include
      winsock2.h for various symbols. There is a rule that winsock2.h
      must be included before windows.h. This means that any file
      which does
      
        #ifdef WIN32
        #include <windows.h>
        #endif
        #include <unistd.h>
      
      is potentially broken. A simple rule is that /all/ includes of
      windows.h must be matched with a preceding include of winsock2.h
      regardless of whether unistd.h is used currently
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      931b7d19
  10. 21 6月, 2012 1 次提交
  11. 28 5月, 2012 2 次提交
    • D
      Add impl of APIs to get user directories on Win32 · 076f2006
      Daniel P. Berrange 提交于
      Add an impl of +virGetUserRuntimeDirectory, virGetUserCacheDirectory
      virGetUserConfigDirectory and virGetUserDirectory for Win32 platform.
      Also create stubs for non-Win32 platforms which lack getpwuid_r()
      
      In adding these two helpers were added virFileIsAbsPath and
      virFileSkipRoot, along with some macros VIR_FILE_DIR_SEPARATOR,
      VIR_FILE_DIR_SEPARATOR_S, VIR_FILE_IS_DIR_SEPARATOR,
      VIR_FILE_PATH_SEPARATOR, VIR_FILE_PATH_SEPARATOR_S
      
      All this code was adapted from GLib2 under terms of LGPLv2+ license.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      076f2006
    • D
      Remove uid param from directory lookup APIs · 517368a3
      Daniel P. Berrange 提交于
      Remove the uid param from virGetUserConfigDirectory,
      virGetUserCacheDirectory, virGetUserRuntimeDirectory,
      and virGetUserDirectory
      
      These functions were universally called with the
      results of getuid() or geteuid(). To make it practical
      to port to Win32, remove the uid parameter and hardcode
      geteuid()
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      517368a3
  12. 16 5月, 2012 1 次提交
  13. 14 5月, 2012 1 次提交
    • W
      Use XDG Base Directories instead of storing in home directory · 32a9aac2
      William Jon McCann 提交于
      As defined in:
      http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
      
      This offers a number of advantages:
       * Allows sharing a home directory between different machines, or
      sessions (eg. using NFS)
       * Cleanly separates cache, runtime (eg. sockets), or app data from
      user settings
       * Supports performing smart or selective migration of settings
      between different OS versions
       * Supports reseting settings without breaking things
       * Makes it possible to clear cache data to make room when the disk
      is filling up
       * Allows us to write a robust and efficient backup solution
       * Allows an admin flexibility to change where data and settings are stored
       * Dramatically reduces the complexity and incoherence of the
      system for administrators
      32a9aac2
  14. 20 4月, 2012 1 次提交
    • E
      build: avoid strtol and strtod · ae27f341
      Eric Blake 提交于
      Ensure we don't introduce any more lousy integer parsing in new
      code, while avoiding a scrub-down of existing legacy code.
      
      Note that we also need to enable sc_prohibit_atoi_atof (see cfg.mk
      local-checks-to-skip) before we are bulletproof, but that also
      entails scrubbing I'm not ready to do at the moment.
      
      * src/util/util.c (virStrToLong_i, virStrToLong_ui)
      (virStrToLong_l, virStrToLong_ul, virStrToLong_ll)
      (virStrToLong_ull, virStrToDouble): Mark exemptions.
      * src/util/virmacaddr.c (virMacAddrParse): Likewise.
      * cfg.mk (sc_prohibit_strtol): New syntax check.
      (exclude_file_name_regexp--sc_prohibit_strtol): Ignore files that
      I'm not willing to fix yet.
      (local-checks-to-skip): Re-enable sc_prohibit_atoi_atof.
      ae27f341
  15. 19 4月, 2012 1 次提交
    • E
      util: remove dead casts · ee20ec4c
      Eric Blake 提交于
      The sequence:
        long long val;
        if ((long long) val != val)
      is dead code.
      
      * src/util/util.c (virStrToLong_ll, virStrToLong_ull): Remove
      useless cast.
      ee20ec4c
  16. 02 4月, 2012 1 次提交
  17. 30 3月, 2012 1 次提交
  18. 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
  19. 08 3月, 2012 2 次提交
    • M
      util: Don't overflow on errno in virFileAccessibleAs · f05fb6c5
      Michal Privoznik 提交于
      If we need to virFork() to check assess() under different
      UID+GID we need to translate returned status via WEXITSTATUS().
      Otherwise, we may return values greater than 255 which is
      obviously wrong.
      f05fb6c5
    • E
      util: new function for scaling numbers · 0d90823e
      Eric Blake 提交于
      Scaling an integer based on a suffix is something we plan on reusing
      in several contexts: XML parsing, virsh CLI parsing, and possibly
      elsewhere.  Make it easy to reuse, as well as adding in support for
      powers of 1000.
      
      * src/util/util.h (virScaleInteger): New function.
      * src/util/util.c (virScaleInteger): Implement it.
      * src/libvirt_private.syms (util.h): Export it.
      0d90823e
  20. 22 2月, 2012 1 次提交
  21. 04 2月, 2012 1 次提交
    • L
      util: refactor virFileOpenAs · 90e4d681
      Laine Stump 提交于
      virFileOpenAs previously would only try opening a file as the current
      user, or as a different user, but wouldn't try both methods in a
      single call. This made it cumbersome to use as a replacement for
      open(2). Additionally, it had a lot of historical baggage that led to
      it being difficult to understand.
      
      This patch refactors virFileOpenAs in the following ways:
      
      * reorganize the code so that everything dealing with both the parent
        and child sides of the "fork+setuid+setgid+open" method are in a
        separate function. This makes the public function easier to understand.
      
      * Allow a single call to virFileOpenAs() to first attempt the open as
        the current user, and if that fails to automatically re-try after
        doing fork+setuid (if deemed appropriate, i.e. errno indicates it
        would now be successful, and the file is on a networkFS). This makes
        it possible (in many, but possibly not all, cases) to drop-in
        virFileOpenAs() as a replacement for open(2).
      
        (NB: currently qemuOpenFile() calls virFileOpenAs() twice, once
        without forking, then again with forking. That unfortunately can't
        be changed without at least some discussion of the ramifications,
        because the requested file permissions are different in each case,
        which is something that a single call to virFileOpenAs() can't deal
        with.)
      
      * Add a flag so that any fchown() of the file to a different uid:gid
        is explicitly requested when the function is called, rather than it
        being implied by the presence of the O_CREAT flag. This just makes
        for less subtle surprises to consumers. (Commit
        b1643dc1 added the check for O_CREAT
        before forcing ownership. This patch just makes that restriction
        more explicit.)
      
      * If either the uid or gid is specified as "-1", virFileOpenAs will
        interpret this to mean "the current [gu]id".
      
      All current consumers of virFileOpenAs should retain their present
      behavior (after a few minor changes to their setup code and
      arguments).
      90e4d681
  22. 28 1月, 2012 3 次提交
  23. 26 1月, 2012 2 次提交
    • D
      Introduce new API for generating random numbers · e95ef67b
      Daniel P. Berrange 提交于
      The old virRandom() API was not generating good random numbers.
      Replace it with a new API virRandomBits which instead of being
      told the upper limit, gets told the number of bits of randomness
      required.
      
      * src/util/virrandom.c, src/util/virrandom.h: Add virRandomBits,
        and move virRandomInitialize
      * src/util/util.h, src/util/util.c: Delete virRandom and
        virRandomInitialize
      * src/libvirt.c, src/security/security_selinux.c,
        src/test/test_driver.c, src/util/iohelper.c: Update for
        changes from virRandom to virRandomBits
      * src/storage/storage_backend_iscsi.c: Remove bogus call
        to virRandomInitialize & convert to virRandomBits
      e95ef67b
    • M
      Add missing virGetGroupName() · 5f1767e8
      Marc-André Lureau 提交于
      Add missing function if !HAVE_GETPWUID_R.
      5f1767e8
  24. 20 1月, 2012 1 次提交
    • E
      util: add new file for virTypedParameter utils · 61ca98b0
      Eric Blake 提交于
      Preparation for another patch that refactors common patterns
      into the new file for fewer lines of code overall.
      
      * src/util/util.h (virTypedParameterArrayClear): Move...
      * src/util/virtypedparam.h: ...to new file.
      (virTypedParameterArrayValidate, virTypedParameterAssign): New
      prototypes.
      * src/util/util.c (virTypedParameterArrayClear): Likewise.
      * src/util/virtypedparam.c: New file.
      * po/POTFILES.in: Mark file for translation.
      * src/Makefile.am (UTIL_SOURCES): Build it.
      * src/libvirt_private.syms (util.h): Split...
      (virtypedparam.h): to new section.
      (virkeycode.h): Sort.
      * daemon/remote.c: Adjust callers.
      * tools/virsh.c: Likewise.
      61ca98b0
  25. 19 1月, 2012 1 次提交
  26. 18 1月, 2012 1 次提交
    • D
      Fix startup of LXC containers with filesystems containing symlinks · c53ba61b
      Daniel P. Berrange 提交于
      Given an LXC guest with a root filesystem path of
      
        /export/lxc/roots/helloworld/root
      
      During startup, we will pivot the root filesystem to end up
      at
      
        /.oldroot/export/lxc/roots/helloworld/root
      
      We then try to open
      
        /.oldroot/export/lxc/roots/helloworld/root/dev/pts
      
      Now consider if '/export/lxc' is an absolute symlink pointing
      to '/media/lxc'. The kernel will try to open
      
        /media/lxc/roots/helloworld/root/dev/pts
      
      whereas it should be trying to open
      
        /.oldroot//media/lxc/roots/helloworld/root/dev/pts
      
      To deal with the fact that the root filesystem can be moved,
      we need to resolve symlinks in *any* part of the filesystem
      source path.
      
      * src/libvirt_private.syms, src/util/util.c,
        src/util/util.h: Add virFileResolveAllLinks to resolve
        all symlinks in a path
      * src/lxc/lxc_container.c: Resolve all symlinks in filesystem
        paths during startup
      c53ba61b
  27. 30 11月, 2011 5 次提交
    • D
      Remove time APIs from src/util/util.h · a8bb75a3
      Daniel P. Berrange 提交于
      The virTimestamp and virTimeMs functions in src/util/util.h
      duplicate functionality from virtime.h, in a non-async signal
      safe manner. Remove them, and convert all code over to the new
      APIs.
      
      * src/util/util.c, src/util/util.h: Delete virTimeMs and virTimestamp
      * src/lxc/lxc_driver.c, src/qemu/qemu_domain.c,
        src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
        src/qemu/qemu_process.c, src/util/event_poll.c: Convert to use
        virtime APIs
      a8bb75a3
    • D
      Move suspend capabilities APIs out of util.h into virnodesuspend.c · c92653f4
      Daniel P. Berrange 提交于
      The node suspend capabilities APIs should not have been put into
      util.[ch]. Instead move them into virnodesuspend.[ch]
      
      * src/util/util.c, src/util/util.h: Remove suspend capabilities APIs
      * src/util/virnodesuspend.c, src/util/virnodesuspend.h: Add
        suspend capabilities APIs
      * src/qemu/qemu_capabilities.c: Include virnodesuspend.h
      c92653f4
    • D
      Rename suspend capabilities APIs · 53c2aad8
      Daniel P. Berrange 提交于
      Rename virGetPMCapabilities to virNodeSuspendGetTargetMask and
      virDiscoverHostPMFeature to virNodeSuspendSupportsTarget.
      
      * src/util/util.c, src/util/util.h: Rename APIs
      * src/qemu/qemu_capabilities.c, src/util/virnodesuspend.c: Adjust
        for new names
      53c2aad8
    • D
      Sanitize virDiscoverHostPMFeature to return a boolean · 33386276
      Daniel P. Berrange 提交于
      Since virDiscoverHostPMFeature is just checking one feature,
      there is no reason for it to return a bitmask. Change it to
      return a boolean
      
      * src/util/util.c, src/util/util.h: Make virDiscoverHostPMFeature
        return a boolean
      33386276
    • D
      Remove internal only virHostPMCapability enum · 6fb5400f
      Daniel P. Berrange 提交于
      The internal virHostPMCapability enum just duplicates the
      public virNodeSuspendTarget enum, but with different names.
      
      * src/util/util.c: Use VIR_NODE_SUSPEND_TARGET constants
      * src/util/util.h: Remove virHostPMCapability enum
      * src/conf/capabilities.c: Use VIR_NODE_SUSPEND_TARGET_LAST
      6fb5400f