qemu: Add e1000e/vmxnet3 IFF_VNET_HDR support

Setting IFF_VNET_HDR for a tap device passes the whole packet to the
host, reducing emulation overhead and improving performance.

Libvirt bases its decision about applying IFF_VNET_HDR to the tap
interface on whether or not the model of the emulated network device
is virtio.  Originally, virtio was the only model to support
IFF_VNET_HDR in QEMU; however, the e1000e & vmxnet3 adapters have also
supported it since their introductions - QEMU commit
786fd2b0f87 for vmxnet3, and QEMU commit 6f3fbe4ed0 for e1000e, so it
should be set for those models too.

Signed-off-by: Patrick Magauran <patmagauran.j@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Patrick Magauran 2020-08-08 09:59:13 -04:00 committed by Laine Stump
parent 234a0ea306
commit 69e3381626
1 changed files with 13 additions and 4 deletions

View File

@ -231,6 +231,15 @@ qemuInterfaceStopDevices(virDomainDefPtr def)
}
static bool
qemuInterfaceIsVnetCompatModel(const virDomainNetDef *net)
{
return (virDomainNetIsVirtioModel(net) ||
net->model == VIR_DOMAIN_NET_MODEL_E1000E ||
net->model == VIR_DOMAIN_NET_MODEL_VMXNET3);
}
/**
* qemuInterfaceDirectConnect:
* @def: the definition of the VM (needed by 802.1Qbh and audit)
@ -255,7 +264,7 @@ qemuInterfaceDirectConnect(virDomainDefPtr def,
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
unsigned int macvlan_create_flags = VIR_NETDEV_MACVLAN_CREATE_WITH_TAP;
if (virDomainNetIsVirtioModel(net))
if (qemuInterfaceIsVnetCompatModel(net))
macvlan_create_flags |= VIR_NETDEV_MACVLAN_VNET_HDR;
if (virNetDevMacVLanCreateWithVPortProfile(net->ifname,
@ -417,7 +426,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
}
}
if (virDomainNetIsVirtioModel(net))
if (qemuInterfaceIsVnetCompatModel(net))
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
if (net->managed_tap == VIR_TRISTATE_BOOL_NO) {
@ -436,7 +445,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
if (virNetDevMacVLanTapOpen(net->ifname, tapfd, tapfdSize) < 0)
goto cleanup;
if (virNetDevMacVLanTapSetup(tapfd, tapfdSize,
virDomainNetIsVirtioModel(net)) < 0) {
qemuInterfaceIsVnetCompatModel(net)) < 0) {
goto cleanup;
}
} else {
@ -559,7 +568,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
template_ifname = true;
}
if (virDomainNetIsVirtioModel(net))
if (qemuInterfaceIsVnetCompatModel(net))
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
if (driver->privileged) {