Unified Xen DomU configuration file
Tags: domu, Fedora, Linux, tutorials, Virtualization, xen
Previously, we create a configuration file for each DomU virtual machines in our cluster. Most of the content in these configuration files is the same. The differences are only the name, memory size and image file address. There are several disadvantages of this method: We must create and configure a new configuration file when creating a new virtual machines; We must change every configuration files when we want to change the parameters of the virtual machines such as change the raw image file driver from loopback to tap.
So we change to using a unified Xen DomU configuration file. We creating DomUs, just use this unified Xen DomU configuration file and add some parameters to it.
Assumption
For VM with id vmid:
Name is: vmvmid
Raw image file address is: /lhome/xen/vmvmid/vmdiskvmid
The parameter for vmid is vmid. The parameter for memory size is vmmem. We force the memory size of the virtual machines to be at least 1G. We assume the virtual cpu number is 2 for all virtual machines. If the cpu number should be different from virtual machines, we can also add a parameter for it.
The configuration file vm.run
This is the unified configuration file /lhome/xen/vm.run:
# Called automatically by 'xm create'.
# Checks that 'vmid' has been given a valid value.
def vmid_check(var, val):
val = int(val)
if val <= 0:
raise ValueError
return val
# Checks that 'vmmem' has been given a valid value
# Make sure the vmmem is >= 1024
def vmmem_check(var, val):
val = int(val)
if val <= 1024:
return 1024
return val
# Define the 'vmid' variable so that 'xm create' knows about it.
xm_vars.var('vmid',
use="Virtual machine id. Integer greater than 0.",
check=vmid_check)
# Define the 'vmmem' variable
xm_vars.var('vmmem',
use="Virtual machine memory. Integer greater thatn 1024.",
check=vmmem_check)
# Check the defined variables have valid values..
xm_vars.check()
# --------------------------------------------------------------
name="vm%d" % vmid
memory="%d" % vmmem
disk=["tap:aio:/lhome/xen/vm%d/vmdisk%d,xvda,w" % (vmid,vmid) ]
vif=['bridge=eth0']
bootloader="/usr/bin/pygrub"
vcpus=2
on_reboot='restart'
on_crash='restart'
The meaning should be easy to understand with these comments.
How to use it
When we want to create vmvmid with vmmem kb memory, just follow these steps:
# cd /lhome/xen # xm create vm.run vmid=vmid vmmem=vmmem
Read more:
- Automatically backing up Xen File-backed DomU
- Setting up Stable Xen DomU with Fedora: Unmodified Fedora 11 with pv_ops Kernel
- Setting up Stable Xen DomU with Fedora: Unmodified Fedora 12 on top of Xenified Fedora 12 Dom0 with Xen 4.0
- An I/O performance comparison between loopback backed and blktap backed Xen file-backed VBD
- How to Duplicate Xen DomU Virtual Machines
- A simple CPU and memory performance test of xen Dom0 and DomU
















[...] name can also be derived from vmid. Some more details and the configuration file can be found from unified-xen-domu-configuration-file. The set up process of Xen platform can be found from [...]