qemu-img convert of a backing qcow2 snapshot
Hi,
Let's say we have this chain:
base <--- sn1 <--- sn2 <--- active
Can we shutdown the VM and "qemu-img convert sn2 -O qcow2 sn2_new" and rebase active to sn2_new like this:
sn2_new <--- active
?
Or is it better practice to blockpull? BTW, is blockpull into an non-active snapshot already supported and stable?
I have tested this qemu-img convert approach and it seems to work, but I would like to ask someone more familiar with qcow2 internals and prevent data corruption.
Best regards,
Christopher Pereira
Quoted 4 lines · Christopher Pereira
Hi,
Let's say we have this chain:
Quoted 8 lines
base <--- sn1 <--- sn2 <--- activeCan we shutdown the VM and "qemu-img convert sn2 -O qcow2
sn2_new" and rebase active tosn2_newlike this:sn2_new <--- active?
Yes. As long as the guest-visible data in 'base <- sn1 <- sn2' is identical to the guest-visible data in 'sn2_new', then it doesn't matter which of the two files is used as the backing file for 'active'.
Quoted 3 lines
Or is it better practice to blockpull? BTW, is blockpull into an non-active snapshot already supported and stable?
There are patches proposed for blockpull into sn2, but those have not been committed yet. To pull data into sn2, you currently have to do offline work. However, you CAN commit from sn2 into base, creating the chain 'base+ <- active' (where 'base+' represents the data that used to be visible via 'base <- sn1 <- sn2') while the guest is live.
Quoted 4 lines
I have tested this qemu-img convert approach and it seems to work, but I would like to ask someone more familiar with qcow2 internals and prevent data corruption.
Data corruption is likely to happen if you make external modifications to base, sn1, or sn2 while the guest is running, including 'qemu-img convert' modifications. If the guest is running, only QMP commands are safe. But if the guest is offline, then as long as the guest-visible contents are the same, you can rearrange backing chains however you see fit.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] qemu-img convert of a backing qcow2 snapshot (THANKS)
Quoted 10 lines · Eric Blake
Quoted 9 lines · Christopher Pereira
Hi,
Let's say we have this chain:
base <--- sn1 <--- sn2 <--- activeCan we shutdown the VM and "qemu-img convert sn2 -O qcow2
sn2_new" and rebase active tosn2_newlike this:
Quoted 6 lines
Quoted 3 lines
sn2_new <--- active?
Yes. As long as the guest-visible data in 'base <- sn1 <- sn2' is identical to the guest-visible data in '
sn2_new', then it doesn't matter which of the two files is used as the backing file for 'active'.
Nice! Thanks Eric for confirming and for all your brilliant work.