提交 b020cf73 编写于 作者: M Michal Privoznik

domain_conf: Introduce <mtu/> to <interface/>

So far we allow to set MTU for libvirt networks. However, not all
domain interfaces have to be plugged into a libvirt network and
even if they are, they might want to have a different MTU (e.g.
for testing purposes).
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 eebec169
......@@ -5215,6 +5215,25 @@ qemu-kvm -net nic,model=? /dev/null
<span class="since">Since 0.9.5</span>
</p>
<h5><a name="mtu">MTU configuration</a></h5>
<pre>
...
&lt;devices&gt;
&lt;interface type='network'&gt;
&lt;source network='default'/&gt;
&lt;target dev='vnet0'/&gt;
<b>&lt;mtu size='1500'/&gt;</b>
&lt;/interface&gt;
&lt;/devices&gt;
...</pre>
<p>
This element provides means of setting MTU of the virtual network link.
Currently there is just one attribute <code>size</code> which accepts a
non-negative integer which specifies the MTU size for the interface.
<span class="since">Since 3.1.0</span>
</p>
<h5><a name="ipconfig">IP configuration</a></h5>
<pre>
...
......
......@@ -24,6 +24,14 @@
options in order to print just the --name and/or --uuid of pools.
</description>
</change>
<change>
<summary>
Introduce MTU to domain &lt;interface/&gt;
</summary>
<description>
Allow setting MTU size for some types of domain interface.
</description>
</change>
</section>
<section title="Bug fixes">
<change>
......
......@@ -2465,6 +2465,9 @@
<empty/>
</element>
</optional>
<optional>
<ref name="mtu"/>
</optional>
<optional>
<element name="target">
<attribute name="dev">
......
......@@ -260,10 +260,19 @@
</optional>
</element>
</define>
<define name="macTableManager">
<choice>
<value>kernel</value>
<value>libvirt</value>
</choice>
</define>
<define name="mtu">
<element name="mtu">
<attribute name="size">
<ref name="unsignedShort"/>
</attribute>
</element>
</define>
</grammar>
......@@ -10050,6 +10050,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
if (virXPathUInt("string(./mtu/@size)", ctxt, &def->mtu) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("malformed mtu size"));
goto error;
}
cleanup:
ctxt->node = oldnode;
VIR_FREE(macaddr);
......@@ -21769,6 +21775,10 @@ virDomainNetDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<link state='%s'/>\n",
virDomainNetInterfaceLinkStateTypeToString(def->linkstate));
}
if (def->mtu)
virBufferAsprintf(buf, "<mtu size='%u'/>\n", def->mtu);
if (virDomainDeviceInfoFormat(buf, &def->info,
flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT
| VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0)
......
......@@ -1009,6 +1009,7 @@ struct _virDomainNetDef {
virNetDevVlan vlan;
int trustGuestRxFilters; /* enum virTristateBool */
int linkstate;
unsigned int mtu;
};
/* Used for prefix of ifname of any network name generated dynamically
......
......@@ -2868,6 +2868,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
_("rx_queue_size has to be a power of two"));
goto cleanup;
}
if (net->mtu &&
!qemuDomainNetSupportsMTU(net->type)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("setting MTU on interface type %s is not supported yet"),
virDomainNetTypeToString(net->type));
goto cleanup;
}
}
ret = 0;
......@@ -6529,6 +6537,27 @@ qemuDomainSupportsNetdev(virDomainDefPtr def,
return virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV);
}
bool
qemuDomainNetSupportsMTU(virDomainNetType type)
{
switch (type) {
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_ETHERNET:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
case VIR_DOMAIN_NET_TYPE_MCAST:
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_DIRECT:
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_LAST:
break;
}
return false;
}
int
qemuDomainNetVLAN(virDomainNetDefPtr def)
......
......@@ -708,6 +708,8 @@ bool qemuDomainSupportsNetdev(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
virDomainNetDefPtr net);
bool qemuDomainNetSupportsMTU(virDomainNetType type);
int qemuDomainNetVLAN(virDomainNetDefPtr def);
int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
......
<domain type='qemu'>
<name>test</name>
<uuid>15d091de-0181-456b-9554-e4382dc1f1ab</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-0.13'>hvm</type>
<boot dev='cdrom'/>
<boot dev='hd'/>
<bootmenu enable='yes'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' event_idx='on'/>
<source file='/var/lib/libvirt/images/f14.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</controller>
<controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
<interface type='network'>
<source network='default'/>
<mac address='52:54:00:e5:48:58'/>
<model type='virtio'/>
<mtu size='1500'/>
</interface>
<interface type='network'>
<source network='default'/>
<mac address='52:54:00:e5:48:59'/>
<model type='virtio'/>
<mtu size='9000'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<memballoon model='virtio'/>
</devices>
</domain>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册