1. 14 9月, 2015 2 次提交
  2. 11 9月, 2015 1 次提交
  3. 08 7月, 2015 1 次提交
  4. 22 5月, 2015 3 次提交
  5. 10 3月, 2015 3 次提交
    • M
      qcow2: Use 64 bits for refcount values · 0e06528e
      Max Reitz 提交于
      Refcounts may have a width of up to 64 bits, so qemu should use the same
      width to represent refcount values internally.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0e06528e
    • M
      qcow2: Use unsigned addend for update_refcount() · 2aabe7c7
      Max Reitz 提交于
      update_refcount() and qcow2_update_cluster_refcount() currently take a
      signed addend. At least one caller passes a value directly derived from
      an absolute refcount that should be reached ("l2_refcount - 1" in
      expand_zero_clusters_in_l1()). Therefore, the addend should be unsigned
      as well; this will be especially important for 64 bit refcounts.
      
      Because update_refcount() then no longer knows whether the refcount
      should be increased or decreased, it now requires an additional flag
      which specified exactly that. The same applies to
      qcow2_update_cluster_refcount().
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      2aabe7c7
    • M
      qcow2: Only return status from qcow2_get_refcount · 7324c10f
      Max Reitz 提交于
      Refcounts can theoretically be of type uint64_t; in order to be able to
      represent the full range, qcow2_get_refcount() cannot use a single
      variable to represent both all refcount values and also keep some values
      reserved for errors.
      
      One solution would be to add an Error pointer parameter to
      qcow2_get_refcount(); however, no caller could (currently) pass that
      error message, so it would have to be emitted immediately and be
      passed to the next caller by returning -EIO or something similar.
      Therefore, an Error parameter does not offer any advantages here.
      
      The solution applied by this patch is simpler to use. Because no caller
      would be able to pass the error message, they would have to print it and
      free it, whereas with this patch the caller only needs to pass the
      returned integer (which is often a no-op from the code perspective,
      because that integer will be stored in a variable "ret" which will be
      returned by the fail path of many callers).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      7324c10f
  6. 24 1月, 2015 1 次提交
  7. 10 12月, 2014 1 次提交
  8. 03 11月, 2014 3 次提交
  9. 23 10月, 2014 1 次提交
  10. 22 9月, 2014 1 次提交
  11. 20 8月, 2014 1 次提交
    • M
      block: Use g_new() & friends where that makes obvious sense · 5839e53b
      Markus Armbruster 提交于
      g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
      for two reasons.  One, it catches multiplication overflowing size_t.
      Two, it returns T * rather than void *, which lets the compiler catch
      more type errors.
      
      Patch created with Coccinelle, with two manual changes on top:
      
      * Add const to bdrv_iterate_format() to keep the types straight
      
      * Convert the allocation in bdrv_drop_intermediate(), which Coccinelle
        inexplicably misses
      
      Coccinelle semantic patch:
      
          @@
          type T;
          @@
          -g_malloc(sizeof(T))
          +g_new(T, 1)
          @@
          type T;
          @@
          -g_try_malloc(sizeof(T))
          +g_try_new(T, 1)
          @@
          type T;
          @@
          -g_malloc0(sizeof(T))
          +g_new0(T, 1)
          @@
          type T;
          @@
          -g_try_malloc0(sizeof(T))
          +g_try_new0(T, 1)
          @@
          type T;
          expression n;
          @@
          -g_malloc(sizeof(T) * (n))
          +g_new(T, n)
          @@
          type T;
          expression n;
          @@
          -g_try_malloc(sizeof(T) * (n))
          +g_try_new(T, n)
          @@
          type T;
          expression n;
          @@
          -g_malloc0(sizeof(T) * (n))
          +g_new0(T, n)
          @@
          type T;
          expression n;
          @@
          -g_try_malloc0(sizeof(T) * (n))
          +g_try_new0(T, n)
          @@
          type T;
          expression p, n;
          @@
          -g_realloc(p, sizeof(T) * (n))
          +g_renew(T, p, n)
          @@
          type T;
          expression p, n;
          @@
          -g_try_realloc(p, sizeof(T) * (n))
          +g_try_renew(T, p, n)
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NJeff Cody <jcody@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5839e53b
  12. 15 8月, 2014 2 次提交
    • M
      qcow2: Catch !*host_offset for data allocation · ff52aab2
      Max Reitz 提交于
      qcow2_alloc_cluster_offset() uses host_offset == 0 as "no preferred
      offset" for the (data) cluster range to be allocated. However, this
      offset is actually valid and may be allocated on images with a corrupted
      refcount table or first refcount block.
      
      In this case, the corruption prevention should normally catch that
      write anyway (because it would overwrite the image header). But since 0
      is a special value here, the function assumes that nothing has been
      allocated at all which it asserts against.
      
      Because this condition is not qemu's fault but rather that of a broken
      image, it shouldn't throw an assertion but rather mark the image corrupt
      and show an appropriate message, which this patch does by calling the
      corruption check earlier than it would be called normally (before the
      assertion).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      ff52aab2
    • K
      qcow2: Handle failure for potentially large allocations · de82815d
      Kevin Wolf 提交于
      Some code in the block layer makes potentially huge allocations. Failure
      is not completely unexpected there, so avoid aborting qemu and handle
      out-of-memory situations gracefully.
      
      This patch addresses the allocations in the qcow2 block driver.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      de82815d
  13. 28 5月, 2014 1 次提交
  14. 30 4月, 2014 1 次提交
    • M
      qcow2: Check min_size in qcow2_grow_l1_table() · b93f9950
      Max Reitz 提交于
      First, new_l1_size is an int64_t, whereas min_size is a uint64_t.
      Therefore, during the loop which adjusts new_l1_size until it equals or
      exceeds min_size, new_l1_size might overflow and become negative. The
      comparison in the loop condition however will take it as an unsigned
      value (because min_size is unsigned) and therefore recognize it as
      exceeding min_size. Therefore, the loop is left with a negative
      new_l1_size, which is not correct. This could be fixed by making
      new_l1_size uint64_t.
      
      On the other hand, however, by doing this, the while loop may take
      forever. If min_size is e.g. UINT64_MAX, it will take new_l1_size
      probably multiple overflows to reach the exact same value (if it reaches
      it at all). Then, right after the loop, new_l1_size will be recognized
      as being too big anyway.
      
      Both problems require a ridiculously high min_size value, which is very
      unlikely to occur; but both problems are also simply avoided by checking
      whether min_size is sane before calculating new_l1_size (which should
      still be checked separately, though).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b93f9950
  15. 29 4月, 2014 1 次提交
    • M
      qcow2: Fix discard · c883db0d
      Max Reitz 提交于
      discard_single_l2() should not implement its own version of
      qcow2_get_cluster_type(), but rather rely on this already existing
      function. By doing so, it will work for compressed clusters as well
      (which it did not so far).
      
      Also, rename "old_offset" to "old_l2_entry", as both are quite different
      (and the value is indeed of the latter kind).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c883db0d
  16. 04 4月, 2014 1 次提交
  17. 01 4月, 2014 2 次提交
  18. 13 3月, 2014 1 次提交
  19. 22 2月, 2014 1 次提交
  20. 09 2月, 2014 1 次提交
  21. 06 12月, 2013 1 次提交
  22. 28 11月, 2013 1 次提交
  23. 14 11月, 2013 1 次提交
    • P
      qcow2: fix possible corruption when reading multiple clusters · 78a52ad5
      Peter Lieven 提交于
      if multiple sectors spanning multiple clusters are read the
      function count_contiguous_clusters should ensure that the
      cluster type should not change between the clusters.
      
      Especially the for-loop should break when we have one
      or more normal clusters followed by a compressed cluster.
      
      Unfortunately the wrong macro was used in the mask to
      compare the flags.
      
      This was discovered while debugging a data corruption
      issue when converting a compressed qcow2 image to raw.
      qemu-img reads 2MB chunks which span multiple clusters.
      
      CC: qemu-stable@nongnu.org
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      78a52ad5
  24. 06 11月, 2013 1 次提交
  25. 11 10月, 2013 1 次提交
  26. 07 10月, 2013 1 次提交
  27. 02 10月, 2013 1 次提交
  28. 27 9月, 2013 4 次提交