Libvirt bases its decision about whether to apply the vnet_hdr flag to the tap interface on whether or not the selected model is VirtIO. Originally, VirtIO was the only model to support the vnet_hdr in QEMU; however, the e1000e & vmxnet3 adapters also support it(seemingly from introduction based on commits). This passes the whole packet to the host, reducing emulation overhead and improving performance. Signed-off-by: Patrick Magauran <patmagauran.j@xxxxxxxxx> --- src/conf/domain_conf.c | 8 +++++++- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/qemu/qemu_interface.c | 8 ++++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 69e0439e7e..cb184110f7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30981,7 +30981,13 @@ virDomainNetIsVirtioModel(const virDomainNetDef *net) net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL || net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL); } - +bool +virDomainNetIsVnetCompatModel(const virDomainNetDef *net) +{ + return (virDomainNetIsVirtioModel(net) || + net->model == VIR_DOMAIN_NET_MODEL_E1000E || + net->model == VIR_DOMAIN_NET_MODEL_VMXNET3); +} /* Return listens[i] from the appropriate union for the graphics * type, or NULL if this is an unsuitable type, or the index is out of diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 011bf66cb4..cbc46fdf78 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3371,6 +3371,7 @@ const char *virDomainNetGetModelString(const virDomainNetDef *net); int virDomainNetSetModelString(virDomainNetDefPtr et, const char *model); bool virDomainNetIsVirtioModel(const virDomainNetDef *net); +bool virDomainNetIsVnetCompatModel(const virDomainNetDef *net); int virDomainNetAppendIPAddress(virDomainNetDefPtr def, const char *address, int family, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 01c2e710cd..2b64042dd2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -525,6 +525,7 @@ virDomainNetGetActualVlan; virDomainNetGetModelString; virDomainNetInsert; virDomainNetIsVirtioModel; +virDomainNetIsVnetCompatModel; virDomainNetModelTypeFromString; virDomainNetModelTypeToString; virDomainNetNotifyActualDevice; diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index ffec992596..8397ed8645 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -255,7 +255,7 @@ qemuInterfaceDirectConnect(virDomainDefPtr def, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); unsigned int macvlan_create_flags = VIR_NETDEV_MACVLAN_CREATE_WITH_TAP; - if (virDomainNetIsVirtioModel(net)) + if (virDomainNetIsVnetCompatModel(net)) macvlan_create_flags |= VIR_NETDEV_MACVLAN_VNET_HDR; if (virNetDevMacVLanCreateWithVPortProfile(net->ifname, @@ -417,7 +417,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def, } } - if (virDomainNetIsVirtioModel(net)) + if (virDomainNetIsVnetCompatModel(net)) tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR; if (net->managed_tap == VIR_TRISTATE_BOOL_NO) { @@ -436,7 +436,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def, if (virNetDevMacVLanTapOpen(net->ifname, tapfd, tapfdSize) < 0) goto cleanup; if (virNetDevMacVLanTapSetup(tapfd, tapfdSize, - virDomainNetIsVirtioModel(net)) < 0) { + virDomainNetIsVnetCompatModel(net)) < 0) { goto cleanup; } } else { @@ -559,7 +559,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, template_ifname = true; } - if (virDomainNetIsVirtioModel(net)) + if (virDomainNetIsVnetCompatModel(net)) tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR; if (driver->privileged) { -- 2.26.2