1<?xml version="1.0"?>
2<!-- A Relax NG schema for the libvirt network XML format -->
3<grammar xmlns="http://relaxng.org/ns/structure/1.0"
4         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
5  <start>
6    <ref name="network"/>
7  </start>
8
9  <include href="basictypes.rng"/>
10  <include href="networkcommon.rng"/>
11
12  <define name="network">
13
14    <element name="network">
15      <optional>
16        <attribute name="connections">
17          <data type="unsignedInt"/>
18        </attribute>
19      </optional>
20      <!-- Enables IPv6 guest-to-guest communications on a network
21           with no gateways addresses specified -->
22      <optional>
23        <attribute name="ipv6">
24          <ref name="virYesNo"/>
25        </attribute>
26      </optional>
27      <optional>
28        <attribute name="trustGuestRxFilters">
29          <ref name="virYesNo"/>
30        </attribute>
31      </optional>
32      <interleave>
33
34        <!-- The name of the network, used to refer to it through the API
35             and in virsh -->
36        <element name="name">
37          <text/>
38        </element>
39
40        <!-- <metadata> element -->
41        <optional>
42          <ref name="metadata"/>
43        </optional>
44
45        <!-- <uuid> element -->
46        <optional>
47          <element name="uuid"><ref name="UUID"/></element>
48        </optional>
49
50        <!-- <bridge> element -->
51        <optional>
52          <!-- The name of the network to be set up; this will back
53               the network on the host -->
54          <element name="bridge">
55            <optional>
56              <attribute name="name">
57                <ref name="deviceName"/>
58              </attribute>
59            </optional>
60
61            <optional>
62              <attribute name="zone">
63                <ref name="zoneName"/>
64              </attribute>
65            </optional>
66
67            <optional>
68              <attribute name="stp">
69                <ref name="virOnOff"/>
70              </attribute>
71            </optional>
72
73            <optional>
74              <attribute name="delay">
75                <data type="unsignedLong"/>
76              </attribute>
77            </optional>
78
79            <optional>
80              <attribute name="macTableManager">
81                <ref name="macTableManager"/>
82              </attribute>
83            </optional>
84
85          </element>
86        </optional>
87
88        <!-- <mtu> element -->
89        <optional>
90          <ref name="mtu"/>
91        </optional>
92
93        <!-- <mac> element -->
94        <optional>
95          <element name="mac">
96            <attribute name="address"><ref name="uniMacAddr"/></attribute>
97            <empty/>
98          </element>
99        </optional>
100
101        <!-- <forward> element -->
102        <optional>
103          <!-- The device through which the bridge is connected to the
104               rest of the network -->
105          <element name="forward">
106            <optional>
107              <attribute name="dev">
108                <ref name="deviceName"/>
109              </attribute>
110            </optional>
111
112            <optional>
113              <attribute name="mode">
114                <choice>
115                  <value>nat</value>
116                  <value>route</value>
117                  <value>open</value>
118                  <value>bridge</value>
119                  <value>passthrough</value>
120                  <value>private</value>
121                  <value>vepa</value>
122                  <value>hostdev</value>
123                </choice>
124              </attribute>
125            </optional>
126
127            <optional>
128              <attribute name="managed">
129                <ref name="virYesNo"/>
130              </attribute>
131            </optional>
132            <interleave>
133              <choice>
134                <group>
135                  <zeroOrMore>
136                    <element name="interface">
137                      <attribute name="dev">
138                        <ref name="deviceName"/>
139                      </attribute>
140                      <optional>
141                        <attribute name="connections">
142                          <data type="unsignedInt"/>
143                        </attribute>
144                      </optional>
145                    </element>
146                  </zeroOrMore>
147                </group>
148                <group>
149                  <zeroOrMore>
150                    <element name="address">
151                      <attribute name="type">
152                        <value>pci</value>
153                      </attribute>
154                      <ref name="pciaddress"/>
155                      <optional>
156                        <attribute name="connections">
157                          <data type="unsignedInt"/>
158                        </attribute>
159                      </optional>
160                    </element>
161                  </zeroOrMore>
162                </group>
163              </choice>
164              <optional>
165                <element name="pf">
166                  <attribute name="dev">
167                    <ref name="deviceName"/>
168                  </attribute>
169                </element>
170              </optional>
171              <optional>
172                <element name="driver">
173                  <attribute name="name">
174                    <choice>
175                      <value>kvm</value>
176                      <value>vfio</value>
177                    </choice>
178                  </attribute>
179                  <empty/>
180                </element>
181              </optional>
182              <optional>
183                <element name="nat">
184                  <optional>
185                    <attribute name="ipv6">
186                      <ref name="virYesNo"/>
187                    </attribute>
188                  </optional>
189                  <interleave>
190                    <optional>
191                      <element name="address">
192                        <attribute name="start">
193                          <ref name="ipv4Addr"/>
194                        </attribute>
195                        <attribute name="end">
196                          <ref name="ipv4Addr"/>
197                        </attribute>
198                      </element>
199                    </optional>
200                    <optional>
201                      <element name="port">
202                        <attribute name="start">
203                          <ref name="port"/>
204                        </attribute>
205                        <attribute name="end">
206                          <ref name="port"/>
207                        </attribute>
208                      </element>
209                    </optional>
210                  </interleave>
211                </element>
212              </optional>
213            </interleave>
214          </element>
215        </optional>
216
217        <!-- <virtualport> element -->
218        <optional>
219          <ref name="virtualPortProfile"/>
220        </optional>
221
222        <!-- <portgroup> elements -->
223        <zeroOrMore>
224          <element name="portgroup">
225            <attribute name="name">
226              <ref name="deviceName"/>
227            </attribute>
228            <optional>
229              <attribute name="default">
230                <ref name="virYesNo"/>
231              </attribute>
232            </optional>
233            <optional>
234              <attribute name="trustGuestRxFilters">
235                <ref name="virYesNo"/>
236              </attribute>
237            </optional>
238            <interleave>
239              <optional>
240                <ref name="virtualPortProfile"/>
241              </optional>
242              <optional>
243                <ref name="bandwidth"/>
244              </optional>
245              <optional>
246                <ref name="vlan"/>
247              </optional>
248            </interleave>
249          </element>
250        </zeroOrMore>
251
252        <!-- <domain> element -->
253        <optional>
254          <element name="domain">
255            <attribute name="name"><ref name="dnsName"/></attribute>
256            <optional>
257              <attribute name="localOnly"><ref name="virYesNo"/></attribute>
258            </optional>
259          </element>
260        </optional>
261
262        <!-- Define the DNS related elements like TXT records
263             and other features in the <dns> element -->
264        <optional>
265          <element name="dns">
266            <optional>
267              <attribute name="enable">
268                <ref name="virYesNo"/>
269              </attribute>
270            </optional>
271            <optional>
272              <attribute name="forwardPlainNames">
273                <ref name="virYesNo"/>
274              </attribute>
275            </optional>
276            <interleave>
277              <zeroOrMore>
278                <element name="forwarder">
279                  <optional>
280                    <attribute name="addr"><ref name="ipAddr"/></attribute>
281                  </optional>
282                  <optional>
283                    <attribute name="domain"><ref name="dnsName"/></attribute>
284                  </optional>
285                  <empty/>
286                </element>
287              </zeroOrMore>
288              <zeroOrMore>
289                <element name="txt">
290                  <attribute name="name"><ref name="dnsName"/></attribute>
291                  <attribute name="value"><text/></attribute>
292                </element>
293              </zeroOrMore>
294              <zeroOrMore>
295                <element name="srv">
296                  <attribute name="service"><text/></attribute>
297                  <attribute name="protocol">
298                    <ref name="protocol"/>
299                  </attribute>
300                  <optional>
301                    <attribute name="domain"><ref name="dnsName"/></attribute>
302                  </optional>
303                  <optional>
304                    <attribute name="target"><text/></attribute>
305                  </optional>
306                  <optional>
307                    <attribute name="port">
308                      <ref name="unsignedShort"/>
309                    </attribute>
310                  </optional>
311                  <optional>
312                    <attribute name="priority">
313                      <ref name="unsignedShort"/>
314                    </attribute>
315                  </optional>
316                  <optional>
317                    <attribute name="weight">
318                      <ref name="unsignedShort"/>
319                    </attribute>
320                  </optional>
321                </element>
322              </zeroOrMore>
323              <zeroOrMore>
324                <element name="host">
325                  <attribute name="ip"><ref name="ipAddr"/></attribute>
326                  <oneOrMore>
327                    <element name="hostname"><ref name="dnsName"/></element>
328                  </oneOrMore>
329                </element>
330              </zeroOrMore>
331            </interleave>
332          </element>
333        </optional>
334        <optional>
335          <ref name="bandwidth"/>
336        </optional>
337        <optional>
338          <ref name="vlan"/>
339        </optional>
340        <optional>
341          <ref name="portOptions"/>
342        </optional>
343
344        <!-- <ip> element -->
345        <zeroOrMore>
346          <!-- The IP element sets up NAT'ing and an optional DHCP server
347               local to the host. -->
348          <element name="ip">
349            <optional>
350              <attribute name="address"><ref name="ipAddr"/></attribute>
351            </optional>
352            <optional>
353              <choice>
354                <attribute name="netmask"><ref name="ipv4Addr"/></attribute>
355                <attribute name="prefix"><ref name="ipPrefix"/></attribute>
356              </choice>
357            </optional>
358            <optional>
359              <attribute name="family"><ref name="addr-family"/></attribute>
360            </optional>
361            <optional>
362              <attribute name="localPtr"><ref name="virYesNo"/></attribute>
363            </optional>
364            <interleave>
365              <optional>
366                <element name="tftp">
367                  <attribute name="root"><text/></attribute>
368                </element>
369              </optional>
370              <optional>
371                <!-- Define the range(s) of IP addresses that the DHCP
372                     server should hand out -->
373                <element name="dhcp">
374                  <interleave>
375                    <zeroOrMore>
376                      <element name="range">
377                        <attribute name="start"><ref name="ipAddr"/></attribute>
378                        <attribute name="end"><ref name="ipAddr"/></attribute>
379                        <interleave>
380                          <optional>
381                            <element name="lease">
382                              <attribute name="expiry"><ref name="unsignedLong"/></attribute>
383                              <optional>
384                                <attribute name="unit"><ref name="leaseUnit"/></attribute>
385                              </optional>
386                            </element>
387                          </optional>
388                        </interleave>
389                      </element>
390                    </zeroOrMore>
391                    <zeroOrMore>
392                      <element name="host">
393                        <choice>
394                          <group>
395                            <choice>
396                              <attribute name="mac"><ref name="uniMacAddr"/></attribute>
397                              <attribute name="id"><ref name="DUID"/></attribute>
398                            </choice>
399                            <optional>
400                              <attribute name="name"><text/></attribute>
401                            </optional>
402                          </group>
403                          <attribute name="name"><text/></attribute>
404                        </choice>
405                        <attribute name="ip"><ref name="ipAddr"/></attribute>
406                        <interleave>
407                          <optional>
408                            <element name="lease">
409                              <attribute name="expiry"><ref name="unsignedLong"/></attribute>
410                              <optional>
411                                <attribute name="unit"><ref name="leaseUnit"/></attribute>
412                              </optional>
413                            </element>
414                          </optional>
415                        </interleave>
416                      </element>
417                    </zeroOrMore>
418                    <optional>
419                      <element name="bootp">
420                        <attribute name="file"><ref name="filePath"/></attribute>
421                        <optional>
422                          <attribute name="server"><ref name="dnsName"/></attribute>
423                        </optional>
424                      </element>
425                    </optional>
426                  </interleave>
427                </element>
428              </optional>
429            </interleave>
430          </element>
431        </zeroOrMore>
432        <!-- <route> element -->
433        <zeroOrMore>
434          <ref name="route"/>
435        </zeroOrMore>
436
437      <!-- <dnsmasq:options> -->
438      <optional>
439        <element name="options" ns="http://libvirt.org/schemas/network/dnsmasq/1.0">
440          <zeroOrMore>
441            <element name="option">
442              <attribute name="value"/>
443            </element>
444          </zeroOrMore>
445        </element>
446      </optional>
447      </interleave>
448    </element>
449  </define>
450</grammar>
451