1. 07 9月, 2015 1 次提交
  2. 26 6月, 2015 1 次提交
  3. 10 3月, 2015 1 次提交
  4. 03 3月, 2015 1 次提交
  5. 09 5月, 2014 1 次提交
  6. 27 3月, 2014 1 次提交
  7. 06 6月, 2013 2 次提交
  8. 24 4月, 2013 1 次提交
  9. 26 3月, 2013 2 次提交
  10. 05 2月, 2013 1 次提交
    • E
      cutils: unsigned int parsing functions · e3f9fe2d
      Eduardo Habkost 提交于
      There are lots of duplicate parsing code using strto*() in QEMU, and
      most of that code is broken in one way or another. Even the visitors
      code have duplicate integer parsing code[1]. This introduces functions
      to help parsing unsigned int values: parse_uint() and parse_uint_full().
      
      Parsing functions for signed ints and floats will be submitted later.
      
      parse_uint_full() has all the checks made by opts_type_uint64() at
      opts-visitor.c:
      
       - Check for NULL (returns -EINVAL)
       - Check for negative numbers (returns -EINVAL)
       - Check for empty string (returns -EINVAL)
       - Check for overflow or other errno values set by strtoll() (returns
         -errno)
       - Check for end of string (reject invalid characters after number)
         (returns -EINVAL)
      
      parse_uint() does everything above except checking for the end of the
      string, so callers can continue parsing the remainder of string after
      the number.
      
      Unit tests included.
      
      [1] string-input-visitor.c:parse_int() could use the same parsing code
          used by opts-visitor.c:opts_type_int(), instead of duplicating that
          logic.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      e3f9fe2d
  11. 13 1月, 2013 1 次提交
  12. 02 1月, 2013 1 次提交
  13. 19 12月, 2012 1 次提交
  14. 30 10月, 2012 2 次提交
  15. 05 10月, 2012 1 次提交
  16. 15 8月, 2012 1 次提交
  17. 08 8月, 2012 2 次提交
  18. 26 7月, 2012 1 次提交
  19. 12 6月, 2012 7 次提交
    • M
      rewrite iov_send_recv() and move it to iov.c · 25e5e4c7
      Michael Tokarev 提交于
      Make it much more understandable, add a missing
      iov_cnt argument (number of iovs in the iov), and
      add comments to it.
      
      The new implementation has been extensively tested
      by splitting a large buffer into many small
      randomly-sized chunks, sending it over socket to
      another, slow process and verifying the receiving
      data is the same.
      
      Also add a unit test for iov_send_recv(), sending/
      receiving data between two processes over a socketpair
      using random vectors and random sizes.
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      25e5e4c7
    • M
      export iov_send_recv() and use it in iov_send() and iov_recv() · e3e87df4
      Michael Tokarev 提交于
      Rename do_sendv_recvv() to iov_send_recv(), change its last arg
      (do_send) from int to bool, export it in iov.h, and made the two
      callers of it (iov_send() and iov_recv()) to be trivial #defines
      just adding 5th arg.
      
      iov_send_recv() will be used later.
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      e3e87df4
    • M
      rename qemu_sendv to iov_send, change proto and move declarations to iov.h · 3e80bf93
      Michael Tokarev 提交于
      Rename arguments and use size_t for sizes instead of int,
      from
       int
       qemu_sendv(int sockfd, struct iovec *iov,
                  int len, int iov_offset)
      to
       ssize_t
       iov_send(int sockfd, struct iovec *iov,
                size_t offset, size_t bytes)
      
      The main motivation was to make it clear that length
      and offset are in _bytes_, not in iov elements: it was
      very confusing before, because all standard functions
      which deals with iovecs expects number of iovs, not
      bytes, even the fact that struct iovec has iov_len and
      iov_ prefix does not help.  With "bytes" and "offset",
      especially since they're now size_t, it is much more
      explicit.  Also change the return type to be ssize_t
      instead of int.
      
      This also changes it to match other iov-related functons,
      but not _quite_: there's still no argument indicating
      where iovec ends, ie, no iov_cnt parameter as used
      in iov_size() and friends.  If will be added in subsequent
      patch/rewrite.
      
      All callers of qemu_sendv() and qemu_recvv() and
      related, like qemu_co_sendv() and qemu_co_recvv(),
      were checked to verify that it is safe to use unsigned
      datatype instead of int.
      
      Note that the order of arguments is changed to: offset
      and bytes (len and iov_offset) are swapped with each
      other.  This is to make them consistent with very similar
      functions from qemu_iovec family, where offset always
      follows qiov, to mean the place in it to start from.
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      3e80bf93
    • M
      change qemu_iovec_to_buf() to match other to,from_buf functions · d5e6b161
      Michael Tokarev 提交于
      It now allows specifying offset within qiov to start from and
      amount of bytes to copy.  Actual implementation is just a call
      to iov_to_buf().
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      d5e6b161
    • M
      consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistent · 1b093c48
      Michael Tokarev 提交于
      qemu_iovec_concat() is currently a wrapper for
      qemu_iovec_copy(), use the former (with extra
      "0" arg) in a few places where it is used.
      
      Change skip argument of qemu_iovec_copy() from
      uint64_t to size_t, since size of qiov itself
      is size_t, so there's no way to skip larger
      sizes.  Rename it to soffset, to make it clear
      that the offset is applied to src.
      
      Also change the only usage of uint64_t in
      hw/9pfs/virtio-9p.c, in v9fs_init_qiov_from_pdu() -
      all callers of it actually uses size_t too,
      not uint64_t.
      
      One added restriction: as for all other iovec-related
      functions, soffset must point inside src.
      
      Order of argumens is already good:
       qemu_iovec_memset(QEMUIOVector *qiov, size_t offset,
                         int c, size_t bytes)
      vs:
       qemu_iovec_concat(QEMUIOVector *dst,
                         QEMUIOVector *src,
                         size_t soffset, size_t sbytes)
      (note soffset is after _src_ not dst, since it applies to src;
      for memset it applies to qiov).
      
      Note that in many places where this function is used,
      the previous call is qemu_iovec_reset(), which means
      many callers actually want copy (replacing dst content),
      not concat.  So we may want to add a wrapper like
      qemu_iovec_copy() with the same arguments but which
      calls qemu_iovec_reset() before _concat().
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      1b093c48
    • M
      allow qemu_iovec_from_buffer() to specify offset from which to start copying · 03396148
      Michael Tokarev 提交于
      Similar to
       qemu_iovec_memset(QEMUIOVector *qiov, size_t offset,
                         int c, size_t bytes);
      the new prototype is:
       qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset,
                           const void *buf, size_t bytes);
      
      The processing starts at offset bytes within qiov.
      
      This way, we may copy a bounce buffer directly to
      a middle of qiov.
      
      This is exactly the same function as iov_from_buf() from
      iov.c, so use the existing implementation and rename it
      to qemu_iovec_from_buf() to be shorter and to match the
      utility function.
      
      As with utility implementation, we now assert that the
      offset is inside actual iovec.  Nothing changed for
      current callers, because `offset' parameter is new.
      
      While at it, stop using "bounce-qiov" in block/qcow2.c
      and copy decrypted data directly from cluster_data
      instead of recreating a temp qiov for doing that.
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      03396148
    • M
      consolidate qemu_iovec_memset{,_skip}() into single function and use existing iov_memset() · 3d9b4925
      Michael Tokarev 提交于
      This patch combines two functions into one, and replaces
      the implementation with already existing iov_memset() from
      iov.c.
      
      The new prototype of qemu_iovec_memset():
        size_t qemu_iovec_memset(qiov, size_t offset, int fillc, size_t bytes)
      It is different from former qemu_iovec_memset_skip(), and
      I want to make other functions to be consistent with it
      too: first how much to skip, second what, and 3rd how many
      of it.  It also returns actual number of bytes filled in,
      which may be less than the requested `bytes' if qiov is
      smaller than offset+bytes, in the same way iov_memset()
      does.
      
      While at it, use utility function iov_memset() from
      iov.h in posix-aio-compat.c, where qiov was used.
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      3d9b4925
  20. 09 2月, 2012 1 次提交
  21. 22 12月, 2011 1 次提交
  22. 15 12月, 2011 1 次提交
  23. 29 11月, 2011 2 次提交
    • M
      cutils: Make strtosz & friends leave follow set to callers · eba90e4e
      Markus Armbruster 提交于
      strtosz() & friends require the size to be at the end of the string,
      or be followed by whitespace or ','.  I find this surprising, because
      the name suggests it works like strtol().
      
      The check simplifies callers that accept exactly that follow set
      slightly.  No such callers exist.
      
      The check is redundant for callers that accept a smaller follow set,
      and thus need to check themselves anyway.  Right now, this is the case
      for all but one caller.  All of them neglected to check, or checked
      incorrectly, but the previous few commits fixed them up.
      
      Finally, the check is problematic for callers that accept a larger
      follow set.  This is the case in monitor_parse_command().
      Fortunately, the problems there are relatively harmless.
      
      monitor_parse_command() uses strtosz() for argument type 'o'.  When
      the last argument is of type 'o', a trailing ',' is diagnosed
      differently than other trailing junk:
      
          (qemu) migrate_set_speed 1x
          invalid size
          (qemu) migrate_set_speed 1,
          migrate_set_speed: extraneous characters at the end of line
      
      A related inconsistency exists with non-last arguments.  No such
      command exists, but let's use memsave to explore the inconsistency.
      
      The monitor permits, but does not require whitespace between
      arguments.  For instance, "memsave (1-1)1024foo" is parsed as command
      memsave with three arguments 0, 1024 and "foo".  Yes, this is daft,
      but at least it's consistently daft.
      
      If I change memsave's second argument from 'i' to 'o', then "memsave
      (1-1)1foo" is rejected, because the size is followed by an 'f'.  But
      "memsave (1-1)1," is still accepted, and duly saves to file ",".
      
      We don't have any users of strtosz that profit from the check.  In the
      users we have, it appears to encourage sloppy error checking, or gets
      in the way.  Drop the bothersome check.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      eba90e4e
    • M
      cutils: Drop broken support for zero strtosz default_suffix · 8dddfb55
      Markus Armbruster 提交于
      Commit 9f9b17a4's strtosz() defaults a missing suffix to 'M', except
      it rejects fractions then (switch case 0).
      
      When commit d8427002 introduced strtosz_suffix(), that changed:
      fractions are no longer rejected, because we go to switch case 'M' on
      missing suffix now.  Not mentioned in commit message, probably
      unintentional.  Not worth changing back now.
      
      Because case 0 is still around, you can get the old behavior by
      passing a zero default_suffix to strtosz_suffix() or
      strtosz_suffix_unit().  Undocumented and not used.  Drop.
      
      Commit d8427002 also neglected to update the function comment.  Fix it
      up.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      8dddfb55
  24. 02 11月, 2011 1 次提交
  25. 25 8月, 2011 1 次提交
  26. 21 8月, 2011 1 次提交
  27. 05 8月, 2011 1 次提交
  28. 10 2月, 2011 1 次提交
    • C
      QCOW2: bug fix - read base image beyond its size · e0d9c6f9
      Chunqiang Tang 提交于
      This patch fixes the following bug in QCOW2. For a QCOW2 image that is larger
      than its base image, when handling a read request straddling over the end of the
      base image, the QCOW2 driver attempts to read beyond the end of the base image
      and the request would fail.
      
      This bug was found by Fast Virtual Disk (FVD)'s fully automated testing tool.
      The following test triggered the bug.
      
      dd if=/dev/zero of=/var/ramdisk/truth.raw count=0 bs=1 seek=1098561536
      dd if=/dev/zero of=/var/ramdisk/zero-500M.raw count=0 bs=1 seek=593099264
      ./qemu-img create -f qcow2 -ocluster_size=65536,backing_fmt=blksim -b /var/ramdisk/zero-500M.raw /var/ramdisk/test.qcow2 1098561536
      ./qemu-io --auto --seed=30477694 --truth=/var/ramdisk/truth.raw --format=qcow2 --test=blksim:/var/ramdisk/test.qcow2 --verify_write=true --compare_before=false --compare_after=true --round=100000 --parallel=100 --io_size=10485760 --fail_prob=0 --cancel_prob=0 --instant_qemubh=true
      Signed-off-by: NChunqiang Tang <ctang@us.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e0d9c6f9
  29. 31 1月, 2011 1 次提交