On 13.09.18 05:33, lampahome wrote: > I split data to 3 chunks and save it in 3 independent backing files like > below: > img.000 <-- img.001 <-- img.002 > img.000 is the backing file of img.001 and 001 is the backing file of 002. > img.000 saves the 1st chunk of data and img.001 saves the 2nd chunk of > data, and img.002 saves the 3rd chunk of data. > > Now I have img.003 stores cow data of 1st chunk and img.002 is the backing > file of img.003. > The backing chain is like this: > img.000 <-- img.001 <-- img.002 <-- img.003 > > So that means the data of img.003 saves the same range with img.000 but > different data. > > I know I can use *`qemu-img commit'* but it only commit the data from > img.003 to img.002. > > If I use *`qemu-img rebase -b img.000 img.003`*, the data of img.001 and > img.002 will merge into img.003. > > What I want is only commit the data in img.003 into img.000 because the > data of the two image are the same range(1st chunk) > > Is there anyway to commit(or merge) data of active image into corresponding > backing file?
So img.000, img.001, and img.002 all contain data at completely different areas, and img.003 only contains data where img.000 contains data as well? Say like so: $ qemu-img create -f qcow2 img.000 3M $ qemu-img create -f qcow2 -b img.000 img.001 $ qemu-img create -f qcow2 -b img.001 img.002 $ qemu-img create -f qcow2 -b img.002 img.003 $ qemu-io -c 'write -P 1 0M 1M' img.000 $ qemu-io -c 'write -P 2 1M 1M' img.001 $ qemu-io -c 'write -P 3 2M 1M' img.002 $ qemu-io -c 'write -P 4 0M 1M' img.003 (img.000 contains 1s from 0M to 1M; img.001 contains 2s from 1M to 2M; img.002 contains 3s from 2M to 3M; img.003 contains 4s from 0M to 1M (the range of img.000)) In that case, rebase -u might be what you want, so the following should work (although it can easily corrupt your data if it isn't the case[1]): $ qemu-img rebase -u -b img.000 img.003 $ qemu-img commit img.003 (And then maybe $ qemu-img rebase -u -b img.002 img.003 to return to the previous backing chain.) Max [1] It will corrupt your data if img.001 or img.002 contain any data where img.003 also contains data; because then that data of img.003 will be hidden when viewed through img.001 and img.002.
signature.asc
Description: OpenPGP digital signature