1. 10 7月, 2017 1 次提交
    • E
      block: Guarantee that *file is set on bdrv_get_block_status() · 81c219ac
      Eric Blake 提交于
      We document that *file is valid if the return is not an error and
      includes BDRV_BLOCK_OFFSET_VALID, but forgot to obey this contract
      when a driver (such as blkdebug) lacks a callback.  Messed up in
      commit 67a0fd2a (v2.6), when we added the file parameter.
      
      Enhance qemu-iotest 177 to cover this, using a sequence that would
      print garbage or even SEGV, because it was dererefencing through
      uninitialized memory.  [The resulting test output shows that we
      have less-than-ideal block status from the blkdebug driver, but
      that's a separate fix coming up soon.]
      
      Setting *file on all paths that return BDRV_BLOCK_OFFSET_VALID is
      enough to fix the crash, but we can go one step further: always
      setting *file, even on error, means that a broken caller that
      blindly dereferences file without checking for error is now more
      likely to get a reliable SEGV instead of randomly acting on garbage,
      making it easier to diagnose such buggy callers.  Adding an
      assertion that file is set where expected doesn't hurt either.
      
      CC: qemu-stable@nongnu.org
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      81c219ac
  2. 11 5月, 2017 1 次提交
    • E
      tests: Add coverage for recent block geometry fixes · 40812d93
      Eric Blake 提交于
      Use blkdebug's new geometry constraints to emulate setups that
      have needed past regression fixes: write zeroes asserting
      when running through a loopback block device with max-transfer
      smaller than cluster size, and discard rounding away portions
      of requests not aligned to preferred boundaries.  Also, add
      coverage that the block layer is honoring max transfer limits.
      
      For now, a single iotest performs all actions, with the idea
      that we can add future blkdebug constraint test cases in the
      same file; but it can be split into multiple iotests if we find
      reason to run one portion of the test in more setups than what
      are possible in the other.
      
      For reference, the final portion of the test (checking whether
      discard passes as much as possible to the lowest layers of the
      stack) works as follows:
      
      qemu-io: discard 30M at 80000001, passed to blkdebug
        blkdebug: discard 511 bytes at 80000001, -ENOTSUP (smaller than
      blkdebug's 512 align)
        blkdebug: discard 14371328 bytes at 80000512, passed to qcow2
          qcow2: discard 739840 bytes at 80000512, -ENOTSUP (smaller than
      qcow2's 1M align)
          qcow2: discard 13M bytes at 77M, succeeds
        blkdebug: discard 15M bytes at 90M, passed to qcow2
          qcow2: discard 15M bytes at 90M, succeeds
        blkdebug: discard 1356800 bytes at 105M, passed to qcow2
          qcow2: discard 1M at 105M, succeeds
          qcow2: discard 308224 bytes at 106M, -ENOTSUP (smaller than qcow2's
      1M align)
        blkdebug: discard 1 byte at 111457280, -ENOTSUP (smaller than
      blkdebug's 512 align)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20170429191419.30051-10-eblake@redhat.com
      [mreitz: For cooperation with image locking, add -r to the qemu-io
               invocation which verifies the image content]
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      40812d93