qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 80f5c0: qcow2: Forbid discard in qcow2 v2 ima


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 80f5c0: qcow2: Forbid discard in qcow2 v2 images with back...
Date: Tue, 07 Apr 2020 11:15:13 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 80f5c01183597b075157eb7bedbcb8691f8fa1d1
      
https://github.com/qemu/qemu/commit/80f5c01183597b075157eb7bedbcb8691f8fa1d1
  Author: Alberto Garcia <address@hidden>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M block/qcow2.c
    M tests/qemu-iotests/046
    M tests/qemu-iotests/046.out
    M tests/qemu-iotests/060
    M tests/qemu-iotests/060.out
    M tests/qemu-iotests/177
    A tests/qemu-iotests/290
    A tests/qemu-iotests/290.out
    M tests/qemu-iotests/group

  Log Message:
  -----------
  qcow2: Forbid discard in qcow2 v2 images with backing files

A discard request deallocates the selected clusters so they read back
as zeroes. This is done by clearing the cluster offset field and
setting QCOW_OFLAG_ZERO in the L2 entry.

This flag is however only supported when qcow_version >= 3. In older
images the cluster is simply deallocated, exposing any possible stale
data from the backing file.

Since discard is an advisory operation it's safer to simply forbid it
in this scenario.

Note that we are adding this check to qcow2_co_pdiscard() and not to
qcow2_cluster_discard() or discard_in_l2_slice() because the last
two are also used by qcow2_snapshot_create() to discard the clusters
used by the VM state. In this case there's no risk of exposing stale
data to the guest and we really want that the clusters are always
discarded.

Signed-off-by: Alberto Garcia <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>


  Commit: 39f77cb662c6a7c4c398ee568ebc0ebcd710d0c4
      
https://github.com/qemu/qemu/commit/39f77cb662c6a7c4c398ee568ebc0ebcd710d0c4
  Author: Eric Blake <address@hidden>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M qemu-img.c
    M tests/qemu-iotests/244.out

  Log Message:
  -----------
  qemu-img: Report convert errors by bytes, not sectors

Various qemu-img commands are inconsistent on whether they report
status/errors in terms of bytes or sector offsets.  The latter is
confusing (especially as more places move to 4k block sizes), so let's
switch everything to just use bytes everywhere.  One iotest is
impacted.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Max Reitz <address@hidden>


  Commit: fb43d2d46e0daa491d7d80683dd11bb7b2f5899e
      
https://github.com/qemu/qemu/commit/fb43d2d46e0daa491d7d80683dd11bb7b2f5899e
  Author: Alberto Garcia <address@hidden>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M block/qcow2.c

  Log Message:
  -----------
  qcow2: Check request size in qcow2_co_pwritev_compressed_part()

When issuing a compressed write request the number of bytes must be a
multiple of the cluster size or reach the end of the last cluster.

With the current code such requests are allowed and we hit an
assertion:

   $ qemu-img create -f qcow2 img.qcow2 1M
   $ qemu-io -c 'write -c 0 32k' img.qcow2

   qemu-io: block/qcow2.c:4257: qcow2_co_pwritev_compressed_task:
   Assertion `bytes == s->cluster_size || (bytes < s->cluster_size &&
              (offset + bytes == bs->total_sectors << BDRV_SECTOR_BITS))' 
failed.
   Aborted

This patch fixes a regression introduced in 0d483dce38

Signed-off-by: Alberto Garcia <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Andrey Shinkevich <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Signed-off-by: Max Reitz <address@hidden>


  Commit: 25fb2e9c39db85ef41cf242872944145563df571
      
https://github.com/qemu/qemu/commit/25fb2e9c39db85ef41cf242872944145563df571
  Author: Max Reitz <address@hidden>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M tests/qemu-iotests/common.pattern

  Log Message:
  -----------
  iotests/common.pattern: Quote echos

>From time to time, my shell decides to repace the bracketed numbers here
by the numbers inside (i.e., "=== Clusters to be compressed [1]" is
printed as "=== Clusters to be compressed 1").  That makes tests that
use common.pattern fail.  Prevent that from happening by quoting the
arguments to all echos in common.pattern.

Signed-off-by: Max Reitz <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>


  Commit: 36d883ba0de8a281072ded2b51e0a711fd002139
      
https://github.com/qemu/qemu/commit/36d883ba0de8a281072ded2b51e0a711fd002139
  Author: Anthony PERARD <address@hidden>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M hw/block/dataplane/xen-block.c

  Log Message:
  -----------
  xen-block: Fix double qlist remove and request leak

Commit a31ca6801c02 ("qemu/queue.h: clear linked list pointers on
remove") revealed that a request was removed twice from a list, once
in xen_block_finish_request() and a second time in
xen_block_release_request() when both function are called from
xen_block_complete_aio(). But also, the `requests_inflight' counter is
decreased twice, and thus became negative.

This is a bug that was introduced in bfd0d6366043 ("xen-block: improve
response latency"), where a `finished' list was removed.

That commit also introduced a leak of request in xen_block_do_aio().
That function calls xen_block_finish_request() but the request is
never released after that.

To fix both issue, we do two changes:
- we squash finish_request() and release_request() together as we want
  to remove a request from 'inflight' list to add it to 'freelist'.
- before releasing a request, we need to let the other end know the
  result, thus we should call xen_block_send_response() before
  releasing a request.

The first change fixes the double QLIST_REMOVE() as we remove the extra
call. The second change makes the leak go away because if we want to
call finish_request(), we need to call a function that does all of
finish, send response, and release.

Fixes: bfd0d6366043 ("xen-block: improve response latency")
Signed-off-by: Anthony PERARD <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Paul Durrant <address@hidden>
[mreitz: Amended commit message as per Paul's suggestions]
Signed-off-by: Max Reitz <address@hidden>


  Commit: 339205e7ef370663b329e34fd9e905ca00321aa4
      
https://github.com/qemu/qemu/commit/339205e7ef370663b329e34fd9e905ca00321aa4
  Author: Peter Maydell <address@hidden>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M block/qcow2.c
    M hw/block/dataplane/xen-block.c
    M qemu-img.c
    M tests/qemu-iotests/046
    M tests/qemu-iotests/046.out
    M tests/qemu-iotests/060
    M tests/qemu-iotests/060.out
    M tests/qemu-iotests/177
    M tests/qemu-iotests/244.out
    A tests/qemu-iotests/290
    A tests/qemu-iotests/290.out
    M tests/qemu-iotests/common.pattern
    M tests/qemu-iotests/group

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2020-04-07' 
into staging

Block patches for 5.0-rc2:
- Fix double QLIST_REMOVE() and potential request object leak in
  xen-block
- Prevent a potential assertion failure in qcow2's code for compressed
  clusters by rejecting invalid (unaligned) requests with -EIO
- Prevent discards on qcow2 v2 images from making backing data reappear
- Make qemu-img convert report I/O error locations by byte offsets
  consistently
- Fix for potential I/O test errors (accidental globbing due to missing
  quotes)

# gpg: Signature made Tue 07 Apr 2020 13:30:01 BST
# gpg:                using RSA key 91BEB60A30DB3E8857D11829F407DB0061D5CF40
# gpg:                issuer "address@hidden"
# gpg: Good signature from "Max Reitz <address@hidden>" [full]
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* remotes/maxreitz/tags/pull-block-2020-04-07:
  xen-block: Fix double qlist remove and request leak
  iotests/common.pattern: Quote echos
  qcow2: Check request size in qcow2_co_pwritev_compressed_part()
  qemu-img: Report convert errors by bytes, not sectors
  qcow2: Forbid discard in qcow2 v2 images with backing files

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/3f0fb0737921...339205e7ef37



reply via email to

[Prev in Thread] Current Thread [Next in Thread]