Xen Configuration Syntax


Version 0.2
2004 July 19

Xen Configuration

The Xen virtual machine creation tools provide command-line interfaces and HTTP interfaces to creating virtual machines. Underneath all these interfaces virtual machine configuration data is represented in a common configuration syntax called SXP. The SXP syntax is s-expressions (sxprs), a simple bracketed abstract syntax. Python lists are used to represent its parsed form, with a support api providing access to fields and values (class xen.xend.sxp).

SXP syntax

A general s-expression has the syntax:

s-exp = '(' s-exp* ')' | atom | string
Where an atom is an unquoted string, such as fred or /domain/0. A string is a quoted string, supporting the usual escape sequences. Strings support single or double quotes: 'fred 1' or "fred 2" are both accepted. The characters ()[]<>{} are separators.

An element is an s-expression representing data similar to XML. It has the form:

element    = '(' name attributes? value* ')'
name       = atom
attributes = '(' '@' attribute* ')'
attribute  = '(' attrname attrval ')'
attrname   = atom
attrval    = atom | string
value      = element | atom | string
The name is the element name (roughly indentifying its type). The attributes is a list of attribute-values. We usually prefer to avoid using attributes, and use sub-elements instead. As in XML, any element may have the attribute id to give it an identifier for later reference.

VM configuration

A vm configuration is a single SXP vm element, with subelements for vm parameters and devices. The supported elements and their fields are listed below.

(vm) element

The top-level element, a virtual machine configuration.

(image (linux)) element

Defines a linux kernel image and its command-line parameters.

(image (netbsd)) element

Defines a netbsd kernel image and its command-line parameters.

(backend (blkif)) element

The vm is a block device backend. The vm can have pci devices configured.

(backend (netif)) element

The vm is a net device backend.

(device (vif)) element

Defines a virtual network interface.

(device (vbd)) element

Defines a virtual block device. The uname field defines the device being exported from the block device controller. The dev field defines the device name the vm will see. The device is read-only unless the mode contains w.

(device (pci)) element

Defines a pci device. The bus, dev or func may be given in hex, e.g. 0xff. With no leading 0x they are interpreted as decimal.

Examples

A vm with 64 MB memory, root on /dev/xda1 (mapped from /dev/hda1), one vif with default MAC.

(vm
    (name xendom1)
    (memory 64)
    (image
        (linux
            (kernel /boot/vmlinuz-2.6.12-xen)
            (ip ::::xendom1:eth0:dhcp)
            (root /dev/xda1)
            (args 'rw fastboot 4')
        )
    )
    (device (vif))
    (device (vbd (uname phy:hda1) (dev xda1) (mode w)))
)