qemu: don't set interface MTU when managed='no'

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>
This commit is contained in:
Laine Stump 2021-01-12 14:10:05 -05:00
parent b724b7d197
commit 3bb87556b8
2 changed files with 2 additions and 2 deletions

View 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;

View 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;