1. 21 9月, 2017 1 次提交
    • D
      iohelper: avoid calling read() with misaligned buffers for O_DIRECT · 633b699b
      Daniel P. Berrange 提交于
      The iohelper currently calls saferead() to get data from the
      underlying file. This has a problem with O_DIRECT when hitting
      end-of-file. saferead() is asked to read 1MB, but the first
      read() it does may return only a few KB, so it'll try another
      read() to fill the remaining buffer. Unfortunately the buffer
      pointer passed into this 2nd read() is likely not aligned
      to the extent that O_DIRECT requires, so rather than seeing
      '0' for end-of-file, we'll get -1 + EINVAL due to misaligned
      buffer.
      
      The way the iohelper is currently written, it already handles
      getting short reads, so there is actually no need to use
      saferead() at all. We can simply call read() directly. The
      benefit of this is that we can now write() the data immediately
      so when we go into the subsequent reads() we'll always have a
      correctly aligned buffer.
      
      Technically the file position ought to be aligned for O_DIRECT
      too, but this does not appear to matter when at end-of-file.
      Tested-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      633b699b
  2. 19 9月, 2017 3 次提交
  3. 28 4月, 2017 1 次提交
  4. 20 5月, 2016 1 次提交
  5. 15 4月, 2016 1 次提交
  6. 25 3月, 2014 1 次提交
  7. 10 7月, 2013 1 次提交
  8. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  9. 21 12月, 2012 4 次提交
  10. 05 11月, 2012 1 次提交
  11. 01 11月, 2012 1 次提交
    • M
      iohelper: fdatasync() at the end · f32e3a2d
      Michal Privoznik 提交于
      Currently, when we are doing (managed) save, we insert the
      iohelper between the qemu and OS. The pipe is created, the
      writing end is passed to qemu and the reading end to the
      iohelper. It reads data and write them into given file. However,
      with write() being asynchronous data may still be in OS
      caches and hence in some (corner) cases, all migration data
      may have been read and written (not physically though). So
      qemu will report success, as well as iohelper. However, with
      some non local filesystems, where ENOSPACE is polled every X
      time units, we may get into situation where all operations
      succeeded but data hasn't reached the disk. And in fact will
      never do. Therefore we ought sync caches to make sure data
      has reached the block device on remote host.
      f32e3a2d
  12. 21 9月, 2012 1 次提交
  13. 06 8月, 2012 1 次提交
    • E
      virrandom: make virRandomInitialize an automatic one-shot · 87de27b7
      Eric Blake 提交于
      All callers used the same initialization seed (well, the new
      viratomictest forgot to look at getpid()); so we might as well
      make this value automatic.  And while it may feel like we are
      giving up functionality, I documented how to get it back in the
      unlikely case that you actually need to debug with a fixed
      pseudo-random sequence.  I left that crippled by default, so
      that a stray environment variable doesn't cause a lack of
      randomness to become a security issue.
      
      * src/util/virrandom.c (virRandomInitialize): Rename...
      (virRandomOnceInit): ...and make static, with one-shot call.
      Document how to do fixed-seed debugging.
      * src/util/virrandom.h (virRandomInitialize): Drop prototype.
      * src/libvirt_private.syms (virrandom.h): Don't export it.
      * src/libvirt.c (virInitialize): Adjust caller.
      * src/lxc/lxc_controller.c (main): Likewise.
      * src/security/virt-aa-helper.c (main): Likewise.
      * src/util/iohelper.c (main): Likewise.
      * tests/seclabeltest.c (main): Likewise.
      * tests/testutils.c (virtTestMain): Likewise.
      * tests/viratomictest.c (mymain): Likewise.
      87de27b7
  14. 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
  15. 26 1月, 2012 1 次提交
    • 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
  16. 25 11月, 2011 1 次提交
  17. 22 7月, 2011 3 次提交
    • E
      save: let iohelper work on O_DIRECT fds · 12291656
      Eric Blake 提交于
      Required for a coming patch where iohelper will operate on O_DIRECT
      fds.  There, the user-space memory must be aligned to file system
      boundaries (at least 512, but using page-aligned works better, and
      some file systems prefer 64k).  Made tougher by the fact that
      VIR_ALLOC won't work on void *, but posix_memalign won't work on
      char * and isn't available everywhere.
      
      This patch makes some simplifying assumptions - namely, output
      to an O_DIRECT fd will only be attempted on an empty seekable
      file (hence, no need to worry about preserving existing data
      on a partial block, and ftruncate will work to undo the effects
      of having to round up the size of the last block written), and
      input from an O_DIRECT fd will only be attempted on a complete
      seekable file with the only possible short read at EOF.
      
      * configure.ac (AC_CHECK_FUNCS_ONCE): Check for posix_memalign.
      * src/util/iohelper.c (runIO): Use aligned memory, and handle
      quirks of O_DIRECT on last write.
      12291656
    • E
      save: let iohelper handle inherited fd · 1eb66479
      Eric Blake 提交于
      Rather than making the iohelper subject to a race in reopening
      the file, it is nicer to pass an already-open fd by inheritance.
      
      The old synopsis form must continue to work - if someone updates
      their libvirt package and installs a new libvirt_iohelper but
      without restarting the old libvirtd daemon, then the daemon can
      still make calls using the old syntax but the new iohelper.
      
      * src/util/iohelper.c (runIO): Split code for open...
      (prepare): ...to new function.
      (usage): Update synopsis.
      (main): Allow alternate calling form.
      * src/fdstream.c (virFDStreamOpenFileInternal): Use alternate form.
      1eb66479
    • 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
  18. 16 7月, 2011 1 次提交
    • E
      build: add syntax check for proper flags use · 761bbb17
      Eric Blake 提交于
      Enforce the recent flags cleanups - we want to use 'unsigned int flags'
      in any of our APIs (except where backwards compatibility is important,
      in the public migration APIs), and that all flags are checked for
      validity (except when there are stub functions that completely
      ignore the flags argument).
      
      There are a few minor tweaks done here to avoid false positives:
      signed arguments passed to open() are renamed oflags, and flags
      arguments that are legitimately ignored are renamed flags_unused.
      
      * cfg.mk (sc_flags_usage): New rule.
      (exclude_file_name_regexp--sc_flags_usage): And a few exemptions.
      (sc_flags_debug): Tweak wording.
      * src/util/iohelper.c (runIO, main): Rename variable.
      * src/util/util.c (virSetInherit): Likewise.
      * src/fdstream.h (virFDStreamOpenFile, virFDStreamCreateFile):
      Likewise.
      * src/fdstream.c (virFDStreamOpenFileInternal)
      (virFDStreamOpenFile, virFDStreamCreateFile): Likewise.
      * src/util/command.c (virExecWithHook) [WIN32]: Likewise.
      * src/util/util.c (virFileOpenAs, virDirCreate) [WIN32]: Likewise.
      * src/locking/lock_manager.c (virLockManagerPluginNew)
      [!HAVE_DLFCN_H]: Likewise.
      * src/locking/lock_driver_nop.c (virLockManagerNopNew)
      (virLockManagerNopAddResource, virLockManagerNopAcquire)
      (virLockManagerNopRelease, virLockManagerNopInquire): Likewise.
      761bbb17
  19. 13 5月, 2011 1 次提交
    • M
      virFDStream: Add option for delete file after it's opening · 6a1f5f56
      Michal Privoznik 提交于
      This is needed if we want to transfer a temporary file. If the
      transfer is done with iohelper, we might run into a race condition,
      where we unlink() file before iohelper is executed.
      
      * src/fdstream.c, src/fdstream.h,
        src/util/iohelper.c: Add new option
      * src/lxc/lxc_driver.c, src/qemu/qemu_driver.c,
        src/storage/storage_driver.c, src/uml/uml_driver.c,
        src/xen/xen_driver.c: Expand existing function calls
      6a1f5f56
  20. 29 3月, 2011 1 次提交
    • D
      Enhance the streams helper to support plain file I/O · e886237a
      Daniel P. Berrange 提交于
      The O_NONBLOCK flag doesn't work as desired on plain files
      or block devices. Introduce an I/O helper program that does
      the blocking I/O operations, communicating over a pipe that
      can support O_NONBLOCK
      
      * src/fdstream.c, src/fdstream.h: Add non-blocking I/O
        on plain files/block devices
      * src/Makefile.am, src/util/iohelper.c: I/O helper program
      * src/qemu/qemu_driver.c, src/lxc/lxc_driver.c,
        src/uml/uml_driver.c, src/xen/xen_driver.c: Update for
        streams API change
      e886237a