Message ID | 1382600811-20043-17-git-send-email-pl@kamp.de |
---|---|
State | New |
Headers | show |
Il 24/10/2013 08:46, Peter Lieven ha scritto:
> This currently is designed especially for iscsi.
I'm not sure this is the way you want to spin this. :)
Perhaps "This currently works only for iscsi". It can be extended to
raw with BLKDISCARDZEROES for example.
Paolo
On 24.10.2013 11:13, Paolo Bonzini wrote: > Il 24/10/2013 08:46, Peter Lieven ha scritto: >> This currently is designed especially for iscsi. > I'm not sure this is the way you want to spin this. :) > > Perhaps "This currently works only for iscsi". It can be extended to > raw with BLKDISCARDZEROES for example. Thanks for your comments. Will respin. Peter
diff --git a/qemu-img.c b/qemu-img.c index c6eff15..fe0bdb1 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1353,7 +1353,7 @@ static int img_convert(int argc, char **argv) } } - flags = BDRV_O_RDWR; + flags = min_sparse ? (BDRV_O_RDWR | BDRV_O_UNMAP) : BDRV_O_RDWR; ret = bdrv_parse_cache_flags(cache, &flags); if (ret < 0) { error_report("Invalid cache option: %s", cache); @@ -1469,6 +1469,14 @@ static int img_convert(int argc, char **argv) } else { int has_zero_init = min_sparse ? bdrv_has_zero_init(out_bs) : 0; + if (!has_zero_init && bdrv_can_write_zeroes_with_unmap(out_bs)) { + ret = bdrv_make_zero(out_bs, BDRV_REQ_MAY_UNMAP); + if (ret < 0) { + goto out; + } + has_zero_init = 1; + } + sector_num = 0; // total number of sectors converted so far nb_sectors = total_sectors - sector_num; if (nb_sectors != 0) {