1. 16 10月, 2019 24 次提交
  2. 15 10月, 2019 6 次提交
  3. 14 10月, 2019 10 次提交
    • M
      iotests: Test large write request to qcow2 file · a1406a92
      Max Reitz 提交于
      Without HEAD^, the following happens when you attempt a large write
      request to a qcow2 file such that the number of bytes covered by all
      clusters involved in a single allocation will exceed INT_MAX:
      
      (A) handle_alloc_space() decides to fill the whole area with zeroes and
          fails because bdrv_co_pwrite_zeroes() fails (the request is too
          large).
      
      (B) If handle_alloc_space() does not do anything, but merge_cow()
          decides that the requests can be merged, it will create a too long
          IOV that later cannot be written.
      
      (C) Otherwise, all parts will be written separately, so those requests
          will work.
      
      In either B or C, though, qcow2_alloc_cluster_link_l2() will have an
      overflow: We use an int (i) to iterate over nb_clusters, and then
      calculate the L2 entry based on "i << s->cluster_bits" -- which will
      overflow if the range covers more than INT_MAX bytes.  This then leads
      to image corruption because the L2 entry will be wrong (it will be
      recognized as a compressed cluster).
      
      Even if that were not the case, the .cow_end area would be empty
      (because handle_alloc() will cap avail_bytes and nb_bytes at INT_MAX, so
      their difference (which is the .cow_end size) will be 0).
      
      So this test checks that on such large requests, the image will not be
      corrupted.  Unfortunately, we cannot check whether COW will be handled
      correctly, because that data is discarded when it is written to null-co
      (but we have to use null-co, because writing 2 GB of data in a test is
      not quite reasonable).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a1406a92
    • M
      qcow2: Limit total allocation range to INT_MAX · d1b9d19f
      Max Reitz 提交于
      When the COW areas are included, the size of an allocation can exceed
      INT_MAX.  This is kind of limited by handle_alloc() in that it already
      caps avail_bytes at INT_MAX, but the number of clusters still reflects
      the original length.
      
      This can have all sorts of effects, ranging from the storage layer write
      call failing to image corruption.  (If there were no image corruption,
      then I suppose there would be data loss because the .cow_end area is
      forced to be empty, even though there might be something we need to
      COW.)
      
      Fix all of it by limiting nb_clusters so the equivalent number of bytes
      will not exceed INT_MAX.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d1b9d19f
    • K
      qemu-nbd: Support help options for --object · 495bf893
      Kevin Wolf 提交于
      Instead of parsing help options as normal object properties and
      returning an error, provide the same help functionality as the system
      emulator in qemu-nbd, too.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      495bf893
    • K
      qemu-img: Support help options for --object · c6e5cdfd
      Kevin Wolf 提交于
      Instead of parsing help options as normal object properties and
      returning an error, provide the same help functionality as the system
      emulator in qemu-img, too.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      c6e5cdfd
    • K
      qemu-io: Support help options for --object · 4fa1f0dc
      Kevin Wolf 提交于
      Instead of parsing help options as normal object properties and
      returning an error, provide the same help functionality as the system
      emulator in qemu-io, too.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      4fa1f0dc
    • K
      vl: Split off user_creatable_print_help() · 3e9297f3
      Kevin Wolf 提交于
      Printing help for --object is something that we not only want in the
      system emulator, but also in tools that support --object. Move it into a
      separate function in qom/object_interfaces.c to make the code accessible
      for tools.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      3e9297f3
    • M
      iotests/028: Fix for long $TEST_DIRs · 48c8d3ce
      Max Reitz 提交于
      For long test image paths, the order of the "Formatting" line and the
      "(qemu)" prompt after a drive_backup HMP command may be reversed.  In
      fact, the interaction between the prompt and the line may lead to the
      "Formatting" to being greppable at all after "read"-ing it (if the
      prompt injects an IFS character into the "Formatting" string).
      
      So just wait until we get a prompt.  At that point, the block job must
      have been started, so "info block-jobs" will only return "No active
      jobs" once it is done.
      Reported-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      48c8d3ce
    • A
      block: Reject misaligned write requests with BDRV_REQ_NO_FALLBACK · f2208fdc
      Alberto Garcia 提交于
      The BDRV_REQ_NO_FALLBACK flag means that an operation should only be
      performed if it can be offloaded or otherwise performed efficiently.
      
      However a misaligned write request requires a RMW so we should return
      an error and let the caller decide how to proceed.
      
      This hits an assertion since commit c8bb23cb if the required
      alignment is larger than the cluster size:
      
      qemu-img create -f qcow2 -o cluster_size=2k img.qcow2 4G
      qemu-io -c "open -o driver=qcow2,file.align=4k blkdebug::img.qcow2" \
              -c 'write 0 512'
      qemu-io: block/io.c:1127: bdrv_driver_pwritev: Assertion `!(flags & BDRV_REQ_NO_FALLBACK)' failed.
      Aborted
      
      The reason is that when writing to an unallocated cluster we try to
      skip the copy-on-write part and zeroize it using BDRV_REQ_NO_FALLBACK
      instead, resulting in a write request that is too small (2KB cluster
      size vs 4KB required alignment).
      Signed-off-by: NAlberto Garcia <berto@igalia.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f2208fdc
    • P
      replay: add BH oneshot event for block layer · e4ec5ad4
      Pavel Dovgalyuk 提交于
      Replay is capable of recording normal BH events, but sometimes
      there are single use callbacks scheduled with aio_bh_schedule_oneshot
      function. This patch enables recording and replaying such callbacks.
      Block layer uses these events for calling the completion function.
      Replaying these calls makes the execution deterministic.
      Signed-off-by: NPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
      Acked-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e4ec5ad4
    • P
      replay: finish record/replay before closing the disks · ae25dccb
      Pavel Dovgalyuk 提交于
      After recent updates block devices cannot be closed on qemu exit.
      This happens due to the block request polling when replay is not finished.
      Therefore now we stop execution recording before closing the block devices.
      Signed-off-by: NPavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      ae25dccb