1. 30 3月, 2010 1 次提交
    • D
      Export virPipeReadUntilEOF internally · b3bff954
      Daniel Veillard 提交于
      used to read the data from virExec stdout/err file descriptors
      
      * src/util/util.c src/util/util.h: not static anymore and export it
      * src/libvirt_private.syms: allow access internally
      b3bff954
  2. 23 3月, 2010 1 次提交
  3. 10 3月, 2010 1 次提交
  4. 20 2月, 2010 1 次提交
    • L
      Rename virFileCreate to virFileOperation, add hook function · fbadc2b6
      Laine Stump 提交于
      It turns out it is also useful to be able to perform other operations
      on a file created while running as a different uid (eg, write things
      to that file), and possibly to do this to a file that already
      exists. This patch adds an optional hook function to the renamed (for
      more accuracy of purpose) virFileOperation; the hook will be called
      after the file has been opened (possibly created) and gid/mode
      checked/set, before closing it.
      
      As with the other operations on the file, if the VIR_FILE_OP_AS_UID
      flag is set, this hook function will be called in the context of a
      child process forked from the process that called virFileOperation.
      The implication here is that, while all data in memory is available to
      this hook function, any modification to that data will not be seen by
      the caller - the only indication in memory of what happened in the
      hook will be the return value (which the hook should set to 0 on
      success, or one of the standard errno values on failure).
      
      Another piece of making the function more flexible was to add an
      "openflags" argument. This arg should contain exactly the flags to be
      passed to open(2), eg O_RDWR | O_EXCL, etc.
      
      In the process of adding the hook to virFileOperation, I also realized
      that the bits to fix up file owner/group/mode settings after creation
      were being done in the parent process, which could fail, so I moved
      them to the child process where they should be.
      
      * src/util/util.[ch]: rename and rework virFileCreate-->virFileOperation,
        and redo flags in virDirCreate
      * storage/storage_backend.c, storage/storage_backend_fs.c: update the
        calls to virFileOperation/virDirCreate to reflect changes in the API,
        but don't yet take advantage of the hook.
      fbadc2b6
  5. 19 2月, 2010 2 次提交
    • C
      Better error reporting for failed migration · b97c24b2
      Chris Lalancette 提交于
      If the hostname as returned by "gethostname" resolves
      to "localhost" (as it does with the broken Fedora-12
      installer), then live migration will fail because the
      source will try to migrate to itself.  Detect this
      situation up-front and abort the live migration before
      we do any real work.
      
      * src/util/util.h src/util/util.c: add a new virGetHostnameLocalhost
        with an optional localhost check, and rewire virGetHostname() to use
        it
      * src/libvirt_private.syms: expose the new function
      * src/qemu/qemu_driver.c: use it in qemudDomainMigratePrepare2()
      b97c24b2
    • L
      Add virFork() function to utils · b4584612
      Laine Stump 提交于
      virFork() contains bookkeeping that must be done any time a process
      forks. Currently this includes:
      
      1) Call virLogLock() prior to fork() and virLogUnlock() just after,
         to avoid a deadlock if some other thread happens to hold that lock
         during the fork.
      
      2) Reset the logging hooks and send all child process log messages to
         stderr.
      
      3) Block all signals prior to fork(), then either a) reset the signal
         mask for the parent process, or b) clear the signal mask for the
         child process.
      
      Note that the signal mask handling in __virExec erroneously fails to
      restore the signal mask when fork() fails. virFork() fixes this
      problem.
      
      Other than this, it attempts to behave as closely to fork() as
      possible (including preserving errno for the caller), with a couple
      exceptions:
      
      1) The return value is 0 (success) or -1 (failure), while the pid is
         returned via the pid_t* argument. Like fork(), if pid < 0 there is
         no child process, otherwise both the child and the parent will
         return to the caller, and both should look at the return value,
         which will indicate if some of the extra processing outlined above
         encountered an error.
      
      2) If virFork() returns with pid < 0 or with a return value < 0
         indicating an error condition, the error has already been
         reported. You can log an additional message if you like, but it
         isn't necessary, and may be awkwardly extraneous.
      
      Note that virFork()'s child process will *never* call _exit() - if a
      child process is created, it will return to the caller.
      
      * util.c util.h: add virFork() function, based on what is currently
                       done in __virExec().
      b4584612
  6. 10 2月, 2010 1 次提交
    • J
      virAsprintf: remove its warn_unused_result attribute · 658952a3
      Jim Meyering 提交于
      * src/util/util.h (virAsprintf): Remove ATTRIBUTE_RETURN_CHECK, since
      it is perfectly fine to ignore the return value, now that the pointer
      is guaranteed to be set to NULL upon failure.
      * src/util/storage_file.c (absolutePathFromBaseFile): Remove now-
      unnecessary use of ignore_value.
      658952a3
  7. 09 2月, 2010 1 次提交
  8. 21 1月, 2010 2 次提交
    • L
      New utility functions virFileCreate and virDirCreate · 98f6f381
      Laine Stump 提交于
      These functions create a new file or directory with the given
      uid/gid. If the flag VIR_FILE_CREATE_AS_UID is given, they do this by
      forking a new process, calling setuid/setgid in the new process, and
      then creating the file. This is better than simply calling open then
      fchown, because in the latter case, a root-squashing nfs server would
      create the new file as user nobody, then refuse to allow fchown.
      
      If VIR_FILE_CREATE_AS_UID is not specified, the simpler tactic of
      creating the file/dir, then chowning is is used. This gives better
      results in cases where the parent directory isn't on a root-squashing
      NFS server, but doesn't give permission for the specified uid/gid to
      create files. (Note that if the fork/setuid method fails to create the
      file due to access privileges, the parent process will make a second
      attempt using this simpler method.)
      
      If the bit VIR_FILE_CREATE_ALLOW_EXIST is set in the flags, an
      existing file/directory will not cause an error; in this case, the
      function will simply set the permissions of the file/directory to
      those requested. If VIR_FILE_CREATE_ALLOW_EXIST is not specified, an
      existing file/directory is considered (and reported as) an error.
      
      Return from both of these functions is 0 on success, or the value of
      errno if there was a failure.
      
      * src/util/util.[ch]: add the 2 new util functions
      98f6f381
    • L
      Add virRunWithHook util function · d2259ada
      Laine Stump 提交于
      * src/util/util.[ch]: similar to virExecWithHook, but waits for child to
        exit. Useful for doing things like setuid after the fork but before the
        exec.
      d2259ada
  9. 22 12月, 2009 1 次提交
    • M
      Fix undefined reference to 'close_used_without_including_unistd_h' · 457d4ad9
      Matthias Bolte 提交于
      Found while trying to cross-compile libvirt on Fedora 12 for Windows.
      gnulib redefines 'close' to 'close_used_without_including_unistd_h'
      in sys/socket.h if winsock2.h is present and unistd.h has not been
      included before sys/socket.h. Reorder some includes to fix this.
      457d4ad9
  10. 04 12月, 2009 1 次提交
    • M
      Add virIndexToDiskName and fix mapping gap · 63166a4e
      Matthias Bolte 提交于
      esxVMX_IndexToDiskName handles indices up to 701. This limit comes
      from a mapping gap in virDiskNameToIndex:
      
        sdzy -> 700
        sdzz -> 701
        sdaaa -> 728
        sdaab -> 729
      
      This line in virDiskNameToIndex causes this gap:
      
        idx = (idx + i) * 26;
      
      Fixing it by altering this line to:
      
        idx = (idx + (i < 1 ? 0 : 1)) * 26;
      
      Also add a new version of virIndexToDiskName that handles the inverse
      mapping for arbitrary indices.
      
      * src/esx/esx_vmx.[ch]: remove esxVMX_IndexToDiskName
      * src/util/util.[ch]: add virIndexToDiskName and fix mapping gap
      * tests/esxutilstest.c: update test to verify that the gap is fixed
      63166a4e
  11. 13 11月, 2009 1 次提交
    • D
      Implement a node device backend using libudev · 3ad6dcf3
      David Allan 提交于
      * configure.in: add new --with-udev, disabled by default, and requiring
        libudev > 145
      * src/node_device/node_device_udev.c src/node_device/node_device_udev.h:
        the new node device backend
      * src/node_device/node_device_linux_sysfs.c: moved node_device_hal_linux.c
        to a better file name
      * src/conf/node_device_conf.c src/conf/node_device_conf.h: add a couple
        of fields in node device definitions, and an API to look them up,
        remove a couple of unused fields from previous patch.
      * src/node_device/node_device_driver.c src/node_device/node_device_driver.h:
        plug the new driver
      * po/POTFILES.in src/Makefile.am src/libvirt_private.syms: add the new
        files and symbols
      * src/util/util.h src/util/util.c: add a new convenience macro
        virBuildPath and virBuildPathInternal() function
      3ad6dcf3
  12. 04 11月, 2009 1 次提交
    • C
      Improve error reporting for virConnectGetHostname calls · 517761fd
      Cole Robinson 提交于
      All drivers have copy + pasted inadequate error reporting which wraps
      util.c:virGetHostname. Move all error reporting to this function, and improve
      what we report.
      
      Changes from v1:
        Drop the driver wrappers around virGetHostname. This means we still need
        to keep the new conn argument to virGetHostname, but I think it's worth
        it.
      517761fd
  13. 03 11月, 2009 1 次提交
    • D
      Annotate many methods with ATTRIBUTE_RETURN_CHECK & fix problems · 46992453
      Daniel P. Berrange 提交于
      Nearly all of the methods in src/util/util.h have error codes that
      must be checked by the caller to correct detect & report failure.
      Add ATTRIBUTE_RETURN_CHECK to ensure compile time validation of
      this
      
      * daemon/libvirtd.c: Add explicit check on return value of virAsprintf
      * src/conf/domain_conf.c: Add missing check on virParseMacAddr return
        value status & report error
      * src/network/bridge_driver.c: Add missing OOM check on virAsprintf
        and report error
      * src/qemu/qemu_conf.c: Add missing check on virParseMacAddr return
        value status & report error
      * src/security/security_selinux.c: Remove call to virRandomInitialize
        that's done in libvirt.c already
      * src/storage/storage_backend_logical.c: Add check & log on virRun
        return status
      * src/util/util.c: Add missing checks on virAsprintf/Run status
      * src/util/util.h: Annotate all methods with ATTRIBUTE_RETURN_CHECK
        if they return an error status code
      * src/vbox/vbox_tmpl.c: Add missing check on virParseMacAddr
      * src/xen/xm_internal.c: Add missing checks on virAsprintf
      * tests/qemuargv2xmltest.c: Remove bogus call to virRandomInitialize()
      46992453
  14. 08 10月, 2009 1 次提交
    • A
      Add virFileAbsPath() utility · 2e812c89
      Amy Griffis 提交于
      * src/util/util.[ch]: Add virFileAbsPath() function to ensure an
        absolute path for a potentially realtive path.
      * src/libvirt_private.syms: add it in libvirt private symbols
      2e812c89
  15. 29 9月, 2009 1 次提交
  16. 23 9月, 2009 1 次提交
    • C
      Introduce virStrncpy. · 03d777f3
      Chris Lalancette 提交于
      Add the virStrncpy function, which takes a dst string, source string,
      the number of bytes to copy and the number of bytes available in the
      dest string.  If the source string is too large to fit into the
      destination string, including the \0 byte, then no data is copied and
      the function returns NULL.  Otherwise, this function copies n bytes
      from source into dst, including the \0, and returns a pointer to the
      dst string.  This function is intended to replace all unsafe uses
      of strncpy in the code base, since strncpy does *not* guarantee that
      the buffer terminates with a \0.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      03d777f3
  17. 21 9月, 2009 1 次提交
    • 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
  18. 10 9月, 2009 1 次提交
    • D
      Fix use of dlopen modules · fcd4e269
      Daniel P. Berrange 提交于
      Remove the bogus dependancy between node_device.c & storage_backend.c
      by moving the virWaitForDevices into util.h where it can be shared
      safely
      
      * src/storage_backend_disk.c, src/storage_backend_logical.c,
        src/storage_backend_mpath.c, src/storage_backend_scsi.c: Replace
        virStorageBackendWaitForDevices with virFileWaitForDevices
      * src/storage_backend.c, src/storage_backend.h: Remove
        virStorageBackendWaitForDevices, virWaitForDevices
      * src/util.h, src/util.c: Add virFileWaitForDevices
      * configure.in: Move xmlrpc check further down after pkgconfig
        is detected
      * src/Makefile.am: Add missing XMLRPC_CFLAGS/LIBS to opennebula
      * src/libvirt_private.syms: Add many missing exports
      fcd4e269
  19. 03 9月, 2009 1 次提交
    • D
      Support configuration of huge pages in guests · d823a05a
      Daniel P. Berrange 提交于
      Add option to domain XML for
      
           <memoryBacking>
              <hugepages/>
           </memoryBacking>
      
      * configure.in: Add check for mntent.h
      * qemud/libvirtd_qemu.aug, qemud/test_libvirtd_qemu.aug, src/qemu.conf
        Add 'hugetlbfs_mount' config parameter
      * src/qemu_conf.c, src/qemu_conf.h: Check for -mem-path flag in QEMU,
        and pass it when hugepages are requested.
        Load hugetlbfs_mount config parameter, search for mount if not given.
      * src/qemu_driver.c: Free hugetlbfs_mount/path parameter in driver shutdown.
        Create directory for QEMU hugepage usage, chowning if required.
      * docs/formatdomain.html.in: Document memoryBacking/hugepages elements
      * docs/schemas/domain.rng: Add memoryBacking/hugepages elements to schema
      * src/util.c, src/util.h, src/libvirt_private.syms: Add virFileFindMountPoint
        helper API
      * tests/qemuhelptest.c: Add -mem-path constants
      * tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add tests for hugepage
        handling
      * tests/qemuxml2argvdata/qemuxml2argv-hugepages.xml,
        tests/qemuxml2argvdata/qemuxml2argv-hugepages.args: Data files for
        hugepage tests
      d823a05a
  20. 24 7月, 2009 2 次提交
    • D
      Implement schedular tunables API using cgroups · 55bc5090
      Daniel P. Berrange 提交于
      * src/qemu_driver.c:  Add driver methods qemuGetSchedulerType,
        qemuGetSchedulerParameters, qemuSetSchedulerParameters
      * src/lxc_driver.c: Fix to use unsigned long long consistently
        for schedular parameters
      * src/cgroup.h, src/cgroup.c: Fix cpu_shares to take unsigned
        long long
      * src/util.c, src/util.h, src/libvirt_private.syms: Add a
        virStrToDouble helper
      * src/virsh.c: Fix handling of --set arg to schedinfo command
        to honour the designated data type of each schedular tunable
        as declared by the driver
      55bc5090
    • D
      Refactor cgroups to allow a group per driver to be managed directly · 946c489c
      Daniel P. Berrange 提交于
      Allow the driver level cgroup to be managed explicitly by the
      hypervisor drivers, in order to detect whether to enable or
      disable cgroup support for domains. Provides better error
      reporting of failures. Also allow for creation of cgroups for
      unprivileged drivers if controller is accessible by the user.
      
      * src/cgroup.c, src/cgroup.h: Add an API to obtain a driver cgroup
      * src/lxc_conf.h, src/lxc_controller.c, src/lxc_driver.c:
        Obtain a driver cgroup at startup and use that instead of
        re-creating everytime.
      * src/util.c, src/util.h, src/libvirt_private.syms: Add a
        virGetUserName() helper
      946c489c
  21. 23 7月, 2009 1 次提交
    • D
      Fix misc Win32 compile warnings · 899ae0d2
      Daniel P. Berrange 提交于
      GCC >= 4.4 assumes the 'printf' attribute refers to the native
      runtime libraries format specifiers. Thanks to gnulib, libvirt
      has GNU format specifiers everywhere.  This means we need to
      use 'gnu_printf' with GCC >= 4.4 to get correct compiler
      checking of printf format specifiers.
      
      * HACKING: Document new rules for ATTRIBUTE_FMT_PRINTF
      * autobuild.sh, mingw32-libvirt.spec.in: Disable OpenNebula
        driver on mingw32 builds
      * qemud/dispatch.h, qemud/qemu.h, src/buf.h src/internal.h,
        src/logging.h, src/security.h, src/sexpr.h, src/util.h,
        src/virterror_internal.h, src/xend_internal.c: Change
        over to ATTRIBUTE_FMT_PRINTF.
      * src/virsh.c: Disable 'cd' and 'pwd' commands on Win32
        since they don't compile
      * src/threads-win32.c: Add missing return value check
      899ae0d2
  22. 17 7月, 2009 1 次提交
    • D
      Run QEMU guests as an unprivileged user · 0714b2ba
      Daniel P. Berrange 提交于
      * configure.in: Add --with-qemu-user and --with-qemu-group args
      * libvirt.spec.in: use 'qemu' for user/group for Fedora >= 12
      * qemud/libvirtd_qemu.arg, qemud/test_libvirtd_qemu.aug,
        src/qemu.conf: Add 'user' and 'group' args for configuration
      * src/Makefile.am: Create %localstatedir/cache/libvirt/qemu
      * src/qemu_conf.c, src/qemu_conf.h: Load user/group from config
      * src/qemu_driver.c: Change user ID/group ID when launching QEMU
        guests. Change user/group ownership on disks/usb/pci devs.
        Put memory dumps in %localstatedir/cache/libvirt/qemu
      * src/util.c, src/util.h: Add convenient APIs for converting
        username/groupname to user ID / group ID
      0714b2ba
  23. 30 6月, 2009 1 次提交
  24. 11 6月, 2009 1 次提交
  25. 11 5月, 2009 2 次提交
    • C
      Add pidfile argument to __virExec · a331653d
      Cole Robinson 提交于
      virExec will write out the pid of the daemonized process only. Use this
      in the QEMU driver, rather than QEMU's pidfile, so we can catch errors we
      might miss if the emulator bails early.
      a331653d
    • C
      Add helper function virExecDaemonize · 79d9d243
      Cole Robinson 提交于
      Wraps __virExec with the VIR_EXEC_DAEMON flag. Waits on the intermediate
      process to ensure we don't end up with any zombies, and differentiates between
      original process errors and intermediate process errors.
      79d9d243
  26. 22 4月, 2009 1 次提交
  27. 01 4月, 2009 1 次提交
  28. 20 3月, 2009 1 次提交
  29. 27 2月, 2009 1 次提交
  30. 14 2月, 2009 1 次提交
    • M
      Add virFileWriteStr() · 0bb6f816
      Mark McLoughlin 提交于
      Re-factor the code from networkEnableIpForwarding() into a
      utility function in preparation for code which writes to
      sysfs files.
      0bb6f816
  31. 06 2月, 2009 1 次提交
    • J
      remove duplicate *SetCloseExec and *SetNonBlock functions · b0d49913
      Jim Meyering 提交于
      * src/qemu_driver.c: Use virSetCloseExec and virSetNonBlock,
      rather than qemuSet* functions.  Suggested by Daniel P. Berrange.
      * src/util.c (virSetCloseExec): Publicize.
      * src/util.h (virSetCloseExec): Declare
      * src/libvirt_private.syms: Add virSetCloseExec.
      b0d49913
  32. 03 2月, 2009 1 次提交
    • J
      build: enable redundant-const check · dff21147
      Jim Meyering 提交于
      * Makefile.cfg (local-checks-to-skip): Remove sc_redundant_const.
      * src/lxc_controller.c: Remove redundant "const"(s).
      * src/storage_backend_fs.c: Likewise.
      * src/util.h: Likewise.
      * src/xen_internal.c: Likewise.
      * tests/qparamtest.c: Likewise.
      dff21147
  33. 23 1月, 2009 2 次提交
  34. 21 1月, 2009 1 次提交
  35. 07 1月, 2009 1 次提交