virt-image
Format of the virtual image XML descriptor
- Provided by: virtinst (Version: 0.600.4-3ubuntu2)
- Report a bug
Format of the virtual image XML descriptor
virt-image(1) relies on an XML descriptor to create virtual machines from virtual machine images. In general, a virtual machine image consists of the XML descriptor (usually in a file image.xml) and a number of files for the virtual machine's disks.
In the following explanation of the structure of the image descriptor, mandatory XML elements are marked as element, whereas optional elements are marked as element.
All file names in the image descriptor are relative to the location of the descriptor itself. Generally, disk files are either kept in the same directory as the image descriptor, or in a subdirectory.
The image descriptor contains information on the requirements a guest has on the host platform through one or more the /image/domain/boot descriptors (see section "BOOT"). The image can only be used if at least one of the boot descriptors is suitable for the host platform; a boot descriptor is suitable if:
If a suitable boot descriptor is found, the guest is created and booted according to the information about booting the OS from the boot/os element and with the disks specified in the boot/drive element. If more than one suitable boot descriptor is found, one of them is chosen based on a heuristic, generally preferring paravirtualized guests over full virtualized ones, though this is an implementation detail of the tool creating the virtual machine.
The image descriptor consists of three sections, all contained in the toplevel image element:
The domain element contains one or more boot descriptors (see section "BOOT") and a devices element. The Devices element lists the recommended number of virtual CPU's in the vcpu element and the recommended amount of memory in kB in the memory element. It also indicates whether the virtual machine should have a network interface through the interface element and whether the virtual machine has a graphical interface through the graphics element.
Each boot descriptor details how the virtual machine should be started on a certain hypervisor. The type attribute of the boot element, which can either be "xen" or "hvm", depending on whether the boot descriptor is for a paravirtualized Xen(tm) guest or a fully-virtualized guest.
The boot element contains three subelements:
The features element indicates whether certain platform features should be on or off. Currently, the platform features are pae, acpi, and apic. They can be turned on or off by giving a state attribute of either "on" or "off". When a feature is mentioned in the features element, it defaults to "on".
For paravirtualized guests, the os element either contains a "<loader>pygrub</loader>" element, indicating that the guest should be booted with pygrub, or kernel, initrd and cmdline elements. The contents of the kernel and initrd elements are the names of the kernel and initrd files, whereas the cmdline element contains the command line that should be passed to the kernel on boot.
The storage element lists the disk image files that are part of the virtual machine image in a list of one or more disk elements. Each disk element can contain the following attributes:
Generally, "system" disks contain application code, "user" disks contain the application's data, and "scratch" disks contain temporary state that can be erased between runs of the guest.
The virtual machine image must contain files for all "system" disks, and may contain files for the "user" and "scratch" disks. If the latter are not part of the image, they are initialized as empty files when a guest is created, with the size given by the size attribute.
The image descriptor below can be used to create a virtual machine running the System Rescue CD ("http://www.sysresccd.org/") Besides the descriptor, you only need the ISO image from the System Rescue CD website.
<?xml version="1.0" encoding="UTF-8"?>
<image>
<name>sysresccd</name>
<domain>
<boot type="hvm">
<guest>
<arch>i686</arch>
</guest>
<os>
<loader dev="cdrom"/>
</os>
<drive disk="root.raw" target="hda"/>
<drive disk="sysresc"/>
</boot>
<devices>
<vcpu>1</vcpu>
<memory>262144</memory>
<interface/>
<graphics/>
</devices>
</domain>
<storage>
<disk file="root.raw" use="scratch" size="100" format="raw"/>
<disk id="sysresc" file="isos/systemrescuecd.iso"
use="system" format="iso"/>
</storage>
</image>
To create a virtual machine, save the above XML in image.xml and run:
# virt-image --vnc image.xml
Written by David Lutterkort. See the AUTHORS file in the source distribution for the complete list of credits.
Please see "http://virt-manager.org/page/BugReporting"
Copyright (C) 2006-2012 Red Hat, Inc, and various contributors. This is free software. You may redistribute copies of it under the terms of the GNU General Public License "http://www.gnu.org/licenses/gpl.html". There is NO WARRANTY, to the extent permitted by law.
virt-image(1), virt-install(1), the project website "http://virt-manager.org", the Relax-NG grammar for image XML "image.rng"