Home » Virtualization

Unified Xen DomU configuration file

By: Zhiqiang Ma On: Jan 29, 2010 Views: 154 Comment: 1 Print Email
Tags: , , , , ,

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:

Digg del.icio.us Stumble Techorati Facebook Newsvine Reddit Twitter
Mixx LinkedIn Google Bookmark Yahoo Bookmark MySpace LiveJournal Blogger RSS feed

One Comment »

  • Automatically backing up Xen File-backed DomU | Pkill.info said:

    [...] 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 [...]

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.