1. 07 2月, 2015 3 次提交
  2. 10 12月, 2014 3 次提交
  3. 18 11月, 2014 6 次提交
  4. 03 11月, 2014 2 次提交
    • M
      raw-posix: raw_co_get_block_status() return value · d7f62751
      Max Reitz 提交于
      Instead of generating the full return value thrice in try_fiemap(),
      try_seek_hole() and as a fall-back in raw_co_get_block_status() itself,
      generate the value only in raw_co_get_block_status().
      
      While at it, also remove the pnum parameter from try_fiemap() and
      try_seek_hole().
      Suggested-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Message-id: 1414148280-17949-3-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      d7f62751
    • M
      raw-posix: Fix raw_co_get_block_status() after EOF · e6d7ec32
      Max Reitz 提交于
      As its comment states, raw_co_get_block_status() should unconditionally
      return 0 and set *pnum to 0 for after EOF.
      
      An assertion after lseek(..., SEEK_HOLE) tried to catch this case by
      asserting that errno != -ENXIO (which would indicate a position after
      the EOF); but it should be errno != ENXIO instead. Regardless of that,
      there should be no such assertion at all. If bdrv_getlength() returned
      an outdated value and the image has been resized outside of qemu,
      lseek() will return with errno == ENXIO. Just return that value as an
      error then.
      
      Setting *pnum to 0 and returning 0 should not be done here, as in that
      case we should update the device length as well. So, from qemu's
      perspective, the file has not been resized; it's just that there was an
      error querying sectors beyond a certain point (the actual file size).
      
      Additionally, nb_sectors should be clamped against the image end. This
      was probably not an issue if FIEMAP or SEEK_HOLE/SEEK_DATA worked, but
      the fallback did not take this case into account.
      Reported-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Message-id: 1414148280-17949-2-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      e6d7ec32
  5. 23 10月, 2014 1 次提交
  6. 20 10月, 2014 4 次提交
  7. 29 9月, 2014 1 次提交
  8. 12 9月, 2014 3 次提交
  9. 22 8月, 2014 1 次提交
  10. 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
  11. 15 8月, 2014 1 次提交
  12. 18 7月, 2014 2 次提交
  13. 14 7月, 2014 1 次提交
  14. 07 7月, 2014 2 次提交
  15. 01 7月, 2014 1 次提交
    • C
      qemu-img create: add 'nocow' option · 4ab15590
      Chunyan Liu 提交于
      Add 'nocow' option so that users could have a chance to set NOCOW flag to
      newly created files. It's useful on btrfs file system to enhance performance.
      
      Btrfs has low performance when hosting VM images, even more when the guest
      in those VM are also using btrfs as file system. One way to mitigate this bad
      performance is to turn off COW attributes on VM files. Generally, there are
      two ways to turn off NOCOW on btrfs: a) by mounting fs with nodatacow, then
      all newly created files will be NOCOW. b) per file. Add the NOCOW file
      attribute. It could only be done to empty or new files.
      
      This patch tries the second way, according to the option, it could add NOCOW
      per file.
      
      For most block drivers, since the create file step is in raw-posix.c, so we
      can do setting NOCOW flag ioctl in raw-posix.c only.
      
      But there are some exceptions, like block/vpc.c and block/vdi.c, they are
      creating file by calling qemu_open directly. For them, do the same setting
      NOCOW flag ioctl work in them separately.
      
      [Fixed up 082.out due to the new 'nocow' creation option
      --Stefan]
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      4ab15590
  16. 16 6月, 2014 2 次提交
  17. 04 6月, 2014 3 次提交
  18. 30 5月, 2014 1 次提交
  19. 10 5月, 2014 1 次提交
    • M
      block/raw-posix: Try both FIEMAP and SEEK_HOLE · 4f11aa8a
      Max Reitz 提交于
      The current version of raw-posix always uses ioctl(FS_IOC_FIEMAP) if
      FIEMAP is available; lseek with SEEK_HOLE/SEEK_DATA are not even
      compiled in in this case. However, there may be implementations which
      support the latter but not the former (e.g., NFSv4.2) as well as vice
      versa.
      
      To cover both cases, try FIEMAP first (as this will return -ENOTSUP if
      not supported instead of returning a failsafe value (everything
      allocated as a single extent)) and if that does not work, fall back to
      SEEK_HOLE/SEEK_DATA.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      4f11aa8a
  20. 30 4月, 2014 1 次提交
    • K
      block: Unlink temporary files in raw-posix/win32 · 8bfea15d
      Kevin Wolf 提交于
      Instead of having unlink() calls in the generic block layer, where we
      aren't even guarateed to have a file name, move them to those block
      drivers that are actually used and that always have a filename. Gets us
      rid of some #ifdefs as well.
      
      The patch also converts bs->is_temporary to a new BDRV_O_TEMPORARY open
      flag so that it is inherited in the protocol layer and the raw-posix and
      raw-win32 drivers can unlink the file.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      8bfea15d