1. 06 9月, 2013 5 次提交
  2. 30 8月, 2013 1 次提交
  3. 23 8月, 2013 1 次提交
  4. 22 8月, 2013 2 次提交
    • M
      block: Produce zeros when protocols reading beyond end of file · 893a8f62
      MORITA Kazutaka 提交于
      While Asias is debugging an issue creating qcow2 images on top of
      non-file protocols.  It boils down to this example using NBD:
      
      $ qemu-io -c 'open -g nbd+unix:///?socket=/tmp/nbd.sock' -c 'read -v 0 512'
      
      Notice the open -g option to set bs->growable.  This means you can
      read/write beyond end of file.  Reading beyond end of file is supposed
      to produce zeroes.
      
      We rely on this behavior in qcow2_create2() during qcow2 image
      creation.  We create a new file and then write the qcow2 header
      structure using bdrv_pwrite().  Since QCowHeader is not a multiple of
      sector size, block.c first uses bdrv_read() on the empty file to fetch
      the first sector (should be all zeroes).
      
      Here is the output from the qemu-io NBD example above:
      
      $ qemu-io -c 'open -g nbd+unix:///?socket=/tmp/nbd.sock' -c 'read -v 0 512'
      00000000:  ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab  ................
      00000010:  ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab  ................
      00000020:  ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab  ................
      ...
      
      We are not zeroing the buffer!  As a result qcow2 image creation on top
      of protocols is not guaranteed to work even when file creation is
      supported by the protocol.
      
      [Adapted this patch to use bs->zero_beyond_eof.
      -- Stefan]
      Signed-off-by: NMORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
      Signed-off-by: NAsias He <asias@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      893a8f62
    • A
      block: Introduce bs->zero_beyond_eof · 0d51b4de
      Asias He 提交于
      In 4146b46c42e0989cb5842e04d88ab6ccb1713a48 (block: Produce zeros when
      protocols reading beyond end of file), we break qemu-iotests ./check
      -qcow2 022. This happens because qcow2 temporarily sets ->growable = 1
      for vmstate accesses (which are stored beyond the end of regular image
      data).
      
      We introduce the bs->zero_beyond_eof to allow qcow2_load_vmstate() to
      disable ->zero_beyond_eof temporarily in addition to enable ->growable.
      
      [Since the broken patch "block: Produce zeros when protocols reading
      beyond end of file" has not been merged yet, I have applied this fix
      *first* and will then apply the next patch to keep the tree bisectable.
      -- Stefan]
      Suggested-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NAsias He <asias@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      0d51b4de
  5. 19 8月, 2013 2 次提交
    • S
      block: stop relying on io_flush() in bdrv_drain_all() · 88266f5a
      Stefan Hajnoczi 提交于
      If a block driver has no file descriptors to monitor but there are still
      active requests, it can return 1 from .io_flush().  This is used to spin
      during synchronous I/O.
      
      Stop relying on .io_flush() and instead check
      QLIST_EMPTY(&bs->tracked_requests) to decide whether there are active
      requests.
      
      This is the first step in removing .io_flush() so that event loops no
      longer need to have the concept of synchronous I/O.  Eventually we may
      be able to kill synchronous I/O completely by running everything in a
      coroutine, but that is future work.
      
      Note this patch moves bs->throttled_reqs initialization to bdrv_new() so
      that bdrv_requests_pending(bs) can safely access it.  In practice bs is
      g_malloc0() so the memory is already zeroed but it's safer to initialize
      the queue properly.
      
      We also need to fix up block/stream.c:close_unused_images() to prevent
      traversing a dangling pointer while it rearranges the backing file
      chain.  This is necessary since the new bdrv_drain_all() traverses the
      backing file chain.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      88266f5a
    • S
      block: ensure bdrv_drain_all() works during bdrv_delete() · e1b5c52e
      Stefan Hajnoczi 提交于
      In bdrv_delete() make sure to call bdrv_make_anon() *after* bdrv_close()
      so that the device is still seen by bdrv_drain_all() when iterating
      bdrv_states.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      e1b5c52e
  6. 29 7月, 2013 1 次提交
  7. 27 7月, 2013 1 次提交
  8. 19 7月, 2013 2 次提交
  9. 15 7月, 2013 2 次提交
  10. 05 7月, 2013 1 次提交
  11. 28 6月, 2013 2 次提交
    • 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
    • S
      block: add bdrv_add_before_write_notifier() · d616b224
      Stefan Hajnoczi 提交于
      The bdrv_add_before_write_notifier() function installs a callback that
      is invoked before a write request is processed.  This will be used to
      implement copy-on-write point-in-time snapshots where we need to copy
      out old data before overwriting it.
      
      Note that BdrvTrackedRequest is moved to block_int.h since it is passed
      to .notify() functions.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d616b224
  12. 24 6月, 2013 1 次提交
    • K
      block: Always enable discard on the protocol level · 50b05b6f
      Kevin Wolf 提交于
      Turning on discard options in qcow2 doesn't help a lot when the discard
      requests that it issues are thrown away by the raw-posix layer. This
      patch always enables discard functionality on the protocol level so that
      it's the image format's responsibility to send (or not) discard
      requests. Requests sent by the guest will be allowed or ignored by the
      top level BlockDriverState, which depends on the discard=... option like
      before.
      
      In particular, this means that even without specifying options, the
      qcow2 default of discarding deleted snapshots actually takes effect now,
      both for qemu and qemu-img.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      50b05b6f
  13. 17 6月, 2013 1 次提交
  14. 06 6月, 2013 1 次提交
  15. 04 6月, 2013 4 次提交
    • W
      block: move qmp and info dump related code to block/qapi.c · f364ec65
      Wenchao Xia 提交于
      This patch is a pure code move patch, except following modification:
      1 get_human_readable_size() is changed to static function.
      2 dump_human_image_info() is renamed to bdrv_image_info_dump().
      3 in qmp_query_block() and qmp_query_blockstats, use bdrv_next(bs)
      instead of direct traverse of global array 'bdrv_states'.
      4 collect_snapshots() and collect_image_info() are renamed, unused parameter
      *fmt in collect_image_info() is removed.
      5 code style fix.
      
      To avoid conflict and tip better, macro in header file is BLOCK_QAPI_H
      instead of QAPI_H. Now block.h and snapshot.h are at the same level in
      include path, block_int.h and qapi.h will both include them.
      Signed-off-by: NWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f364ec65
    • W
      block: move snapshot code in block.c to block/snapshot.c · de08c606
      Wenchao Xia 提交于
      All snapshot related code, except bdrv_snapshot_dump() and
      bdrv_is_snapshot(), is moved to block/snapshot.c. bdrv_snapshot_dump()
      will be moved to another file later. bdrv_is_snapshot() is not related
      with internal snapshot. It also fixes small code style errors reported
      by check script.
      Signed-off-by: NWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      de08c606
    • S
      block: drop bs_snapshots global variable · 29d78271
      Stefan Hajnoczi 提交于
      The bs_snapshots global variable points to the BlockDriverState which
      will be used to save vmstate.  This is really a savevm.c concept but was
      moved into block.c:bdrv_snapshots() when it became clear that hotplug
      could result in a dangling pointer.
      
      While auditing the block layer's global state I came upon bs_snapshots
      and realized that a variable is not necessary here.  Simply find the
      first BlockDriverState capable of internal snapshots each time this is
      needed.
      
      The behavior of bdrv_snapshots() is preserved across hotplug because new
      drives are always appended to the bdrv_states list.  This means that
      calling the new find_vmstate_bs() function is idempotent - it returns
      the same BlockDriverState unless it was hot-unplugged.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: NWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      29d78271
    • F
      block: add block driver read only whitelist · b64ec4e4
      Fam Zheng 提交于
      We may want to include a driver in the whitelist for read only tasks
      such as diagnosing or exporting guest data (with libguestfs as a good
      example). This patch introduces a readonly whitelist option, and for
      backward compatibility, the old configure option --block-drv-whitelist
      is now an alias to rw whitelist.
      
      Drivers in readonly list is only permitted to open file readonly, and
      returns -ENOTSUP for RW opening.
      
      E.g. To include vmdk readonly, and others read+write:
          ./configure --target-list=x86_64-softmmu \
                      --block-drv-rw-whitelist=qcow2,raw,file,qed \
                      --block-drv-ro-whitelist=vmdk
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b64ec4e4
  16. 14 5月, 2013 1 次提交
  17. 23 4月, 2013 1 次提交
  18. 22 4月, 2013 5 次提交
  19. 15 4月, 2013 2 次提交
  20. 06 4月, 2013 4 次提交