"Richard W.M. Jones" <rjo...@redhat.com> writes: > [Applies against qemu 1.1.0, not HEAD, because qemu from git seems to > be broken at the moment. But the patch is easy to rebase.]
How's it broken? Regards, Anthony Liguori > This patch adds a -drive detect_zero=on|off flag (defaults to "off"). > > Setting this on causes the write path to detect all zero byte writes > and, for block device drivers which support this, turn the request > into the more space-efficient bdrv_co_do_write_zeroes call. > > The use case is for virt-sparsify. We want to create an intermediate > qcow2 overlay file which we know will mostly contain zeroes, and we > want qcow2 to handle this without creating a huge empty file. In my > testing, the size of the intermediate file is reduced considerably > (down to about 1/4 of the original size), making sparsification of > large mostly-empty guests possible for the first time. > > The implementation is very simple-minded. It tests if the entire > request is all zero bytes or not. A better implementation would > almost certainly be even more space-efficient, but at the cost of > splitting some write requests (if that's a problem). > > Testing: I booted and tested an F16 guest with this patch and the > setting "on", without problems. I also modified libguestfs to add > this flag, then ran the whole libguestfs test suite with no reported > problems. > > Rich.