1. 24 Jan, 2014 24 commits
  2. 22 Jan, 2014 7 commits
    • Peter Feiner's avatar
      block: fix backing file segfault · d80ac658
      Peter Feiner authored
      When a backing file is opened such that (1) a protocol is directly
      used as the block driver and (2) the block driver has bdrv_file_open,
      bdrv_open_backing_file segfaults. The problem arises because
      bdrv_open_common returns without setting bd->backing_hd->file.
      
      To effect (1), you seem to have to use the -F flag in qemu-img. There
      are several block drivers that satisfy (2), such as "file" and "nbd".
      Here are some concrete examples:
      
          #!/bin/bash
      
          echo Test file format
          ./qemu-img create -f file base.file 1m
          ./qemu-img create -f qcow2 -F file -o backing_file=base.file\
              file-overlay.qcow2
          ./qemu-img convert -O raw file-overlay.qcow2 file-convert.raw
      
          echo Test nbd format
          SOCK=$PWD/nbd.sock
          ./qemu-img create -f raw base.raw 1m
          ./qemu-nbd -t -k $SOCK base.raw &
          trap "kill $!" EXIT
          while ! test -e $SOCK; do sleep 1; done
          ./qemu-img create -f qcow2 -F nbd -o backing_file=nbd:unix:$SOCK\
              nbd-overlay.qcow2
          ./qemu-img convert -O raw nbd-overlay.qcow2 nbd-convert.raw
      
      Without this patch, the two qemu-img convert commands segfault.
      
      This is a regression that was introduced in v1.7 by
      dbecebdd.
      Signed-off-by: default avatarPeter Feiner <peter@gridcentric.ca>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      d80ac658
    • Max Reitz's avatar
      block: Allow recursive "file"s · 505d7583
      Max Reitz authored
      It should be possible to use a format as a driver for a file which in
      turn requires another file, i.e., nesting file formats.
      
      Allowing nested file formats results in e.g. qcow2 BlockDriverStates
      never being directly passed to bdrv_open_common() from bdrv_file_open(),
      but instead being handed through bdrv_open(). This changes the error
      message when trying to give a filename to qcow2, i.e. trying to use it
      as a driver for the protocol level. Therefore, change the reference
      output of I/O test 051 accordingly.
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      505d7583
    • Max Reitz's avatar
      block: Use bdrv_open_image() in bdrv_open() · 054963f8
      Max Reitz authored
      Using bdrv_open_image() instead of bdrv_file_open() directly in
      bdrv_open() is easier.
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      054963f8
    • Max Reitz's avatar
      block: Add bdrv_open_image() · da557aac
      Max Reitz authored
      Add a common function for opening images to be used for block drivers
      specified through BlockdevRefs in an option QDict. The difference from
      bdrv_file_open() is that this function may invoke bdrv_open() instead,
      allowing auto-detection of the driver to be used; and second, it
      automatically extracts the BlockdevRef from the option QDict.
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      da557aac
    • Max Reitz's avatar
      block: Allow block devices without files · 2a05cbe4
      Max Reitz authored
      blkdebug and blkverify will, in order to retain compatibility, not
      support the field "file" implicitly through bdrv_open(). In order to be
      able to use those drivers without giving a filename anyway, it is
      necessary to be able to have block devices without files implicitly
      opened by bdrv_open(). This is the case, if there was neither a file
      name, a reference to an existing block device to use as a file nor
      options specific to the file.
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      2a05cbe4
    • Max Reitz's avatar
      block: Pass reference to bdrv_file_open() · 2258e3fe
      Max Reitz authored
      With that now being possible, bdrv_open() should try to extract a block
      device reference from the options and pass it to bdrv_file_open().
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      2258e3fe
    • Max Reitz's avatar
      block: Allow reference for bdrv_file_open() · 72daa72e
      Max Reitz authored
      Allow specifying a reference to an existing block device (by name) for
      bdrv_file_open() instead of a filename and/or options.
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      72daa72e
  3. 13 Dec, 2013 1 commit
  4. 06 Dec, 2013 1 commit
    • Stefan Hajnoczi's avatar
      block: clean up bdrv_drain_all() throttling comments · 0b06ef3b
      Stefan Hajnoczi authored
      Since cc0681c4 ("block: Enable the new
      throttling code in the block layer.") bdrv_drain_all() no longer spins.
      The code used to look as follows:
      
        do {
            busy = qemu_aio_wait();
      
            /* FIXME: We do not have timer support here, so this is effectively
             * a busy wait.
             */
            QTAILQ_FOREACH(bs, &bdrv_states, list) {
                while (qemu_co_enter_next(&bs->throttled_reqs)) {
                    busy = true;
                }
            }
        } while (busy);
      
      Note that throttle requests are kicked but I/O throttling limits are
      still in effect.  The loop spins until the vm_clock time allows the
      request to make progress and complete.
      
      The new throttling code introduced bdrv_start_throttled_reqs().  This
      function not only kicks throttled requests but also temporarily disables
      throttling so requests can run.
      
      The outdated FIXME comment can be removed.  Also drop the busy = true
      assignment since we overwrite it immediately afterwards.
      Reviewed-by: default avatarAlex Bligh <alex@alex.org.uk>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      0b06ef3b
  5. 04 Dec, 2013 1 commit
    • Max Reitz's avatar
      block: Close backing file early in bdrv_img_create · 66f6b814
      Max Reitz authored
      Leaving the backing file open although it is not needed anymore can
      cause problems if it is opened through a block driver which allows
      exclusive access only and if the create function of the block driver
      used for the top image (the one being created) tries to close and reopen
      the image file (which will include opening the backing file a second
      time).
      
      In particular, this will happen with a backing file opened through
      qemu-nbd and using qcow2 as the top image file format (which reopens the
      image to flush it to disk).
      
      In addition, the BlockDriverState in bdrv_img_create() is used for the
      backing file only; it should therefore be made local to the respective
      block.
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      66f6b814
  6. 03 Dec, 2013 6 commits