1. 04 Jun, 2013 4 commits
    • Wenchao Xia's avatar
      block: move qmp and info dump related code to block/qapi.c · f364ec65
      Wenchao Xia authored
      
      
      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: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      f364ec65
    • Wenchao Xia's avatar
      block: move snapshot code in block.c to block/snapshot.c · de08c606
      Wenchao Xia authored
      
      
      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: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      de08c606
    • Stefan Hajnoczi's avatar
      block: drop bs_snapshots global variable · 29d78271
      Stefan Hajnoczi authored
      
      
      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: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      29d78271
    • Fam Zheng's avatar
      block: add block driver read only whitelist · b64ec4e4
      Fam Zheng authored
      
      
      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: default avatarFam Zheng <famz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      b64ec4e4
  2. 22 Apr, 2013 1 commit
    • Kevin Wolf's avatar
      block: Add driver-specific options for backing files · 31ca6d07
      Kevin Wolf authored
      
      
      Options starting in "backing." are passed to the backing file now. If
      you don't need to specify the filename for the backing file, you can add
      it on the command line instead of in the image file:
      
      $ qemu-nbd -t /tmp/test.img
      $ qemu-img create -f qcow2 empty.qcow2 1G
      $ qemu-system-x86_64 -drive file=empty.qcow2,backing.file.driver=nbd,\
          backing.file.host=localhost
      
      Note that this doesn't override the backing filename from the image. If
      the image has one, this will fail because NBD doesn't want the options
      and a filename at the same time.
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      31ca6d07
  3. 15 Apr, 2013 2 commits
  4. 22 Mar, 2013 1 commit
  5. 15 Mar, 2013 1 commit
  6. 22 Feb, 2013 5 commits
  7. 25 Jan, 2013 3 commits
  8. 14 Jan, 2013 1 commit
  9. 02 Jan, 2013 1 commit
    • Stefan Hajnoczi's avatar
      raw-posix: add raw_get_aio_fd() for virtio-blk-data-plane · 4065742a
      Stefan Hajnoczi authored
      
      
      The raw_get_aio_fd() function allows virtio-blk-data-plane to get the
      file descriptor of a raw image file with Linux AIO enabled.  This
      interface is really a layering violation that can be resolved once the
      block layer is able to run outside the global mutex - at that point
      virtio-blk-data-plane will switch from custom Linux AIO code to using
      the block layer.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      4065742a
  10. 19 Dec, 2012 3 commits
  11. 12 Dec, 2012 1 commit
    • Kevin Wolf's avatar
      qemu-io: Add AIO debugging commands · 41c695c7
      Kevin Wolf authored
      
      
      This makes the blkdebug suspend/resume functionality available in
      qemu-io. Use it like this:
      
        $ ./qemu-io blkdebug::/tmp/test.qcow2
        qemu-io> break write_aio req_a
        qemu-io> aio_write 0 4k
        qemu-io> blkdebug: Suspended request 'req_a'
        qemu-io> resume req_a
        blkdebug: Resuming request 'req_a'
        qemu-io> wrote 4096/4096 bytes at offset 0
        4 KiB, 1 ops; 0:00:30.71 (133.359788 bytes/sec and 0.0326 ops/sec)
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      41c695c7
  12. 11 Dec, 2012 2 commits
  13. 24 Oct, 2012 4 commits
  14. 23 Oct, 2012 1 commit
  15. 28 Sep, 2012 7 commits
  16. 24 Sep, 2012 2 commits
    • Jeff Cody's avatar
      block: Framework for reopening files safely · e971aa12
      Jeff Cody authored
      
      
      This is based on Supriya Kannery's bdrv_reopen() patch series.
      
      This provides a transactional method to reopen multiple
      images files safely.
      
      Image files are queue for reopen via bdrv_reopen_queue(), and the
      reopen occurs when bdrv_reopen_multiple() is called.  Changes are
      staged in bdrv_reopen_prepare() and in the equivalent driver level
      functions.  If any of the staged images fails a prepare, then all
      of the images left untouched, and the staged changes for each image
      abandoned.
      
      Block drivers are passed a reopen state structure, that contains:
          * BDS to reopen
          * flags for the reopen
          * opaque pointer for any driver-specific data that needs to be
            persistent from _prepare to _commit/_abort
          * reopen queue pointer, if the driver needs to queue additional
            BDS for a reopen
      Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      e971aa12
    • Jeff Cody's avatar
      block: correctly set the keep_read_only flag · be028adc
      Jeff Cody authored
      
      
      I believe the bs->keep_read_only flag is supposed to reflect
      the initial open state of the device. If the device is initially
      opened R/O, then commit operations, or reopen operations changing
      to R/W, are prohibited.
      
      Currently, the keep_read_only flag is only accurate for the active
      layer, and its backing file. Subsequent images end up always having
      the keep_read_only flag set.
      
      For instance, what happens now:
      
      [  base  ]  kro = 1, ro = 1
          |
          v
      [ snap-1 ]  kro = 1, ro = 1
          |
          v
      [ snap-2 ]  kro = 0, ro = 1
          |
          v
      [ active ]  kro = 0, ro = 0
      
      What we want:
      
      [  base  ]  kro = 0, ro = 1
          |
          v
      [ snap-1 ]  kro = 0, ro = 1
          |
          v
      [ snap-2 ]  kro = 0, ro = 1
          |
          v
      [ active ]  kro = 0, ro = 0
      Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      be028adc
  17. 10 Aug, 2012 1 commit
    • Stefan Hajnoczi's avatar
      block: add BLOCK_O_CHECK for qemu-img check · 058f8f16
      Stefan Hajnoczi authored
      
      
      Image formats with a dirty bit, like qed and qcow2, repair dirty image
      files upon open with BDRV_O_RDWR.  Performing automatic repair when
      qemu-img check runs is not ideal because the bdrv_open() call repairs
      the image before the actual bdrv_check() call from qemu-img.c.
      
      Fix this "double repair" since it leads to confusing output from
      qemu-img check.  Tell the block driver that this image is being opened
      just for bdrv_check().  This skips automatic repair and qemu-img.c can
      invoke it manually with bdrv_check().
      
      Update the golden output for qemu-iotests 039 to reflect the new
      qemu-img check output.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      058f8f16