qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/2] Block patches
@ 2020-02-10  9:23 Stefan Hajnoczi
  2020-02-10  9:23 ` [PULL 1/2] block: fix crash on zero-length unaligned write and read Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2020-02-10  9:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, Stefan Hajnoczi, qemu-block, Max Reitz,
	Fam Zheng, Eduardo Habkost

The following changes since commit 346ed3151f1c43e72c40cb55b392a1d4cface62c:

  Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20200206.0' into staging (2020-02-07 11:52:15 +0000)

are available in the Git repository at:

  https://github.com/stefanha/qemu.git tags/block-pull-request

for you to fetch changes up to 11a18c84db4a71497d3d40769688a01b6f64b2ad:

  hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host (2020-02-07 16:49:39 +0000)

----------------------------------------------------------------
Pull request

----------------------------------------------------------------

Philippe Mathieu-Daudé (1):
  hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host

Vladimir Sementsov-Ogievskiy (1):
  block: fix crash on zero-length unaligned write and read

 block/io.c        | 28 +++++++++++++++++++++++++++-
 hw/core/machine.c |  3 ++-
 2 files changed, 29 insertions(+), 2 deletions(-)

-- 
2.24.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PULL 1/2] block: fix crash on zero-length unaligned write and read
  2020-02-10  9:23 [PULL 0/2] Block patches Stefan Hajnoczi
@ 2020-02-10  9:23 ` Stefan Hajnoczi
  2020-02-10  9:23 ` [PULL 2/2] hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host Stefan Hajnoczi
  2020-02-10 18:09 ` [PULL 0/2] Block patches Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2020-02-10  9:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, Vladimir Sementsov-Ogievskiy,
	Stefan Hajnoczi, qemu-block, qemu-stable, Max Reitz, Fam Zheng,
	Eduardo Habkost

From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Commit 7a3f542fbd "block/io: refactor padding" occasionally dropped
aligning for zero-length request: bdrv_init_padding() blindly return
false if bytes == 0, like there is nothing to align.

This leads the following command to crash:

./qemu-io --image-opts -c 'write 1 0' \
  driver=blkdebug,align=512,image.driver=null-co,image.size=512

>> qemu-io: block/io.c:1955: bdrv_aligned_pwritev: Assertion
    `(offset & (align - 1)) == 0' failed.
>> Aborted (core dumped)

Prior to 7a3f542fbd we does aligning of such zero requests. Instead of
recovering this behavior let's just do nothing on such requests as it
is useless.

Note that driver may have special meaning of zero-length reqeusts, like
qcow2_co_pwritev_compressed_part, so we can't skip any zero-length
operation. But for unaligned ones, we can't pass it to driver anyway.

This commit also fixes crash in iotest 80 running with -nocache:

./check -nocache -qcow2 80

which crashes on same assertion due to trying to read empty extra data
in qcow2_do_read_snapshots().

Cc: qemu-stable@nongnu.org # v4.2
Fixes: 7a3f542fbd
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 20200206164245.17781-1-vsementsov@virtuozzo.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/io.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/block/io.c b/block/io.c
index 1eb2b2bddc..7e4cb74cf4 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1565,10 +1565,12 @@ static bool bdrv_init_padding(BlockDriverState *bs,
         pad->tail = align - pad->tail;
     }
 
-    if ((!pad->head && !pad->tail) || !bytes) {
+    if (!pad->head && !pad->tail) {
         return false;
     }
 
+    assert(bytes); /* Nothing good in aligning zero-length requests */
+
     sum = pad->head + bytes + pad->tail;
     pad->buf_len = (sum > align && pad->head && pad->tail) ? 2 * align : align;
     pad->buf = qemu_blockalign(bs, pad->buf_len);
@@ -1706,6 +1708,18 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child,
         return ret;
     }
 
+    if (bytes == 0 && !QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)) {
+        /*
+         * Aligning zero request is nonsense. Even if driver has special meaning
+         * of zero-length (like qcow2_co_pwritev_compressed_part), we can't pass
+         * it to driver due to request_alignment.
+         *
+         * Still, no reason to return an error if someone do unaligned
+         * zero-length read occasionally.
+         */
+        return 0;
+    }
+
     bdrv_inc_in_flight(bs);
 
     /* Don't do copy-on-read if we read data before write operation */
@@ -2116,6 +2130,18 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child,
         return -ENOTSUP;
     }
 
+    if (bytes == 0 && !QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)) {
+        /*
+         * Aligning zero request is nonsense. Even if driver has special meaning
+         * of zero-length (like qcow2_co_pwritev_compressed_part), we can't pass
+         * it to driver due to request_alignment.
+         *
+         * Still, no reason to return an error if someone do unaligned
+         * zero-length write occasionally.
+         */
+        return 0;
+    }
+
     bdrv_inc_in_flight(bs);
     /*
      * Align write if necessary by performing a read-modify-write cycle.
-- 
2.24.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PULL 2/2] hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host
  2020-02-10  9:23 [PULL 0/2] Block patches Stefan Hajnoczi
  2020-02-10  9:23 ` [PULL 1/2] block: fix crash on zero-length unaligned write and read Stefan Hajnoczi
@ 2020-02-10  9:23 ` Stefan Hajnoczi
  2020-02-10 18:09 ` [PULL 0/2] Block patches Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2020-02-10  9:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, Stefan Hajnoczi, qemu-block,
	Michael S . Tsirkin, Cornelia Huck, Max Reitz, Fam Zheng,
	Philippe Mathieu-Daudé, Eduardo Habkost

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Commit ed65fd1a2750 ("virtio-blk: switch off scsi-passthrough by
default") changed the default value of the 'scsi' property of
virtio-blk, which is only available on Linux hosts. It also added
an unconditional compat entry for 2.4 or earlier machines.

Trying to set this property on a pre-2.5 machine on OSX, we get:

   Unexpected error in object_property_find() at qom/object.c:1201:
   qemu-system-x86_64: -device virtio-blk-pci,id=scsi0,drive=drive0: can't apply global virtio-blk-device.scsi=true: Property '.scsi' not found

Fix this error by marking the property optional.

Fixes: ed65fd1a27 ("virtio-blk: switch off scsi-passthrough by default")
Suggested-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-id: 20200207001404.1739-1-philmd@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/core/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 3e288bfceb..d8e30e4895 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -148,7 +148,8 @@ GlobalProperty hw_compat_2_5[] = {
 const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5);
 
 GlobalProperty hw_compat_2_4[] = {
-    { "virtio-blk-device", "scsi", "true" },
+    /* Optional because the 'scsi' property is Linux-only */
+    { "virtio-blk-device", "scsi", "true", .optional = true },
     { "e1000", "extra_mac_registers", "off" },
     { "virtio-pci", "x-disable-pcie", "on" },
     { "virtio-pci", "migrate-extra", "off" },
-- 
2.24.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PULL 0/2] Block patches
  2020-02-10  9:23 [PULL 0/2] Block patches Stefan Hajnoczi
  2020-02-10  9:23 ` [PULL 1/2] block: fix crash on zero-length unaligned write and read Stefan Hajnoczi
  2020-02-10  9:23 ` [PULL 2/2] hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host Stefan Hajnoczi
@ 2020-02-10 18:09 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2020-02-10 18:09 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Kevin Wolf, Fam Zheng, Eduardo Habkost, Qemu-block,
	QEMU Developers, Max Reitz

On Mon, 10 Feb 2020 at 09:23, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> The following changes since commit 346ed3151f1c43e72c40cb55b392a1d4cface62c:
>
>   Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20200206.0' into staging (2020-02-07 11:52:15 +0000)
>
> are available in the Git repository at:
>
>   https://github.com/stefanha/qemu.git tags/block-pull-request
>
> for you to fetch changes up to 11a18c84db4a71497d3d40769688a01b6f64b2ad:
>
>   hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host (2020-02-07 16:49:39 +0000)
>
> ----------------------------------------------------------------
> Pull request
>
> ----------------------------------------------------------------
>
> Philippe Mathieu-Daudé (1):
>   hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host
>
> Vladimir Sementsov-Ogievskiy (1):
>   block: fix crash on zero-length unaligned write and read


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-10 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-10  9:23 [PULL 0/2] Block patches Stefan Hajnoczi
2020-02-10  9:23 ` [PULL 1/2] block: fix crash on zero-length unaligned write and read Stefan Hajnoczi
2020-02-10  9:23 ` [PULL 2/2] hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host Stefan Hajnoczi
2020-02-10 18:09 ` [PULL 0/2] Block patches Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).