1. 20 10月, 2014 1 次提交
  2. 22 9月, 2014 2 次提交
  3. 12 9月, 2014 1 次提交
  4. 20 8月, 2014 2 次提交
    • M
      block: Use g_new() & friends to avoid multiplying sizes · 02c4f26b
      Markus Armbruster 提交于
      g_new(T, n) is safer than g_malloc(sizeof(*v) * n) 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.
      
      Perhaps a conversion to g_malloc_n() would be neater in places, but
      that's merely four years old, and we can't use such newfangled stuff.
      
      This commit only touches allocations with size arguments of the form
      sizeof(T), plus two that use 4 instead of sizeof(uint32_t).  We can
      make the others safe by converting to g_malloc_n() when it becomes
      available to us in a couple of years.
      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>
      02c4f26b
    • 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
  5. 15 8月, 2014 1 次提交
  6. 16 6月, 2014 2 次提交
  7. 06 6月, 2014 1 次提交
  8. 04 6月, 2014 1 次提交
  9. 28 5月, 2014 1 次提交
  10. 18 2月, 2014 1 次提交
  11. 22 1月, 2014 1 次提交
    • S
      rbd: switch from pipe to QEMUBH completion notification · e04fb07f
      Stefan Hajnoczi 提交于
      rbd callbacks are called from non-QEMU threads.  Up until now a pipe was
      used to signal completion back to the QEMU iothread.
      
      The pipe writer code handles EAGAIN using select(2).  The select(2) API
      is not scalable since fd_set size is static.  FD_SET() can write beyond
      the end of fd_set if the file descriptor number is too high.  (QEMU's
      main loop uses poll(2) to avoid this issue with select(2).)
      
      Since the pipe itself is quite clumsy to use and QEMUBH is now
      thread-safe, just schedule a BH from the rbd callback function.  This
      way we can simplify I/O completion in addition to eliminating the
      potential FD_SET() crash when file descriptor numbers become too high.
      
      Crash scenario: QEMU already has 1024 file descriptors open.  Hotplug an
      rbd drive and get the pipe writer to take the select(2) code path.
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      Tested-by: NJosh Durgin <josh.durgin@inktank.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e04fb07f
  12. 07 1月, 2014 1 次提交
  13. 25 9月, 2013 2 次提交
  14. 12 9月, 2013 3 次提交
    • M
      bdrv: Use "Error" for creating images · d5124c00
      Max Reitz 提交于
      Add an Error ** parameter to BlockDriver.bdrv_create to allow more
      specific error messages.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      d5124c00
    • M
      bdrv: Use "Error" for opening images · 015a1036
      Max Reitz 提交于
      Add an Error ** parameter to BlockDriver.bdrv_open and
      BlockDriver.bdrv_file_open to allow more specific error messages.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      015a1036
    • W
      snapshot: distinguish id and name in snapshot delete · a89d89d3
      Wenchao Xia 提交于
      Snapshot creation actually already distinguish id and name since it take
      a structured parameter *sn, but delete can't. Later an accurate delete
      is needed in qmp_transaction abort and blockdev-snapshot-delete-sync,
      so change its prototype. Also *errp is added to tip error, but return
      value is kepted to let caller check what kind of error happens. Existing
      caller for it are savevm, delvm and qemu-img, they are not impacted by
      introducing a new function bdrv_snapshot_delete_by_id_or_name(), which
      check the return value and do the operation again.
      
      Before this patch:
        For qcow2, it search id first then name to find the one to delete.
        For rbd, it search name.
        For sheepdog, it does nothing.
      
      After this patch:
        For qcow2, logic is the same by call it twice in caller.
        For rbd, it always fails in delete with id, but still search for name
      in second try, no change to user.
      
      Some code for *errp is based on Pavel's patch.
      Signed-off-by: NWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a89d89d3
  15. 19 8月, 2013 2 次提交
  16. 28 6月, 2013 1 次提交
    • P
      block: change default of .has_zero_init to 0 · 3ac21627
      Peter Lieven 提交于
      .has_zero_init defaults to 1 for all formats and protocols.
      
      this is a dangerous default since this means that all
      new added drivers need to manually overwrite it to 0 if
      they do not ensure that a device is zero initialized
      after bdrv_create().
      
      if a driver needs to explicitly set this value to
      1 its easier to verify the correctness in the review process.
      
      during review of the existing drivers it turned out
      that ssh and gluster had a wrong default of 1.
      both protocols support host_devices as backend
      which are not by default zero initialized. this
      wrong assumption will lead to possible corruption
      if qemu-img convert is used to write to such a backend.
      
      vpc and vmdk also defaulted to 1 altough they support
      fixed respectively flat extends. this has to be addresses
      in separate patches. both formats as well as the mentioned
      ssh and gluster are turned to the default of 0 with this
      patch for safety.
      
      a similar problem with the wrong default existed for
      iscsi most likely because the driver developer did
      oversee the default value of 1.
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      3ac21627
  17. 26 4月, 2013 1 次提交
  18. 22 4月, 2013 2 次提交
  19. 15 4月, 2013 1 次提交
    • J
      rbd: add an asynchronous flush · dc7588c1
      Josh Durgin 提交于
      The existing bdrv_co_flush_to_disk implementation uses rbd_flush(),
      which is sychronous and causes the main qemu thread to block until it
      is complete. This results in unresponsiveness and extra latency for
      the guest.
      
      Fix this by using an asynchronous version of flush.  This was added to
      librbd with a special #define to indicate its presence, since it will
      be backported to stable versions. Thus, there is no need to check the
      version of librbd.
      
      Implement this as bdrv_aio_flush, since it matches other aio functions
      in the rbd block driver, and leave out bdrv_co_flush_to_disk when the
      asynchronous version is available.
      Reported-by: NOliver Francke <oliver@filoo.de>
      Signed-off-by: NJosh Durgin <josh.durgin@inktank.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      dc7588c1
  20. 25 3月, 2013 1 次提交
  21. 19 12月, 2012 2 次提交
  22. 11 12月, 2012 1 次提交
  23. 21 11月, 2012 1 次提交
  24. 15 11月, 2012 1 次提交
  25. 24 9月, 2012 1 次提交
  26. 15 6月, 2012 1 次提交
  27. 12 6月, 2012 2 次提交
    • 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
      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
  28. 03 5月, 2012 1 次提交
  29. 19 4月, 2012 1 次提交
  30. 26 1月, 2012 1 次提交