diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2013-04-15 17:17:33 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-04-22 10:27:58 +0200 |
commit | 54f106d5fd51fcf385bab2ddf125477e83758038 (patch) | |
tree | e76e619f264a1dbf6b636aa56def8814f6604380 /qemu-img.c | |
parent | 16b3c5cd9f27678bc9d6707664640653b47533b9 (diff) | |
download | hqemu-54f106d5fd51fcf385bab2ddf125477e83758038.zip hqemu-54f106d5fd51fcf385bab2ddf125477e83758038.tar.gz |
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: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -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)); |