提交 54f106d5 编写于 作者: S Stefan Hajnoczi 提交者: Kevin Wolf

qemu-img: do not zero-pad the compressed write buffer

bdrv_write_compressed() does not allow requests that span the end of the
device.  Therefore it is useless to zero-pad the last cluster and
thereby exceed the end of the device.

Let image formats handle zero-padding the final compressed cluster, if
necessary.
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 16b3c5cd
......@@ -1425,12 +1425,8 @@ static int img_convert(int argc, char **argv)
}
assert (remainder == 0);
if (n < cluster_sectors) {
memset(buf + n * 512, 0, cluster_size - n * 512);
}
if (!buffer_is_zero(buf, cluster_size)) {
ret = bdrv_write_compressed(out_bs, sector_num, buf,
cluster_sectors);
if (!buffer_is_zero(buf, n * BDRV_SECTOR_SIZE)) {
ret = bdrv_write_compressed(out_bs, sector_num, buf, n);
if (ret != 0) {
error_report("error while compressing sector %" PRId64
": %s", sector_num, strerror(-ret));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册