This add a new "mtu" param to vm nic,
and force the mtu in the guest for virtio nic only.

Special value: 1 = set the same value than the bridge
---
 PVE/QemuServer.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6445508..9baa6ff 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -884,6 +884,12 @@ my $net_fmt = {
        description => 'Whether this interface should be disconnected (like 
pulling the plug).',
        optional => 1,
     },
+    mtu => {
+       type => 'integer',
+       minimum => 1, maximum => 65520,
+       description => 'Force mtu (virtio only). 1 = bridge mtu value',
+       optional => 1,
+    },
 };
 
 my $netdesc = {
@@ -1593,6 +1599,19 @@ sub print_netdevice_full {
     }
     $tmpstr .= ",bootindex=$net->{bootindex}" if $net->{bootindex} ;
 
+    if($net->{model} eq 'virtio' && $net->{mtu} && $net->{bridge}) {
+
+       my $mtu = $net->{mtu};
+       my $bridge_mtu = PVE::Network::read_bridge_mtu($net->{bridge});
+
+       if($mtu == 1) {
+            $mtu = $bridge_mtu;
+        } else {
+            die "mtu $mtu is bigger than bridge mtu $bridge_mtu" if $mtu > 
$bridge_mtu;
+       }
+       $tmpstr .= ",host_mtu=$mtu";
+    }
+
     if ($use_old_bios_files) {
        my $romfile;
        if ($device eq 'virtio-net-pci') {
-- 
2.20.1

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to