TL;DR at bottom

I am building a web interface for libvirt as a project. I am using libvirt-php as the language binding to libvirt and everything is working, except for domain creation, sort of.

The issue I am having is with domain creation, wherein I would like to have a domain be created based off of a base domain. I have posted a similar question to this before, where I asked almost the exact same question. I got a helpful response from a moderator who told me to check out how virt-install achieved this.

So I did, I ran virt-install to see how they achieved creating a new domain from a base one, but to my dismay it didn't work as I anticipated, as it just ended up sharing the given storage volume I specified, unless I messed something up.

So I took another approach, where I would create a new storage volume based off of the one I would like to use as the storage for the new domain using the virsh vol-create-from command, or in libvirt-php the libvirt_storagevolume_create_xml_from() function.

This approach worked well, I could create a domain, specify the storage volume I would like to use as the base disk image, and it just worked. However I encountered a new problem whenever I tried creating multiple domains at once.

You see since domain creation is a time consuming process, I decided just to push that job onto a beanstalkd queue, and use supervisord to keep the processes running by spawning workers to manage the new jobs. This is where the new problem arose, as the error logs had the following message: Requested operation is not valid: volume 'ubuntu-14.04.3-x64' is still being allocated.

So it turns out that I have to wait for the volume to be cloned, before cloning it again. This is the issue I am having.

TL;DR: Trying to create domain in libvirt from a base domain, have tried the following things:

  • Tried looking at how virt-install's --import flag worked, didn't yield any useful results. (May have overlooked something though).

  • Tried creating a storage volume from a base storage volume. (This worked, until I tried cloning the storage volume multiple times, whilst other volumes were being created from the base volume I had).

The solution where I would create a new storage volume from the base on seems to be the most convenient, if it would allow for me to create multiple volumes from that base one at the same time.


So my question is this, is it possible to either:

  • Create a domain from a base disk image in libvirt?

  • Clone a volume multiple times without having to wait for the cloning process to finish? (Is there something I am overlooking here with regards to the configuration of libvirt?)

  • Create a new domain from another domain's snapshot in libvirt? (Asking this as this is another possible solution that just crossed my mind whilst writing this question, and Google hasn't yet given any useful answers, a part from how to restore a domain to a previous snapshot.)


I would simply utilise qemu-img for this. If you want to see code, take a look at how vdsm does it.

  • Yeah just took a look at VDSM, looks like that uses qemu-img directly, so I'll give that a shot. Thanks for the reply. – brti Feb 13 '16 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.