On Thu, Jun 27, 2013 at 08:30:04PM +0800, Wenchao Xia wrote: > 于 2013-6-27 17:01, Stefan Hajnoczi 写道: > >On Tue, Jun 25, 2013 at 07:14:19PM +0800, Wenchao Xia wrote: > >>于 2013-6-25 17:13, Stefan Hajnoczi 写道: > >>>On Thu, Jun 20, 2013 at 04:59:17PM +0800, Wenchao Xia wrote: > >BTW we already have qemu-io -c map which prints out allocation > >information for an image file. If that command is extended to support > >-s then you can get your info easily. > Do you mean use it like: > 1 call qemu-io file -c map -s sn0 > 2 call qemu-io file -c map -s sn1 > 3 for (offset = 0; offset < len; offset +=512) { > if (allocated on sn0) { > call qemu-io file read -s sn0, into buf0 > } > if (allocated on sn1) { > call qemu-io file read -s sn1, into buf1 > } > if strcmp(buf0, buf1) { > write down the delta > } > } > ? > I think it is workable and flex, the bottle neck is the string > parsing of qemu-io. For delta data info retrieving purpose, qemu-img > approach would faster.
It's also possible to put Step 3 into qemu-img so that this feature is fast and easy to use with a single command. Stefan