1virt-image(5) Virtual Machine Install Tools virt-image(5)
2
3
4
6 virt-image - Format of the virtual image XML descriptor
7
9 virt-image(1) relies on an XML descriptor to create virtual machines
10 from virtual machine images. In general, a virtual machine image
11 consists of the XML descriptor (usually in a file image.xml) and a
12 number of files for the virtual machine's disks.
13
14 In the following explanation of the structure of the image descriptor,
15 mandatory XML elements are marked as element, whereas optional elements
16 are marked as element.
17
18 All file names in the image descriptor are relative to the location of
19 the descriptor itself. Generally, disk files are either kept in the
20 same directory as the image descriptor, or in a subdirectory.
21
23 The image descriptor contains information on the requirements a guest
24 has on the host platform through one or more the /image/domain/boot
25 descriptors (see section "BOOT"). The image can only be used if at
26 least one of the boot descriptors is suitable for the host platform; a
27 boot descriptor is suitable if:
28
29 · The CPU architecture of the boot descriptor, given by the
30 boot/guest/arch element, is supported by the host
31
32 · The host supports a guest with the features requested in the
33 boot/guest/features element, such as providing an APIC, or having
34 ACPI turned off
35
36 If a suitable boot descriptor is found, the guest is created and booted
37 according to the information about booting the OS from the boot/os
38 element and with the disks specified in the boot/drive element. If more
39 than one suitable boot descriptor is found, one of them is chosen based
40 on a heuristic, generally preferring paravirtualized guests over full
41 virtualized ones, though this is an implementation detail of the tool
42 creating the virtual machine.
43
45 The image descriptor consists of three sections, all contained in the
46 toplevel image element:
47
48 General metadata about the image
49 A number of elements like label, name, and description that give
50 some simple information about the image. The name must be a string
51 suitable as a name for the virtual machine, the label is a short
52 human-readable string suitable for display in graphical UI's, and
53 the description should be a longer, free-form description of the
54 purpose of the image. The name is mandatory.
55
56 Virtual machine attributes
57 The domain element contains instructions on how to boot the image,
58 and device attributes such as the number of virtual CPU's and the
59 size of the memory. (see section "DOMAIN")
60
61 Storage layout
62 The storage element lists the files to back the virtual machine's
63 disks and some information about their format and use. (see section
64 "STORAGE")
65
67 The domain element contains one or more boot descriptors (see section
68 "BOOT") and a devices element. The Devices element lists the
69 recommended number of virtual CPU's in the vcpu element and the
70 recommended amount of memory in kB in the memory element. It also
71 indicates whether the virtual machine should have a network interface
72 through the interface element and whether the virtual machine has a
73 graphical interface through the graphics element.
74
75 BOOT
76
77 Each boot descriptor details how the virtual machine should be started
78 on a certain hypervisor. The type attribute of the boot element, which
79 can either be "xen" or "hvm", depending on whether the boot descriptor
80 is for a paravirtualized Xen(tm) guest or a fully-virtualized guest.
81
82 The boot element contains three subelements:
83
84 The platform requirements of the guest
85 The platform requirements, contained in the guest element, consist
86 of the arch element and the features element. The arch element
87 indicates the CPU architecture the guest expects, e.g. "i686",
88 "x86_64", or "ppc".
89
90 The features element indicates whether certain platform features
91 should be on or off. Currently, the platform features are pae,
92 acpi, and apic. They can be turned on or off by giving a state
93 attribute of either "on" or "off". When a feature is mentioned in
94 the features element, it defaults to "on".
95
96 The details of booting the image's operating system
97 The os element for fully-virtualized "hvm" guests contains a loader
98 element whose dev attribute indicates whether to boot off a hard
99 disk ("dev='hd'") or off a CD-ROM ("dev='cdrom'")
100
101 For paravirtualized guests, the os element either contains a
102 "<loader>pygrub</loader>" element, indicating that the guest should
103 be booted with pygrub, or kernel, initrd and cmdline elements. The
104 contents of the kernel and initrd elements are the names of the
105 kernel and initrd files, whereas the cmdline element contains the
106 command line that should be passed to the kernel on boot.
107
108 The mapping of disk files as devices into the guest
109 The mapping of disk files into the guest is performed by a list of
110 drive elements inside the boot element. Each drive element
111 references the name of a disk file from the "STORAGE" section
112 through its disk attribute and can optionally specify as what
113 device that disk file should appear in the guest through its target
114 attribute. If the target is omitted, device names are assigned in
115 the order in which the drive elements appear, skipping already
116 assigned devices.
117
119 The storage element lists the disk image files that are part of the
120 virtual machine image in a list of one or more disk elements. Each disk
121 element can contain the following attributes:
122
123 · the file attribute giving the name of the disk file
124
125 · an optional id attribute. The name given with that attribute is
126 used to reference the disk from the drive element of a boot
127 descriptor. If the id attribute is missing, it defaults to the file
128 attribute.
129
130 · the use attribute indicating whether the disk file is a "system",
131 "user", or "scratch" disk. The use attribute differentiates disk
132 files so that an update based on replacing disk files can replace
133 "system" disks, but leave "user" disks untouched.
134
135 Generally, "system" disks contain application code, "user" disks
136 contain the application's data, and "scratch" disks contain
137 temporary state that can be erased between runs of the guest.
138
139 The virtual machine image must contain files for all "system"
140 disks, and may contain files for the "user" and "scratch" disks. If
141 the latter are not part of the image, they are initialized as empty
142 files when a guest is created, with the size given by the size
143 attribute.
144
145 · the size attribute giving the size of the disk in MB.
146
147 · the format attribute giving the format of the disk file. Currently,
148 this can be one of: "raw" "iso", "qemu", "qemu2", or "vmdk".
149
151 The image descriptor below can be used to create a virtual machine
152 running the System Rescue CD ("http://www.sysresccd.org/") Besides the
153 descriptor, you only need the ISO image from the System Rescue CD
154 website.
155
156 <?xml version="1.0" encoding="UTF-8"?>
157 <image>
158 <name>sysresccd</name>
159 <domain>
160 <boot type="hvm">
161 <guest>
162 <arch>i686</arch>
163 </guest>
164 <os>
165 <loader dev="cdrom"/>
166 </os>
167 <drive disk="root.raw" target="hda"/>
168 <drive disk="sysresc"/>
169 </boot>
170 <devices>
171 <vcpu>1</vcpu>
172 <memory>262144</memory>
173 <interface/>
174 <graphics/>
175 </devices>
176 </domain>
177 <storage>
178 <disk file="root.raw" use="scratch" size="100" format="raw"/>
179 <disk id="sysresc" file="isos/systemrescuecd.iso"
180 use="system" format="iso"/>
181 </storage>
182 </image>
183
184 To create a virtual machine, save the above XML in image.xml and run:
185
186 # virt-image --vnc image.xml
187
189 Written by David Lutterkort. See the AUTHORS file in the source
190 distribution for the complete list of credits.
191
193 Please see "http://virt-manager.org/page/BugReporting"
194
196 Copyright (C) 2006-2007 Red Hat, Inc, and various contributors. This
197 is free software. You may redistribute copies of it under the terms of
198 the GNU General Public License "http://www.gnu.org/licenses/gpl.html".
199 There is NO WARRANTY, to the extent permitted by law.
200
202 virt-image(1), virt-install(1), the project website
203 "http://virt-manager.org", the Relax-NG grammar for image XML
204 "image.rng"
205
206
207
208 2009-12-01 virt-image(5)