|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- A relax-ng grammar for virtual machine image descriptors --> |
| 3 | +<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0" |
| 4 | + datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> |
| 5 | + <start> |
| 6 | + <!-- An entire image consists of two parts: a description of the |
| 7 | + virtual machine in the image and a description of the |
| 8 | + storage backing the machine --> |
| 9 | + <element name="image"> |
| 10 | + <!-- A machine-usable name for this image --> |
| 11 | + <element name="name"><ref name="genericName"/></element> |
| 12 | + <!-- A human-readable label and description, mostly |
| 13 | + to support UI's --> |
| 14 | + <optional> |
| 15 | + <element name="label"><data type="string"/></element> |
| 16 | + </optional> |
| 17 | + <optional> |
| 18 | + <element name="description"><data type="string"/></element> |
| 19 | + </optional> |
| 20 | + <element name="domain"> |
| 21 | + <ref name="domain"/> |
| 22 | + </element> |
| 23 | + <element name="storage"> |
| 24 | + <ref name="storage"/> |
| 25 | + </element> |
| 26 | + </element> |
| 27 | + </start> |
| 28 | + |
| 29 | + <!-- The basics of the virtual machine: a list of boot descriptors |
| 30 | + that indicate how the virtual machine can be booted on various hosts, |
| 31 | + and a few statements listing what hardware should be available to the VM |
| 32 | + --> |
| 33 | + <define name="domain"> |
| 34 | + <oneOrMore> |
| 35 | + <element name="boot"><ref name="boot"/></element> |
| 36 | + </oneOrMore> |
| 37 | + <element name="devices"> |
| 38 | + <!-- Number of virtual CPU's --> |
| 39 | + <element name="vcpu"><ref name="countCPU"/></element> |
| 40 | + <!-- Size of memory (in kB) --> |
| 41 | + <element name="memory"><ref name="memoryKB"/></element> |
| 42 | + <!-- Whether the VM should have a network interface --> |
| 43 | + <element name="interface"><empty/></element> |
| 44 | + <!-- Whether the VM has a graphical interface --> |
| 45 | + <element name="graphics"><empty/></element> |
| 46 | + </element> |
| 47 | + </define> |
| 48 | + |
| 49 | + <!-- |
| 50 | + The boot descriptor for a virtual machine contains what capabilties |
| 51 | + the host must provide (in the guest element), how to boot the |
| 52 | + machine on such a host (in the os element) and how the disks from |
| 53 | + the storage section are to be mapped to drives in the machine |
| 54 | + --> |
| 55 | + <define name="boot"> |
| 56 | + <attribute name="type"> |
| 57 | + <choice> |
| 58 | + <value>xen</value> <!-- for a paravirt Xen host --> |
| 59 | + <value>hvm</value> <!-- for various fully-virt host platforms --> |
| 60 | + </choice> |
| 61 | + </attribute> |
| 62 | + <element name="guest"> |
| 63 | + <!-- The architecture we require to boot --> |
| 64 | + <element name="arch"> |
| 65 | + <choice> |
| 66 | + <value>i686</value> |
| 67 | + <value>x86_64</value> |
| 68 | + <value>mips</value> |
| 69 | + <value>sparc</value> |
| 70 | + <value>ppc</value> |
| 71 | + </choice> |
| 72 | + </element> |
| 73 | + <!-- Host features we need --> |
| 74 | + <optional> |
| 75 | + <element name="features"> |
| 76 | + <optional> |
| 77 | + <element name="pae"><ref name="feature-content"/></element> |
| 78 | + </optional> |
| 79 | + <optional> |
| 80 | + <element name="acpi"><ref name="feature-content"/></element> |
| 81 | + </optional> |
| 82 | + <optional> |
| 83 | + <element name="apic"><ref name="feature-content"/></element> |
| 84 | + </optional> |
| 85 | + </element> |
| 86 | + </optional> |
| 87 | + </element> |
| 88 | + |
| 89 | + <element name="os"> |
| 90 | + <!-- The details of how to boot the machine: either a loader or |
| 91 | + a kernel/initrd (for paravirt) |
| 92 | + --> |
| 93 | + <choice> |
| 94 | + <!-- |
| 95 | + An explicit loader: for hvm machines, should not have any content, |
| 96 | + since the loader is chosen depending on the host platform. |
| 97 | + Use the dev attribute to indicate from which device to boot |
| 98 | + For paravirt, specify 'pygrub'; the device to boot from needs to |
| 99 | + be the first one mapped with a 'drive' element |
| 100 | + --> |
| 101 | + <element name="loader"> |
| 102 | + <optional> |
| 103 | + <attribute name="dev"> |
| 104 | + <choice> |
| 105 | + <value>hd</value> |
| 106 | + <value>cdrom</value> |
| 107 | + </choice> |
| 108 | + </attribute> |
| 109 | + </optional> |
| 110 | + <choice> |
| 111 | + <empty/> <!-- for fullyvirt --> |
| 112 | + <value>pygrub</value> <!-- for paravirt --> |
| 113 | + </choice> |
| 114 | + </element> |
| 115 | + <!-- |
| 116 | + Boot a kernel/initrd contained in the image |
| 117 | + --> |
| 118 | + <group> |
| 119 | + <element name="kernel"><ref name="fileName"/></element> |
| 120 | + <optional> |
| 121 | + <element name="initrd"><ref name="fileName"/></element> |
| 122 | + </optional> |
| 123 | + <optional> |
| 124 | + <element name="cmdline"><text/></element> |
| 125 | + </optional> |
| 126 | + </group> |
| 127 | + </choice> |
| 128 | + </element> |
| 129 | + |
| 130 | + <!-- |
| 131 | + Mapping of disks from the storage section into drives in the |
| 132 | + virtual machine. The disk attribute names the disk, and the |
| 133 | + optional target attribute defines as which device that disk should |
| 134 | + appear inside the VM |
| 135 | + --> |
| 136 | + <oneOrMore> |
| 137 | + <element name="drive"> |
| 138 | + <attribute name="disk"><ref name="fileName"/></attribute> |
| 139 | + <optional> |
| 140 | + <attribute name="target"><ref name="deviceName"/></attribute> |
| 141 | + </optional> |
| 142 | + </element> |
| 143 | + </oneOrMore> |
| 144 | + </define> |
| 145 | + |
| 146 | + <!-- |
| 147 | + The storage section of the image description, consisting of a simple |
| 148 | + list of disks. |
| 149 | + --> |
| 150 | + <define name="storage"> |
| 151 | + <oneOrMore> |
| 152 | + <!-- A disk for mapping into a virtual machine |
| 153 | + file: file name (file must be in the same dir as the |
| 154 | + image descriptor) |
| 155 | + use: only important for updating existing images |
| 156 | + through replacement of entire disks |
| 157 | + size: size of the disk in MB, needed only for user and scratch |
| 158 | + disks that are not contained in the image; a blank disk |
| 159 | + of that size will be created automatically. |
| 160 | + format: raw for an uncompressed disk image (default) |
| 161 | + iso for an ISO |
| 162 | + --> |
| 163 | + <element name="disk"> |
| 164 | + <attribute name="file"><ref name="fileName"/></attribute> |
| 165 | + <attribute name="use"> |
| 166 | + <choice> |
| 167 | + <value>system</value> |
| 168 | + <value>user</value> |
| 169 | + <value>scratch</value> |
| 170 | + </choice> |
| 171 | + </attribute> |
| 172 | + <optional> |
| 173 | + <attribute name="size"><ref name="unsignedInt"/></attribute> |
| 174 | + </optional> |
| 175 | + <optional> |
| 176 | + <attribute name="format"> |
| 177 | + <choice> |
| 178 | + <value>raw</value> |
| 179 | + <value>iso</value> |
| 180 | + </choice> |
| 181 | + </attribute> |
| 182 | + </optional> |
| 183 | + </element> |
| 184 | + </oneOrMore> |
| 185 | + </define> |
| 186 | + |
| 187 | + <!-- The content for individual features like pae, acpi and apic. |
| 188 | + The state attribute defaults to 'on' |
| 189 | + --> |
| 190 | + <define name="feature-content"> |
| 191 | + <optional> |
| 192 | + <attribute name="state"> |
| 193 | + <choice> |
| 194 | + <value>on</value> |
| 195 | + <value>off</value> |
| 196 | + </choice> |
| 197 | + </attribute> |
| 198 | + </optional> |
| 199 | + <empty/> |
| 200 | + </define> |
| 201 | + |
| 202 | + <!-- |
| 203 | + Type library |
| 204 | + --> |
| 205 | + <define name='unsignedInt'> |
| 206 | + <data type='unsignedInt'> |
| 207 | + <param name="pattern">[0-9]+</param> |
| 208 | + </data> |
| 209 | + </define> |
| 210 | + <define name='countCPU'> |
| 211 | + <data type='unsignedShort'> |
| 212 | + <param name="pattern">[0-9]+</param> |
| 213 | + <param name="minInclusive">1</param> |
| 214 | + </data> |
| 215 | + </define> |
| 216 | + <define name='memoryKB'> |
| 217 | + <data type='unsignedInt'> |
| 218 | + <param name="pattern">[0-9]+</param> |
| 219 | + <param name="minInclusive">4000</param> |
| 220 | + </data> |
| 221 | + </define> |
| 222 | + <define name='genericName'> |
| 223 | + <data type='string'> |
| 224 | + <param name="pattern">[a-zA-Z0-9_\+\-]+</param> |
| 225 | + </data> |
| 226 | + </define> |
| 227 | + <define name='fileName'> |
| 228 | + <data type='string'> |
| 229 | + <param name="pattern">[^/]+</param> |
| 230 | + </data> |
| 231 | + </define> |
| 232 | + <define name='deviceName'> |
| 233 | + <data type='string'> |
| 234 | + <param name="pattern">[a-zA-Z0-9_\-:./]+</param> |
| 235 | + </data> |
| 236 | + </define> |
| 237 | +</grammar> |
0 commit comments