2007-07-24 09:19:40 +00:00
|
|
|
<!-- A Relax NG schema for the libvirt network XML format -->
|
2010-11-11 19:48:51 +00:00
|
|
|
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
|
2007-07-24 09:19:40 +00:00
|
|
|
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
2010-11-11 19:48:51 +00:00
|
|
|
<start>
|
|
|
|
<ref name="network"/>
|
|
|
|
</start>
|
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<define name="network">
|
2010-11-11 19:48:51 +00:00
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<element name="network">
|
|
|
|
<interleave>
|
2009-10-09 12:48:22 +00:00
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<!-- The name of the network, used to refer to it through the API
|
|
|
|
and in virsh -->
|
|
|
|
<element name="name">
|
2009-10-09 12:48:22 +00:00
|
|
|
<text/>
|
2010-11-11 20:17:34 +00:00
|
|
|
</element>
|
2009-10-09 12:48:22 +00:00
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<!-- <uuid> element -->
|
|
|
|
<optional>
|
|
|
|
<element name="uuid"><text/></element>
|
|
|
|
</optional>
|
2009-10-09 12:48:22 +00:00
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<!-- <bridge> element -->
|
|
|
|
<optional>
|
|
|
|
<!-- The name of the network to be set up; this will back
|
|
|
|
the network on the host -->
|
|
|
|
<element name="bridge">
|
|
|
|
<optional>
|
|
|
|
<attribute name="name">
|
|
|
|
<text/>
|
|
|
|
</attribute>
|
|
|
|
</optional>
|
2009-10-09 12:48:22 +00:00
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<optional>
|
|
|
|
<attribute name="stp">
|
|
|
|
<choice>
|
|
|
|
<value>on</value>
|
|
|
|
<value>off</value>
|
|
|
|
</choice>
|
|
|
|
</attribute>
|
|
|
|
</optional>
|
2009-10-09 12:48:22 +00:00
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<optional>
|
|
|
|
<attribute name="delay">
|
|
|
|
<data type="integer"/>
|
|
|
|
</attribute>
|
|
|
|
</optional>
|
2009-10-09 12:48:22 +00:00
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
</element>
|
|
|
|
</optional>
|
2009-10-09 12:48:22 +00:00
|
|
|
|
Give each virtual network bridge its own fixed MAC address
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=609463
The problem was that, since a bridge always acquires the MAC address
of the connected interface with the numerically lowest MAC, as guests
are started and stopped, it was possible for the MAC address to change
over time, and this change in the network was being detected by
Windows 7 (it sees the MAC of the default route change), so on each
reboot it would bring up a dialog box asking about this "new network".
The solution is to create a dummy tap interface with a MAC guaranteed
to be lower than any guest interface's MAC, and attach that tap to the
bridge as soon as it's created. Since all guest MAC addresses start
with 0xFE, we can just generate a MAC with the standard "0x52, 0x54,
0" prefix, and it's guaranteed to always win (physical interfaces are
never connected to these bridges, so we don't need to worry about
competing numerically with them).
Note that the dummy tap is never set to IFF_UP state - that's not
necessary in order for the bridge to take its MAC, and not setting it
to UP eliminates the clutter of having an (eg) "virbr0-nic" displayed
in the output of the ifconfig command.
I chose to not auto-generate the MAC address in the network XML
parser, as there are likely to be consumers of that API that don't
need or want to have a MAC address associated with the
bridge.
Instead, in bridge_driver.c when the network is being defined, if
there is no MAC, one is generated. To account for virtual network
configs that already exist when upgrading from an older version of
libvirt, I've added a %post script to the specfile that searches for
all network definitions in both the config directory
(/etc/libvirt/qemu/networks) and the state directory
(/var/lib/libvirt/network) that are missing a mac address, generates a
random address, and adds it to the config (and a matching address to
the state file, if there is one).
docs/formatnetwork.html.in: document <mac address.../>
docs/schemas/network.rng: add nac address to schema
libvirt.spec.in: %post script to update existing networks
src/conf/network_conf.[ch]: parse and format <mac address.../>
src/libvirt_private.syms: export a couple private symbols we need
src/network/bridge_driver.c:
auto-generate mac address when needed,
create dummy interface if mac address is present.
tests/networkxml2xmlin/isolated-network.xml
tests/networkxml2xmlin/routed-network.xml
tests/networkxml2xmlout/isolated-network.xml
tests/networkxml2xmlout/routed-network.xml: add mac address to some tests
2011-02-09 08:28:12 +00:00
|
|
|
<!-- <mac> element -->
|
|
|
|
<optional>
|
|
|
|
<element name="mac">
|
|
|
|
<attribute name="address"><ref name="mac-addr"/></attribute>
|
|
|
|
<empty/>
|
|
|
|
</element>
|
|
|
|
</optional>
|
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<!-- <forward> element -->
|
|
|
|
<optional>
|
|
|
|
<!-- The device through which the bridge is connected to the
|
|
|
|
rest of the network -->
|
|
|
|
<element name="forward">
|
|
|
|
<optional>
|
|
|
|
<attribute name="dev">
|
|
|
|
<text/>
|
|
|
|
</attribute>
|
|
|
|
</optional>
|
2009-10-09 12:48:22 +00:00
|
|
|
|
2010-11-11 20:17:34 +00:00
|
|
|
<optional>
|
|
|
|
<attribute name="mode">
|
|
|
|
<choice>
|
|
|
|
<value>nat</value>
|
|
|
|
<value>route</value>
|
|
|
|
</choice>
|
|
|
|
</attribute>
|
|
|
|
</optional>
|
2007-07-24 09:19:40 +00:00
|
|
|
</element>
|
2010-11-11 20:17:34 +00:00
|
|
|
</optional>
|
|
|
|
|
|
|
|
<!-- <domain> element -->
|
|
|
|
<optional>
|
|
|
|
<element name="domain">
|
2009-07-02 14:02:18 +00:00
|
|
|
<attribute name="name"><text/></attribute>
|
|
|
|
</element>
|
2010-11-11 20:17:34 +00:00
|
|
|
</optional>
|
|
|
|
|
|
|
|
<!-- <ip> element -->
|
2010-11-17 18:36:19 +00:00
|
|
|
<zeroOrMore>
|
2010-11-11 20:17:34 +00:00
|
|
|
<!-- The IP element sets up NAT'ing and an optional DHCP server
|
|
|
|
local to the host. -->
|
|
|
|
<element name="ip">
|
|
|
|
<optional>
|
2010-11-17 18:36:19 +00:00
|
|
|
<attribute name="address"><ref name="ip-addr"/></attribute>
|
|
|
|
</optional>
|
|
|
|
<optional>
|
|
|
|
<choice>
|
|
|
|
<attribute name="netmask"><ref name="ipv4-addr"/></attribute>
|
|
|
|
<attribute name="prefix"><ref name="ip-prefix"/></attribute>
|
|
|
|
</choice>
|
2010-11-11 20:17:34 +00:00
|
|
|
</optional>
|
|
|
|
<optional>
|
2010-11-17 18:36:19 +00:00
|
|
|
<attribute name="family"><ref name="addr-family"/></attribute>
|
2010-11-11 20:17:34 +00:00
|
|
|
</optional>
|
2009-10-28 14:57:49 +00:00
|
|
|
<optional>
|
2010-11-11 20:17:34 +00:00
|
|
|
<element name="tftp">
|
|
|
|
<attribute name="root"><text/></attribute>
|
|
|
|
</element>
|
2009-10-28 14:57:49 +00:00
|
|
|
</optional>
|
2010-12-16 17:36:19 +00:00
|
|
|
<optional>
|
|
|
|
<!-- Define the range(s) of IP addresses that the DHCP
|
|
|
|
server should hand out -->
|
|
|
|
<element name="dhcp">
|
|
|
|
<zeroOrMore>
|
|
|
|
<element name="range">
|
|
|
|
<attribute name="start"><ref name="ipv4-addr"/></attribute>
|
|
|
|
<attribute name="end"><ref name="ipv4-addr"/></attribute>
|
|
|
|
</element>
|
|
|
|
</zeroOrMore>
|
|
|
|
<zeroOrMore>
|
|
|
|
<element name="host">
|
|
|
|
<attribute name="mac"><ref name="mac-addr"/></attribute>
|
|
|
|
<attribute name="name"><text/></attribute>
|
|
|
|
<attribute name="ip"><ref name="ipv4-addr"/></attribute>
|
|
|
|
</element>
|
|
|
|
</zeroOrMore>
|
|
|
|
<optional>
|
|
|
|
<element name="bootp">
|
|
|
|
<attribute name="file"><text/></attribute>
|
|
|
|
<optional>
|
|
|
|
<attribute name="server"><text/></attribute>
|
|
|
|
</optional>
|
|
|
|
</element>
|
|
|
|
</optional>
|
|
|
|
</element>
|
|
|
|
</optional>
|
2010-03-01 19:09:26 +00:00
|
|
|
</element>
|
2010-11-17 18:36:19 +00:00
|
|
|
</zeroOrMore>
|
2010-11-11 20:17:34 +00:00
|
|
|
</interleave>
|
2007-07-24 09:19:40 +00:00
|
|
|
</element>
|
2010-11-11 20:17:34 +00:00
|
|
|
</define>
|
2010-11-11 20:29:01 +00:00
|
|
|
|
|
|
|
<!-- An ipv4 "dotted quad" address -->
|
|
|
|
<define name='ipv4-addr'>
|
|
|
|
<data type='string'>
|
|
|
|
<param name="pattern">(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))</param>
|
|
|
|
</data>
|
|
|
|
</define>
|
|
|
|
|
2010-11-17 18:36:19 +00:00
|
|
|
<!-- Based on http://blog.mes-stats.fr/2008/10/09/regex-ipv4-et-ipv6 -->
|
|
|
|
<define name='ipv6-addr'>
|
|
|
|
<data type='string'>
|
|
|
|
<!-- To understand this better, take apart the toplevel '|'s -->
|
|
|
|
<param name="pattern">(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(([0-9A-Fa-f]{1,4}:){0,5}:(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(::([0-9A-Fa-f]{1,4}:){0,5}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)</param>
|
|
|
|
</data>
|
|
|
|
</define>
|
|
|
|
|
|
|
|
<define name='ip-addr'>
|
|
|
|
<choice>
|
|
|
|
<ref name='ipv4-addr'/>
|
|
|
|
<ref name='ipv6-addr'/>
|
|
|
|
</choice>
|
|
|
|
</define>
|
|
|
|
|
|
|
|
<define name='ip-prefix'>
|
|
|
|
<data type='unsignedInt'>
|
|
|
|
<param name="maxInclusive">128</param>
|
|
|
|
</data>
|
|
|
|
</define>
|
|
|
|
|
|
|
|
<define name='addr-family'>
|
|
|
|
<data type='string'>
|
|
|
|
<param name="pattern">(ipv4)|(ipv6)</param>
|
|
|
|
</data>
|
|
|
|
</define>
|
|
|
|
|
2010-11-11 20:29:01 +00:00
|
|
|
<!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
|
|
|
|
<define name='mac-addr'>
|
|
|
|
<data type='string'>
|
|
|
|
<param name="pattern">([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}</param>
|
|
|
|
</data>
|
|
|
|
</define>
|
|
|
|
|
2010-11-11 19:48:51 +00:00
|
|
|
</grammar>
|