using ubuntu 20.04 as kvm host, initializing a guest using cloud-init. this gives me a working guest, with an image chain as a result. to simplify the backup process and re-use an existing script, I would like to consolidate the image chain to a single file.
https://libvirt.org/kbase/merging_disk_image_chains.html#consolidating-an-entire-disk-image-chain-into-a-single-image
initial config
virsh domblklist test
Target Source
-----------------------------
vda test-rootfs.qcow2
hdd -
consolidate images
virsh blockcommit test vda --verbose --pivot --active
Block commit: [100 %]
Successfully pivoted
result
virsh domblklist test
Target Source
------------------------------------------
vda /data/libvirt/disk-images/test
hdd -
This is the expected result. Whenever I shutdown the VM and start again, the image config changes to:
virsh domblklist test
Target Source
-----------------------------
vda test-rootfs.qcow2
hdd -
and the consolidated image is not used any more, instead it is using the original image chain again ... -> My Question: Why?
BR and thx for hints
//edit:
I have disabled cloud-init in the guest, then the shudtown / start procedure.
Here is the diff, comparing after block commit and after shutdown / start the domain (using virsh dumpxml).
$ diff 0_blockcommit 1_shutdown_start
1c1
< <domain type='kvm' id='8'>
---
> <domain type='kvm' id='9'>
32c32
< <disk type='file' device='disk'>
---
> <disk type='volume' device='disk'>
34,35c34,39
< <source file='/data/libvirt/pools/disk-images/test.qcow2' index='3'/>
< <backingStore/>
---
> <source pool='disk-images' volume='test-rootfs.qcow2' index='2'/>
> <backingStore type='file' index='3'>
> <format type='qcow2'/>
> <source file='/data/libvirt/pools/disk-images/test.qcow2'/>
> <backingStore/>
> </backingStore>
42c46,47
< <source index='4'/>
---
> <source file='/data/libvirt/pools/disk-images/test.iso' index='1'/>
> <backingStore/>
89c94
< <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-8-test/org.qemu.guest_agent.0'/>
---
> <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-9-test/org.qemu.guest_agent.0'/>