On 08/12/2014 08:57 PM, Eric Blake wrote:
On 08/12/2014 05:59 PM, Tom Horsley wrote:
> Just curious here. Say I have a qcow2 image named outer.qcow2
> and it has a raw format backing_file named inner.img.
>
> If I do something like
>
> qemu-img convert -f raw -O qcow2 inner.img new-inner.img
> rm -f inner.img
> mv new-inner.img inner.img
>
> (in other words convert the backing file from raw to
> qcow2)
>
> What are the odds that outer.qcow2 will still be usable?
If you stop there, 0%. The outer file is still trying to open the inner
file as raw, which sees completely different data than if it opened the
inner file as qcow2.
But if you follow that up with:
qemu-img rebase -u -b inner.img -F qcow2 -f qcow2 outer.qcow2
then it is 100% safe. That is, as long as you rewrite the outer file to
track the new format of the inner file, then the guest-visible data is
identical.
Oh, and there's a caveat. This must be done while no guest is actively
using the image. If any guest is actively using outer.qcow2, then
you've almost guaranteed total corruption of your guest.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org