mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
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: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
eebec1697e
commit
b020cf73fe
@ -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>
|
||||
...
|
||||
<devices>
|
||||
<interface type='network'>
|
||||
<source network='default'/>
|
||||
<target dev='vnet0'/>
|
||||
<b><mtu size='1500'/></b>
|
||||
</interface>
|
||||
</devices>
|
||||
...</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 <interface/>
|
||||
</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,
|
||||
|
60
tests/qemuxml2argvdata/qemuxml2argv-net-mtu.xml
Normal file
60
tests/qemuxml2argvdata/qemuxml2argv-net-mtu.xml
Normal file
@ -0,0 +1,60 @@
|
||||
<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>
|
Loading…
x
Reference in New Issue
Block a user