conf: support host-side IP/route information in <interface>

This is place as a sub-element of <source>, where other aspects of the
host-side connection to the network device are located (network or
bridge name, udp listen port, etc). It's a bit odd that the interface
we're configuring with this info is itself named in <target dev='x'/>,
but that ship sailed long ago:

    <interface type='ethernet'>
      <mac address='00:16:3e:0f:ef:8a'/>
      <source>
        <ip address='192.168.122.12' family='ipv4'
            prefix='24' peer='192.168.122.1'/>
        <ip address='192.168.122.13' family='ipv4' prefix='24'/>
        <route family='ipv4' address='0.0.0.0'
               gateway='192.168.122.1'/>
        <route family='ipv4' address='192.168.124.0' prefix='24'
               gateway='192.168.124.1'/>
      </source>
    </interface>

In practice, this will likely only be useful for type='ethernet', so
its presence in any other type of interface is currently forbidden in
the generic device Validate function (but it's been put into the
general population of virDomainNetDef rather than the
ethernet-specific union member so that 1) we can more easily add the
capability to other types if needed, and 2) we can retain the info
when set to an invalid interface type all the way through to
validation and report a proper error, rather than just ignoring it
(which is currently what happens for many other type-specific
settings).

(NB: The already-existing configuration of IP info for the guest-side
of interfaces is in subelements directly under <interface>, and the
name of the guest-side interface (when configurable) is in <guest
dev='x'/>).

(This patch had been pushed earlier in
commit fe6a77898a, but was reverted in
commit d658456530 because it had been
accidentally pushed during the freeze for release 2.0.0)
This commit is contained in:
Laine Stump
2016-06-09 15:35:08 -04:00
parent b81cf13e66
commit 98fa8f3ef6
6 changed files with 155 additions and 22 deletions

View File

@@ -5015,6 +5015,32 @@ qemu-kvm -net nic,model=? /dev/null
definitions</a>. This is used by the LXC driver.
</p>
<pre>
...
&lt;devices&gt;
&lt;interface type='ethernet'&gt;
<b>&lt;source/&gt;</b>
<b>&lt;ip address='192.168.123.1' prefix='24'/&gt;</b>
<b>&lt;ip address='10.0.0.10' prefix='24' peer='192.168.122.5'/&gt;</b>
<b>&lt;route family='ipv4' address='192.168.42.0' prefix='24' gateway='192.168.123.4'/&gt;</b>
<b>&lt;source/&gt;</b>
...
&lt;/interface&gt;
...
&lt;/devices&gt;
...
</pre>
<p>
<span class="since">Since 2.1.0</span> network devices of type
"ethernet" can optionally be provided one or more IP addresses
and one or more routes to set on the <b>host</b> side of the
network device. These are configured as subelements of
the <code>&lt;source&gt;</code> element of the interface, and
have the same attributes as the similarly named elements used to
configure the guest side of the interface (described above).
</p>
<h5><a name="elementVhostuser">vhost-user interface</a></h5>
<p>