Score:0

KVM / libvirt disk consolidation

de flag
m85

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'/>
ThunderBird avatar
ru flag
Please, try to format your post properly.
Score:0
de flag
m85

Workaround:

DOMAIN_NAME="test"
## save xml and remove domain
#
virsh dumpxml ${DOMAIN_NAME} > ${DOMAIN_NAME}.xml
virsh undefine ${DOMAIN_NAME}
virsh shutdown ${DOMAIN_NAME}
 
## redefine domain and start again
#
virsh define ${DOMAIN_NAME}.xml
virsh start ${DOMAIN_NAME}

A ticket was created on the libvirt project: https://gitlab.com/libvirt/libvirt/-/issues/240

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.