1. 06 12月, 2013 1 次提交
    • S
      block: clean up bdrv_drain_all() throttling comments · 0b06ef3b
      Stefan Hajnoczi 提交于
      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: NAlex Bligh <alex@alex.org.uk>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      0b06ef3b
  2. 04 12月, 2013 1 次提交
    • M
      block: Close backing file early in bdrv_img_create · 66f6b814
      Max Reitz 提交于
      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: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      66f6b814
  3. 03 12月, 2013 6 次提交
  4. 30 11月, 2013 1 次提交
  5. 29 11月, 2013 4 次提交
    • K
      block: Enable BDRV_O_SNAPSHOT with driver-specific options · 9fd3171a
      Kevin Wolf 提交于
      In the case of snapshot=on, don't rely on the backing file path in the
      temporary image any more, but override the backing file with the given
      set of options. This way, block drivers that don't use a file name can
      be accessed with snapshot=on, for example:
      
          -drive file.driver=nbd,file.host=localhost,snapshot=on
      
      Which becomes internally something like:
      
          file.filename=/tmp/vl.AWQZCu,backing.file.driver=nbd,backing.file.host=localhost
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      9fd3171a
    • F
      blkdebug: add "remove_break" command · 4cc70e93
      Fam Zheng 提交于
      This adds "remove_break" command which is the reverse of blkdebug
      command "break": it removes all breakpoints with given tag and resumes
      all the requests.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      4cc70e93
    • F
      qapi: Change BlockDirtyInfo to list · 21b56835
      Fam Zheng 提交于
      We have multiple dirty bitmaps in BDS now, switch QAPI to allow query
      it (BlockInfo.dirty_bitmaps), and also drop old BlockInfo.dirty.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      21b56835
    • F
      block: per caller dirty bitmap · e4654d2d
      Fam Zheng 提交于
      Previously a BlockDriverState has only one dirty bitmap, so only one
      caller (e.g. a block job) can keep track of writing. This changes the
      dirty bitmap to a list and creates a BdrvDirtyBitmap for each caller, the
      lifecycle is managed with these new functions:
      
          bdrv_create_dirty_bitmap
          bdrv_release_dirty_bitmap
      
      Where BdrvDirtyBitmap is a linked list wrapper structure of HBitmap.
      
      In place of bdrv_set_dirty_tracking, a BdrvDirtyBitmap pointer argument
      is added to these functions, since each caller has its own dirty bitmap:
      
          bdrv_get_dirty
          bdrv_dirty_iter_init
          bdrv_get_dirty_count
      
      bdrv_set_dirty and bdrv_reset_dirty prototypes are unchanged but will
      internally walk the list of all dirty bitmaps and set them one by one.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e4654d2d
  6. 28 11月, 2013 8 次提交
  7. 15 11月, 2013 1 次提交
  8. 14 11月, 2013 1 次提交
    • F
      block: Print its file name if backing file opening failed · b04b6b6e
      Fam Zheng 提交于
      If backing file doesn't exist, the error message is confusing and
      misleading:
      
          $ qemu /tmp/a.qcow2
          qemu: could not open disk image /tmp/a.qcow2: Could not open file: No
          such file or directory
      
      But...
      
          $ ls /tmp/a.qcow2
          /tmp/a.qcow2
      
          $ qemu-img info /tmp/a.qcow2
          image: /tmp/a.qcow2
          file format: qcow2
          virtual size: 8.0G (8589934592 bytes)
          disk size: 196K
          cluster_size: 65536
          backing file: /tmp/b.qcow2
      
      Because...
      
          $ ls /tmp/b.qcow2
          ls: cannot access /tmp/b.qcow2: No such file or directory
      
      This is not intuitive. It's better to have the missing file's name in
      the error message. With this patch:
      
          $ qemu-io -c 'read 0 512' /tmp/a.qcow2
          qemu-io: can't open device /tmp/a.qcow2: Could not open backing
          file: Could not open '/stor/vm/arch.raw': No such file or directory
          no file open, try 'help open'
      
      Which is a little bit better.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b04b6b6e
  9. 08 11月, 2013 1 次提交
  10. 07 11月, 2013 1 次提交
  11. 29 10月, 2013 3 次提交
    • K
      block: Avoid unecessary drv->bdrv_getlength() calls · b94a2610
      Kevin Wolf 提交于
      The block layer generally keeps the size of an image cached in
      bs->total_sectors so that it doesn't have to perform expensive
      operations to get the size whenever it needs it.
      
      This doesn't work however when using a backend that can change its size
      without qemu being aware of it, i.e. passthrough of removable media like
      CD-ROMs or floppy disks. For this reason, the caching is disabled when a
      removable device is used.
      
      It is obvious that checking whether the _guest_ device has removable
      media isn't the right thing to do when we want to know whether the size
      of the host backend can change. To make things worse, non-top-level
      BlockDriverStates never have any device attached, which makes qemu
      assume they are removable, so drv->bdrv_getlength() is always called on
      the protocol layer. In the case of raw-posix, this causes unnecessary
      lseek() system calls, which turned out to be rather expensive.
      
      This patch completely changes the logic and disables bs->total_sectors
      caching only for certain block driver types, for which a size change is
      expected: host_cdrom and host_floppy on POSIX, host_device on win32; also
      the raw format in case it sits on top of one of these protocols, but in
      the common case the nested bdrv_getlength() call on the protocol driver
      will use the cache again and avoid an expensive drv->bdrv_getlength()
      call.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      b94a2610
    • T
      block: Disable BDRV_O_COPY_ON_READ for the backing file · 87a5debd
      Thibaut LAURENT 提交于
      Since commit 0ebd24e0,
      bdrv_open_common will throw an error when trying to open a file
      read-only with the BDRV_O_COPY_ON_READ flag set.
      Although BDRV_O_RDWR is unset for the backing files,
      BDRV_O_COPY_ON_READ is still passed on if copy-on-read was requested
      for the drive. Let's unset this flag too before opening the backing
      file, or bdrv_open_common will fail.
      Signed-off-by: NThibaut LAURENT <thibaut.laurent@gmail.com>
      Reviewed-by: NBenoit Canet <benoit@irqsave.net>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      87a5debd
    • M
      block: Don't copy backing file name on error · 61ed2684
      Max Reitz 提交于
      bdrv_open_backing_file() tries to copy the backing file name using
      pstrcpy directly after calling bdrv_open() to open the backing file
      without checking whether that was actually successful. If it was not,
      ps->backing_hd->file will probably be NULL and qemu will crash.
      
      Fix this by moving pstrcpy after checking whether bdrv_open() succeeded.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NBenoit Canet <benoit@irqsave.net>
      Reviewed-by: Amos_沧海桑田's avatarAmos Kong <kongjianjun@gmail.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      61ed2684
  12. 11 10月, 2013 5 次提交
  13. 07 10月, 2013 1 次提交
  14. 02 10月, 2013 1 次提交
  15. 26 9月, 2013 1 次提交
  16. 25 9月, 2013 4 次提交