]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: don't set interface MTU when managed='no'
authorLaine Stump <laine@redhat.com>
Tue, 12 Jan 2021 19:10:05 +0000 (14:10 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 15 Jan 2021 17:19:57 +0000 (12:19 -0500)
managed='no' on an <interface> allows an unprivileged libvirt to use a
pre-created tap/macvtap device that libvirt has permission to
open/read/write, but no permission to modify (i.e. set the MTU or MAC
address). But when the XML had an <mtu size='blah'/> setting (which
was put there in order to tell the *guest* OS what MTU to set for the
emulated device at the other end of the tap) we were attempting to set
the MTU of the tap device on the host, paying no attention to the
setting of 'managed'. That would of course end in failure.

This patch only sets the MTU if managed='no' is *not* set (so, if it
is 'yes', or just not set at all).

Note that MTU of the tap is also set when connecting the tap to a
bridge device, but managed='no' is only allowed for <interface
type='ethernet'>, which would never attach to a bridge anyway, so we
don't need the check there.

Resolves: https://bugzilla.redhat.com/1905929
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c
src/qemu/qemu_hotplug.c

index 6f970a312896fec215fdddd197ba844f02e72d49..3eff09a9d3e3683a179aa7db7f0eca89e381a75b 100644 (file)
@@ -8149,7 +8149,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
         }
     }
 
-    if (net->mtu &&
+    if (net->mtu && net->managed_tap != VIR_TRISTATE_BOOL_NO &&
         virNetDevSetMTU(net->ifname, net->mtu) < 0)
         goto cleanup;
 
index f336a90c8eb55f74f0e86c19740f0ea6801bd69d..95f2bd0aca8683cce0f456cdd080e149b285810e 100644 (file)
@@ -1387,7 +1387,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
         }
     }
 
-    if (net->mtu &&
+    if (net->mtu && net->managed_tap != VIR_TRISTATE_BOOL_NO &&
         virNetDevSetMTU(net->ifname, net->mtu) < 0)
         goto cleanup;