1. 21 9月, 2015 1 次提交
    • J
      virfile: Rename virFileUnlink to virFileRemove · 1b046a68
      John Ferlan 提交于
      Similar to commit id '35847860', it's possible to attempt to create
      a 'netfs' directory in an NFS root-squash environment which will cause
      the 'vol-delete' command to fail.  It's also possible error paths from
      the 'vol-create' would result in an error to remove a created directory
      if the permissions were incorrect (and disallowed root access).
      
      Thus rename the virFileUnlink to be virFileRemove to match the C API
      functionality, adjust the code to following using rmdir or unlink
      depending on the path type, and then use/call it for the VIR_STORAGE_VOL_DIR
      1b046a68
  2. 02 9月, 2015 1 次提交
    • J
      virfile: Introduce virFileUnlink · 35847860
      John Ferlan 提交于
      In an NFS root-squashed environment the 'vol-delete' command will fail to
      'unlink' the target volume since it was created under a different uid:gid.
      
      This code continues the concepts introduced in virFileOpenForked and
      virDirCreate[NoFork] with respect to running the unlink command under
      the uid/gid of the child. Unlike the other two, don't retry on EACCES
      (that's why we're here doing this now).
      35847860
  3. 20 5月, 2015 1 次提交
  4. 09 1月, 2015 1 次提交
    • J
      safezero: fall back to writing zeroes even when resizing · 1390c268
      Ján Tomko 提交于
      Remove the resize flag and use the same code path for all callers.
      This flag was added by commit 18f03166 to allow virStorageFileResize
      use 'safezero' while preserving the behavior.
      
      Explicitly return -2 when a fallback to a different method should
      be done, to make the code path more obvious.
      
      Fail immediately when ftruncate fails in the mmap method,
      as we did before commit 18f03166.
      1390c268
  5. 17 12月, 2014 1 次提交
    • J
      virstoragefile: Have virStorageFileResize use safezero · 18f03166
      John Ferlan 提交于
      Currently virStorageFileResize() function uses build conditionals to
      choose either the posix_fallocate() or syscall(SYS_fallocate) with no
      fallback in order to preallocate the space in the newly resized file.
      
      Since the safezero code has a similar set of conditionals modify the
      resize and safezero code in order to allow the resize logic to make use
      of safezero to unify the look/feel of the code paths.
      
      Add a new boolean (resize) to safezero() to make the optional decision
      whether to try syscall(SYS_fallocate) if the posix_fallocate fails because
      HAVE_POSIX_FALLOCATE is not defined (eg, return -1 and errno == 0).
      
      Create a local safezero_sys_fallocate in order to handle the resize
      code paths that support that.  If not present, the set errno = ENOSYS
      in order to allow the caller to handle the failure scenarios.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      18f03166
  6. 29 7月, 2014 1 次提交
  7. 01 7月, 2014 1 次提交
    • J
      Introduce virFileReadAllQuiet · f638c13e
      Ján Tomko 提交于
      Just like virFileReadAll, but returns -errno instead
      of reporting errors. Useful for ignoring some errors.
      f638c13e
  8. 06 5月, 2014 1 次提交
  9. 29 4月, 2014 1 次提交
  10. 25 4月, 2014 1 次提交
  11. 12 4月, 2014 1 次提交
    • E
      util: new virFileRelLinkPointsTo function · 91f349d8
      Eric Blake 提交于
      When checking if two filenames point to the same inode (whether
      by hardlink or symlink), sometimes one of the names might be
      relative.  This convenience function makes it easier to check.
      
      * src/util/virfile.h (virFileRelLinkPointsTo): New prototype.
      * src/util/virfile.c (virFileRelLinkPointsTo): New function.
      * src/libvirt_private.syms (virfile.h): Export it.
      * src/xen/xm_internal.c (xenXMDomainGetAutostart): Use it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      91f349d8
  12. 02 4月, 2014 1 次提交
    • E
      util: move detection of shared filesystems · 5160ab79
      Eric Blake 提交于
      The code in virstoragefile.c is getting more complex as I
      consolidate backing chain handling code.  But for the setuid
      virt-login-shell, we don't need to crawl backing chains.  It's
      easier to audit things for setuid security if there are fewer
      files involved, so this patch moves the one function that
      virFileOpen() was actually relying on to also live in virfile.c.
      
      * src/util/virstoragefile.c (virStorageFileIsSharedFS)
      (virStorageFileIsSharedFSType): Move...
      * src/util/virfile.c (virFileIsSharedFS, virFileIsSharedFSType):
      ...to here, and rename.
      (virFileOpenAs): Update caller.
      * src/security/security_selinux.c
      (virSecuritySELinuxSetFileconHelper)
      (virSecuritySELinuxSetSecurityAllLabel)
      (virSecuritySELinuxRestoreSecurityImageLabelInt): Likewise.
      * src/security/security_dac.c
      (virSecurityDACRestoreSecurityImageLabelInt): Likewise.
      * src/qemu/qemu_driver.c (qemuOpenFileAs): Likewise.
      * src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
      * src/util/virstoragefile.h: Adjust declarations.
      * src/util/virfile.h: Likewise.
      * src/libvirt_private.syms (virfile.h, virstoragefile.h): Move
      symbols as appropriate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5160ab79
  13. 18 3月, 2014 1 次提交
    • N
      Add parameter to wait for lock in file locking APIs · 2250a2b5
      Nehal J Wani 提交于
      Our current pidfile acquire APis (virPidFileAcquire) simply return -1 upon
      failure to acquire a lock. This patch adds a parameter 'bool waitForLock'
      which instructs the APIs if we want to make it block and wait for the lock
      or not.
      2250a2b5
  14. 18 2月, 2014 1 次提交
  15. 28 11月, 2013 1 次提交
  16. 07 11月, 2013 1 次提交
    • E
      storage: avoid short reads while chasing backing chain · 5327fad4
      Eric Blake 提交于
      Our backing file chain code was not very robust to an ill-timed
      EINTR, which could lead to a short read causing us to randomly
      treat metadata differently than usual.  But the existing
      virFileReadLimFD forces an error if we don't read the entire
      file, even though we only care about the header of the file.
      So add a new virFile function that does what we want.
      
      * src/util/virfile.h (virFileReadHeaderFD): New prototype.
      * src/util/virfile.c (virFileReadHeaderFD): New function.
      * src/libvirt_private.syms (virfile.h): Export it.
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormatFromFD): Use it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5327fad4
  17. 05 11月, 2013 1 次提交
  18. 01 6月, 2013 1 次提交
  19. 13 5月, 2013 1 次提交
  20. 11 5月, 2013 1 次提交
    • L
      util: move virFile* functions from virutil.c to virfile.c · bfe7721d
      Laine Stump 提交于
      These all existed before virfile.c was created, and for some reason
      weren't moved.
      
      This is mostly straightfoward, although the syntax rule prohibiting
      write() had to be changed to have an exception for virfile.c instead
      of virutil.c.
      
      This movement pointed out that there is a function called
      virBuildPath(), and another almost identical function called
      virFileBuildPath(). They really should be a single function, which
      I'll take care of as soon as I figure out what the arglist should look
      like.
      bfe7721d
  21. 16 4月, 2013 1 次提交
  22. 08 2月, 2013 1 次提交
    • M
      Drop useless virFileWrapperFdCatchError · 4ca6f508
      Michal Privoznik 提交于
      We are requesting for stderr catching for all cases in
      virFileWrapperFdNew(). There is no need to have a separate
      function just to report an error, esp. when we can do it in
      virFileWrapperFdClose().
      4ca6f508
  23. 30 10月, 2012 1 次提交
    • M
      qemu: Report errors from iohelper · 34e8f63a
      Michal Privoznik 提交于
      Currently, we use iohelper when saving/restoring a domain.
      However, if there's some kind of error (like I/O) it is not
      propagated to libvirt. Since it is not qemu who is doing
      the actual write() it will not get error. The iohelper does.
      Therefore we should check for iohelper errors as it makes
      libvirt more user friendly.
      34e8f63a
  24. 21 9月, 2012 1 次提交
  25. 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
  26. 05 7月, 2012 1 次提交
  27. 28 6月, 2012 1 次提交
  28. 08 6月, 2012 1 次提交
    • J
      util: Fix deadlock in virLogReset · d581313a
      Jiri Denemark 提交于
      When libvirtd forks off a new child, the child then calls virLogReset(),
      which ends up closing file descriptors used as log outputs. However, we
      recently started logging closed file descriptors, which means we need to
      lock logging mutex which was already locked by virLogReset(). We don't
      really want to log anything when we are in the process of closing log
      outputs.
      d581313a
  29. 04 6月, 2012 1 次提交
    • J
      file: Log closing filedescriptors · dfd45843
      Jiri Denemark 提交于
      EBADF errors are logged as warnings as they normally indicate a double
      close bug. This patch also provides VIR_MASS_CLOSE helper to be user in
      the only case of mass close after fork when EBADF should rather be
      ignored.
      dfd45843
  30. 30 4月, 2012 1 次提交
    • J
      qemu: Make sure qemu can access its directory in hugetlbfs · 9d2ac545
      Jiri Denemark 提交于
      When libvirtd is started, we create "libvirt/qemu" directories under
      hugetlbfs mount point. Only the "qemu" subdirectory is chowned to qemu
      user and "libvirt" remains owned by root. If umask was too restrictive
      when libvirtd started, qemu user may lose access to "qemu"
      subdirectory. Let's explicitly grant search permissions to "libvirt"
      directory for all users.
      9d2ac545
  31. 20 2月, 2012 1 次提交
    • L
      Fix compilation on MacOS X · 10269064
      Lincoln Myers 提交于
      * src/util/virfile.h: the virFileWrapperFdFlags being defined as
        a globa variable instead of a type ended up generating a duplicate
        symbol error.
      * AUTHORS: added Lincoln Myers
      10269064
  32. 08 2月, 2012 1 次提交
    • J
      util: Generalize virFileDirectFd · afe6e58a
      Jiri Denemark 提交于
      virFileDirectFd was used for accessing files opened with O_DIRECT using
      libvirt_iohelper. We will want to use the helper for accessing files
      regardless on O_DIRECT and thus virFileDirectFd was generalized and
      renamed to virFileWrapperFd.
      afe6e58a
  33. 25 1月, 2012 1 次提交
  34. 28 10月, 2011 1 次提交
    • J
      Introduce virFileRewrite for safe file rewrite · 559644dd
      Jiri Denemark 提交于
      When saving config files we just overwrite old content of the file. In
      case something fails during that process (e.g. disk gets full) we lose
      both old and new content. This patch makes the process more robust by
      writing the new content into a separate file and only if that succeeds
      the original file is atomically replaced with the new one.
      559644dd
  35. 13 8月, 2011 1 次提交
    • D
      Add virFileLock and virFileUnlock APIs · e4842705
      Daniel P. Berrange 提交于
      Add some simple wrappers around the fcntl() discretionary file
      locking capability.
      
      * src/util/util.c, src/util/util.h, src/libvirt_private.syms: Add
        virFileLock and virFileUnlock APIs
      e4842705
  36. 22 7月, 2011 2 次提交
    • E
      save: add virFileDirectFd wrapper type · 519a1c43
      Eric Blake 提交于
      O_DIRECT has stringent requirements.  Rather than make lots of changes
      at each site that wants to use O_DIRECT, it is easier to offload
      the work through a helper process that mirrors the I/O between a
      pipe and the actual direct fd, so that the other end of the pipe
      no longer has to worry about constraints.
      
      Plus, if the kernel ever gains better posix_fadvise support, then we
      only have to touch a single file to let all callers benefit from a
      more efficient way to avoid file system caching.
      
      * src/util/virfile.h (virFileDirectFdFlag, virFileDirectFdNew)
      (virFileDirectFdClose, virFileDirectFdFree): New prototypes.
      * src/util/virdirect.c: Implement new wrapper object.
      * src/libvirt_private.syms (virfile.h): Export new symbols.
      * cfg.mk (useless_free_options): Add to list.
      * po/POTFILES.in: Add new translations.
      519a1c43
    • 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
  37. 20 7月, 2011 1 次提交
  38. 24 2月, 2011 1 次提交
  39. 30 1月, 2011 1 次提交
    • E
      maint: reject raw close, popen in 'make syntax-check' · 030ce43b
      Eric Blake 提交于
      commit f1fe9671 was supposed to make sure we use files.h
      macros to avoid double close, but it didn't work.
      
      Meanwhile, virCommand is vastly superior to system(), fork(),
      and popen() (also to virExec, but we haven't completed that
      conversion), so enforce that, too.
      
      * cfg.mk (sc_prohibit_close): Fix typo that excluded close, and
      add pclose.
      (sc_prohibit_fork_wrappers): New rule, for fork, system, and popen.
      * .x-sc_prohibit_close: More exemptions.
      * .x-sc_prohibit_fork_wrappers: New file.
      * Makefile.am (syntax_check_exceptions): Ship new file.
      * src/datatypes.c (virReleaseConnect): Tweak comment to avoid
      false positive.
      * src/util/files.h (VIR_CLOSE): Likewise.
      030ce43b