From: Laine Stump Date: Tue, 15 Dec 2020 19:35:35 +0000 (-0500) Subject: qemu: remove redundant code that adds "template" netdev name X-Git-Tag: v7.0.0-rc1~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9606349172b191caec3ad656e1ce1a93a0e0aab4;p=thirdparty%2Flibvirt.git qemu: remove redundant code that adds "template" netdev name The lower level function virNetDevGenerateName() now understands that a blank ifname should be replaced with a generated name based on a template that it knows about itself - there is no need for the higher level functions to stuff a template name ("vnet%d") into ifname. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index 197c0aa239..be2f53945c 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -455,14 +455,10 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def, goto cleanup; } } else { - if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_VNET_PREFIX) || - strchr(net->ifname, '%')) { - VIR_FREE(net->ifname); - net->ifname = g_strdup(VIR_NET_GENERATED_VNET_PREFIX "%d"); - /* avoid exposing vnet%d in getXMLDesc or error outputs */ + + if (!net->ifname) template_ifname = true; - } + if (virNetDevTapCreate(&net->ifname, tunpath, tapfd, tapfdSize, tap_create_flags) < 0) { goto cleanup; @@ -559,14 +555,8 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, goto cleanup; } - if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_VNET_PREFIX) || - strchr(net->ifname, '%')) { - VIR_FREE(net->ifname); - net->ifname = g_strdup(VIR_NET_GENERATED_VNET_PREFIX "%d"); - /* avoid exposing vnet%d in getXMLDesc or error outputs */ + if (!net->ifname) template_ifname = true; - } if (qemuInterfaceIsVnetCompatModel(net)) tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;