]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: simplify virNetDevMacVLanCreateWithVPortProfile()
authorLaine Stump <laine@redhat.com>
Tue, 15 Dec 2020 19:50:40 +0000 (14:50 -0500)
committerLaine Stump <laine@redhat.com>
Thu, 17 Dec 2020 02:32:01 +0000 (21:32 -0500)
commitb36569ec774ce363aed0549753887851a96ab174
treee9fa15391b0c8e994d8c1c25dfd9670446314076
parent9606349172b191caec3ad656e1ce1a93a0e0aab4
util: simplify virNetDevMacVLanCreateWithVPortProfile()

Since commit 282d135ddbb the parser for <interface> has cleared out
any interface name from the input XML that used the macvtap/macvlan
name as a prefix. Along with that, the switch to use the new
virNetDevGenerateName() function for auto-generating macvtap/macvlan
device names (commit 9b5d741a9), has realized two facts:

1) virNetDevGenerateName() can be called with a name already filled
   in, and in that case it is an effective NOP.

2) because virNetDevGenerate() will always find an unused name, there
   is no need to retry device creation in a loop - if it fails the
   first time, it would fail any subsequent time as well.

that, combined with the aforementioned parser change allow us to
simplify virNetDevMacVLanCreateWithVPortProfile() - we no longer need
any extra code to determine if a template "AutoName" was requested,
and don't need a separate code path for creating the device in the
case that a specific name was given in the XML - all we need to do is
log any requested name, and then call exactly the same code as we
would if no name was given.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdevmacvlan.c