0

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.

patszn
  • 11
  • 1
  • 3

1 Answers1

0

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.

DanielB
  • 2,461
  • 1
  • 10
  • 13
  • could you provide a more detailed example? it's kind of hard to parse the libvirt documentation... – anarcat Oct 26 '18 at 18:38