Pull request

-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAl5BIR4ACgkQnKSrs4Gr
 c8gC9ggAk4npQQyMIgrV8FM3oJfs7sv6hAuyhcnMw4xqNDGw1zTelwSY4Vif9IRu
 0dU3xNZKR1LvWqmu5ciShTp8VQ9wtTtGJzI3T90+pweYwa3C3i1go7DXyxAd4EUm
 B0HqD3pb9b7X/wwEC1bi8MlGsJCpWqeLHBWXB4C2Gt1Erjo8I3UHKZBWDQTSfwgz
 aWBvuxp+H2eIqr6aUyHziF2htGminrmQm8m9oIzx6NXghvfLzo4CPr8m0vOZiWdn
 096Y08ZLbCT3IQBfvQDKHRHqPdKGB0MzCdUyN8q+WtApq+dA/HBFGyI2X845iGPf
 XY6qMf/TTRHenV7oBwgU8uMzEI4eMw==
 =8xC9
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

Pull request

# gpg: Signature made Mon 10 Feb 2020 09:23:42 GMT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/block-pull-request:
  hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host
  block: fix crash on zero-length unaligned write and read

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
master
Peter Maydell 2020-02-10 17:08:51 +00:00
commit 81a23caf47
2 changed files with 29 additions and 2 deletions

View File

@ -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.

View File

@ -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" },