]> git.proxmox.com Git - qemu-server.git/commitdiff
add virtio host_mtu feature.
authorAlexandre Derumier <aderumier@odiso.com>
Fri, 17 Apr 2020 05:47:20 +0000 (07:47 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 4 Jun 2020 08:58:49 +0000 (10:58 +0200)
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

index c262f4aa1cc47583e1f6dad020d2786b6bdedb98..c47098e9548af8c59da1613ea6af9e7f2c49ebfc 100644 (file)
@@ -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') {