6.2.2. Generate Libvirt LXC domains
I’ve attempted to simply this tutorial by creating a script to auto generate the libvirt-lxc xml domain definitions.
Download the script to whatever directory you want the containers to live in. In this example I am using the /root/lxc/ directory.
# mkdir /root/lxc/
# cd /root/lxc/
# wget https://raw.github.com/davidvossel/pcmk-lxc-autogen/master/lxc-autogen
# chmod 755 lxc-autogen
Now execute the script.
# ./lxc-autogen
After executing the script you will see a bunch of directories and xml files are generated. Those xml files are the libvirt-lxc domain definitions, and the directories are used as some special mount points for each container. If you open up one of the xml files you’ll be able to see how the cpu, memory, and filesystem resources for the container are defined. You can use the libvirt-lxc driver’s documentation found here,
http://libvirt.org/drvlxc.html, as a reference to help understand all the parts of the xml file. The lxc-autogen script is not complicated and is worth exploring in order to grasp how the environment is generated.
It is worth noting that this environment is dependent on use of libvirt’s default network interface. Verify the commands below look the same as your environment. The default network address 192.168.122.1 should have been generated by automatically when you installed the virtualization software.
# virsh net-list
Name State Autostart Persistent
________________________________________________________
default active yes yes
# virsh net-dumpxml default | grep -e "ip address="
<ip address='192.168.122.1' netmask='255.255.255.0'>