From c2e748f3d928f8030e5c12b474c427086c962ad4 Mon Sep 17 00:00:00 2001
Message-Id:
From: Laine Stump
Date: Tue, 2 May 2017 12:33:11 -0400
Subject: [PATCH] conf: don't ignore for macvtap
interfaces
The parser had been clearing out *all* suggested device names for
type='direct' (aka macvtap) interfaces. All of the code implementing
macvtap allows for a user-specified device name, so we should allow
it. In the case that an interface name starts with "macvtap" or
"macvlan" though, we do still clear it out, just as we do with "vnet"
(which is the prefix used for automatically generated tap device
names), since those are the prefixes for the names we autogenerate for
macvtap and macvlan devices.
Resolves: https://bugzilla.redhat.com/1335798
(cherry picked from commit 9cb891141c4a5a96243c61518c4e0dbcf6a86c24)
Signed-off-by: Jiri Denemark
---
docs/formatdomain.html.in | 6 +++---
src/conf/domain_conf.c | 7 ++++++-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 2dc5e751a..7e55b0327 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5207,9 +5207,9 @@ qemu-kvm -net nic,model=? /dev/null
If no target is specified, certain hypervisors will
automatically generate a name for the created tun device. This
name can be manually specified, however the name should not
- start with either 'vnet' or 'vif', which are prefixes
- reserved by libvirt and certain hypervisors. Manually specified
- targets using these prefixes may be ignored.
+ start with either 'vnet', 'vif', 'macvtap', or 'macvlan',
+ which are prefixes reserved by libvirt and certain hypervisors.
+ Manually specified targets using these prefixes may be ignored.
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7ab5e5051..84a8a94e5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -55,6 +55,7 @@
#include "virtpm.h"
#include "virstring.h"
#include "virnetdev.h"
+#include "virnetdevmacvlan.h"
#include "virhostdev.h"
#include "virmdev.h"
@@ -10016,8 +10017,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
def->data.direct.linkdev = dev;
dev = NULL;
- if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
+ if (ifname &&
+ flags & VIR_DOMAIN_DEF_PARSE_INACTIVE &&
+ (STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) ||
+ STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX))) {
VIR_FREE(ifname);
+ }
break;
--
2.12.2