libvirt API - overlays, backing image

631 Views Asked by At

Is there a possibility to create 2(or more) different overlays from one base image using libvirt API ?

FedoraBase.img <-- FedoraGuest1.qcow2
                \
                  <-- FedoraGuest2.qcow2

So FedoraBase is backing image for Guest1 and Guest2 overlays...

Using qemu-img tool you can create it like this:

qemu-img create -b /export/vmimages/FedoraBase.img -f qcow2 \ 
       /export/vmimages/FedoraGuest1.qcow2

qemu-img create -b /export/vmimages/FedoraBase.img -f qcow2 \ 
       /export/vmimages/FedoraGuest2.qcow2

But I can not find any libvirt API doing the same.

1

There are 1 best solutions below

1
On

This task requires you to use the libvirt storage pool APIs - in particular qcow2 images can be created using the virStorageVolCreateXML() API. This API accepts an XML document that describes the desired configuration and gives you the ability to specify the backing file. This should let achieve the layering you describe.