0

I'm using libvirt's virsh vol-create command to create multiple volumes. I've started using Jinja2 templates to help with automating the task for a specific application. In my case, it would help simplify things for me if I could use the looping feature of Jinja2 to create multiple "<volume>" sections in a single XML file. However, generally speaking, XML requires a single top-level tag to be defined (not multiple of the same) and besides this virsh vol-create gives me an error anyway:

$ virsh vol-create default volumes.xml 
error: Failed to create vol from volumes.xml
error: (storage_volume_definition):16: Extra content at the end of the document
<volume>
^

(file contents are here)

Is it possible to put multiple "<volume>" definitions in the same XML file?

0

This is not possible. One solution I created was to create my own "root tag" called <volumeCollection> and have my own XML scanner find all of the <volume> tags and call virsh vol-create for each of them found. It's a wrapper solution, but accomplished what I needed.

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.