Revisão | 81a23caf47956778c5a5056ad656d1ef92bf9659 (tree) |
---|---|
Hora | 2020-02-11 02:08:51 |
Autor | Peter Maydell <peter.maydell@lina...> |
Commiter | Peter Maydell |
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:
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
@@ -1565,10 +1565,12 @@ static bool bdrv_init_padding(BlockDriverState *bs, | ||
1565 | 1565 | pad->tail = align - pad->tail; |
1566 | 1566 | } |
1567 | 1567 | |
1568 | - if ((!pad->head && !pad->tail) || !bytes) { | |
1568 | + if (!pad->head && !pad->tail) { | |
1569 | 1569 | return false; |
1570 | 1570 | } |
1571 | 1571 | |
1572 | + assert(bytes); /* Nothing good in aligning zero-length requests */ | |
1573 | + | |
1572 | 1574 | sum = pad->head + bytes + pad->tail; |
1573 | 1575 | pad->buf_len = (sum > align && pad->head && pad->tail) ? 2 * align : align; |
1574 | 1576 | pad->buf = qemu_blockalign(bs, pad->buf_len); |
@@ -1706,6 +1708,18 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, | ||
1706 | 1708 | return ret; |
1707 | 1709 | } |
1708 | 1710 | |
1711 | + if (bytes == 0 && !QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)) { | |
1712 | + /* | |
1713 | + * Aligning zero request is nonsense. Even if driver has special meaning | |
1714 | + * of zero-length (like qcow2_co_pwritev_compressed_part), we can't pass | |
1715 | + * it to driver due to request_alignment. | |
1716 | + * | |
1717 | + * Still, no reason to return an error if someone do unaligned | |
1718 | + * zero-length read occasionally. | |
1719 | + */ | |
1720 | + return 0; | |
1721 | + } | |
1722 | + | |
1709 | 1723 | bdrv_inc_in_flight(bs); |
1710 | 1724 | |
1711 | 1725 | /* 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, | ||
2116 | 2130 | return -ENOTSUP; |
2117 | 2131 | } |
2118 | 2132 | |
2133 | + if (bytes == 0 && !QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)) { | |
2134 | + /* | |
2135 | + * Aligning zero request is nonsense. Even if driver has special meaning | |
2136 | + * of zero-length (like qcow2_co_pwritev_compressed_part), we can't pass | |
2137 | + * it to driver due to request_alignment. | |
2138 | + * | |
2139 | + * Still, no reason to return an error if someone do unaligned | |
2140 | + * zero-length write occasionally. | |
2141 | + */ | |
2142 | + return 0; | |
2143 | + } | |
2144 | + | |
2119 | 2145 | bdrv_inc_in_flight(bs); |
2120 | 2146 | /* |
2121 | 2147 | * Align write if necessary by performing a read-modify-write cycle. |
@@ -148,7 +148,8 @@ GlobalProperty hw_compat_2_5[] = { | ||
148 | 148 | const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5); |
149 | 149 | |
150 | 150 | GlobalProperty hw_compat_2_4[] = { |
151 | - { "virtio-blk-device", "scsi", "true" }, | |
151 | + /* Optional because the 'scsi' property is Linux-only */ | |
152 | + { "virtio-blk-device", "scsi", "true", .optional = true }, | |
152 | 153 | { "e1000", "extra_mac_registers", "off" }, |
153 | 154 | { "virtio-pci", "x-disable-pcie", "on" }, |
154 | 155 | { "virtio-pci", "migrate-extra", "off" }, |