[pve-devel] [PATCH qemu-server 1/1] Close #2443: qemu-server: add MTU option to virtio-net device

Alexandre DERUMIER aderumier at odiso.com
Mon Feb 3 06:29:54 CET 2020


Hi,
sorry to bump this thread, but I'm seeing users requesting this on the forum,
and I think I'll need it too for vxlan setup, when users can't increase the mtu on physical interfaces
(and so, need to reduce it in the vms)



>>As far as I can see, the guest sets the MTU to 1500 on the virtio
>>interface, unless qemu explicitly sets host_mtu for the adapter being
>>created, regardless of the MTU of the tap interface on the host.
>>This is essentially the normal behavior of the operating system and the
>>virtio driver if no additional information about the host system is
>>passed on.

>>Thus, I think in the future it would be logical to add a patch that
>>would install host_mtu explicitly if the tap interface on the host
>>system is set to MTU different from 1500. The tap interface itself
>>inherits the MTU from the bridge interface in which it is "connected".

I can adapt the patch to map the mtu in guest, to mtu of bridge/tap.


>> + mtu => { 
>> + type => 'number', 
>> + minimum => 576, maximum=> 65536, 

Not sure, is it possible to add an extra "1" value for "auto" ?

or maybe, do we want to force it, if bridge mtu is < 1500 ?
(as guest mtu is 1500 by default, it will break anyway if bridge mtu < 1500)





----- Mail original -----
De: tacid at tacid.kiev.ua
À: "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Jeudi 12 Décembre 2019 16:51:15
Objet: Re: [pve-devel] [PATCH qemu-server 1/1] Close #2443: qemu-server: add MTU option to virtio-net device

Thomas Lamprecht писал 2019-12-12 08:54: 
> On 12/11/19 6:03 PM, Paul Shepel wrote: 
>> This patch adds support of QEMU host_mtu virtio-net parameter 
>> thats expose host MTU to guest 
>> 
> 
> Looks OK, a nit (which I can fixup locally) and a question out of 
> interest 
> inline. 
> 
>> Signed-off-by: Paul Shepel <tacid at tacid.kiev.ua> 
>> --- 
>> PVE/QemuServer.pm | 8 ++++++++ 
>> 1 file changed, 8 insertions(+) 
>> 
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm 
>> index 865a89b..3168dde 100644 
>> --- a/PVE/QemuServer.pm 
>> +++ b/PVE/QemuServer.pm 
>> @@ -892,6 +892,12 @@ my $net_fmt = { 
>> description => "Rate limit in mbps (megabytes per second) as 
>> floating point number.", 
>> optional => 1, 
>> }, 
>> + mtu => { 
>> + type => 'number', 
>> + minimum => 576, maximum=> 65536, 
> 
> nit: space missing between maximum and => 
> 
> Do you know what the default is? Is it always 1500, or does QEMU adapt 
> this 
> to the host, if the interface it's plugged to has a smaller MTU - for 
> example. 

As far as I can see, the guest sets the MTU to 1500 on the virtio 
interface, unless qemu explicitly sets host_mtu for the adapter being 
created, regardless of the MTU of the tap interface on the host. 
This is essentially the normal behavior of the operating system and the 
virtio driver if no additional information about the host system is 
passed on. 

Thus, I think in the future it would be logical to add a patch that 
would install host_mtu explicitly if the tap interface on the host 
system is set to MTU different from 1500. The tap interface itself 
inherits the MTU from the bridge interface in which it is "connected". 

The problem, as far as I understand, is that TSO is implemented and 
enabled by default in the virtio driver, so if the MTU is not configured 
correctly (larger then can be fit in ethernet frame), some packages will 
simply not reach the destination. 

> 
>> + description => "MTU (virtio-net only)", 
>> + optional => 1, 
>> + }, 
>> tag => { 
>> type => 'integer', 
>> minimum => 1, maximum => 4094, 
>> @@ -2060,6 +2066,7 @@ sub print_netdevice_full { 
>> $tmpstr .= ",vectors=$vectors,mq=on"; 
>> } 
>> $tmpstr .= ",bootindex=$net->{bootindex}" if $net->{bootindex} ; 
>> + $tmpstr .= ",host_mtu=$net->{mtu}" if $net->{mtu} && $device eq 
>> 'virtio-net-pci'; 
>> 
>> if ($use_old_bios_files) { 
>> my $romfile; 
>> @@ -5052,6 +5059,7 @@ sub vmconfig_update_net { 
>> if (&$safe_string_ne($oldnet->{model}, $newnet->{model}) || 
>> &$safe_string_ne($oldnet->{macaddr}, $newnet->{macaddr}) || 
>> &$safe_num_ne($oldnet->{queues}, $newnet->{queues}) || 
>> + &$safe_num_ne($oldnet->{mtu}, $newnet->{mtu}) || 
>> !($newnet->{bridge} && $oldnet->{bridge})) { # bridge/nat mode 
>> change 
>> 
>> # for non online change, we try to hot-unplug 
>> 
_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 




More information about the pve-devel mailing list