1. 16 6月, 2016 2 次提交
  2. 08 6月, 2016 1 次提交
  3. 07 6月, 2016 1 次提交
  4. 19 5月, 2016 1 次提交
  5. 23 3月, 2016 1 次提交
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  6. 20 1月, 2016 1 次提交
  7. 18 12月, 2015 1 次提交
  8. 11 11月, 2015 1 次提交
    • K
      qcow2: Fix qcow2_get_cluster_offset() for zero clusters · a99dfb45
      Kevin Wolf 提交于
      When searching for contiguous zero clusters, we only need to check the
      cluster type. Before this patch, an increasing offset (L2E_OFFSET_MASK)
      was expected, so that the function never returned more than a single
      zero cluster in practice. This patch fixes it to actually return as many
      contiguous zero clusters as it can.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Message-id: 1446657384-5907-1-git-send-email-kwolf@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      a99dfb45
  9. 16 10月, 2015 2 次提交
  10. 14 9月, 2015 2 次提交
  11. 11 9月, 2015 1 次提交
  12. 08 7月, 2015 1 次提交
  13. 22 5月, 2015 3 次提交
  14. 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
  15. 24 1月, 2015 1 次提交
  16. 10 12月, 2014 1 次提交
  17. 03 11月, 2014 3 次提交
  18. 23 10月, 2014 1 次提交
  19. 22 9月, 2014 1 次提交
  20. 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
  21. 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
  22. 28 5月, 2014 1 次提交
  23. 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
  24. 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
  25. 04 4月, 2014 1 次提交
  26. 01 4月, 2014 2 次提交
  27. 13 3月, 2014 1 次提交
  28. 22 2月, 2014 1 次提交
  29. 09 2月, 2014 1 次提交