render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From c2e748f3d928f8030e5c12b474c427086c962ad4 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <c2e748f3d928f8030e5c12b474c427086c962ad4@dist-git>
3e5111
From: Laine Stump <laine@laine.org>
3e5111
Date: Tue, 2 May 2017 12:33:11 -0400
3e5111
Subject: [PATCH] conf: don't ignore <target dev='blah'/> for macvtap
3e5111
 interfaces
3e5111
3e5111
The parser had been clearing out *all* suggested device names for
3e5111
type='direct' (aka macvtap) interfaces. All of the code implementing
3e5111
macvtap allows for a user-specified device name, so we should allow
3e5111
it. In the case that an interface name starts with "macvtap" or
3e5111
"macvlan" though, we do still clear it out, just as we do with "vnet"
3e5111
(which is the prefix used for automatically generated tap device
3e5111
names), since those are the prefixes for the names we autogenerate for
3e5111
macvtap and macvlan devices.
3e5111
3e5111
Resolves: https://bugzilla.redhat.com/1335798
3e5111
(cherry picked from commit 9cb891141c4a5a96243c61518c4e0dbcf6a86c24)
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 docs/formatdomain.html.in | 6 +++---
3e5111
 src/conf/domain_conf.c    | 7 ++++++-
3e5111
 2 files changed, 9 insertions(+), 4 deletions(-)
3e5111
3e5111
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
3e5111
index 2dc5e751a..7e55b0327 100644
3e5111
--- a/docs/formatdomain.html.in
3e5111
+++ b/docs/formatdomain.html.in
3e5111
@@ -5207,9 +5207,9 @@ qemu-kvm -net nic,model=? /dev/null
3e5111
       If no target is specified, certain hypervisors will
3e5111
       automatically generate a name for the created tun device. This
3e5111
       name can be manually specified, however the name should not
3e5111
-      start with either 'vnet' or 'vif', which are prefixes
3e5111
-      reserved by libvirt and certain hypervisors. Manually specified
3e5111
-      targets using these prefixes may be ignored.
3e5111
+      start with either 'vnet', 'vif', 'macvtap', or 'macvlan',
3e5111
+      which are prefixes reserved by libvirt and certain hypervisors.
3e5111
+      Manually specified targets using these prefixes may be ignored.
3e5111
     

3e5111
 
3e5111
     

3e5111
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
3e5111
index 7ab5e5051..84a8a94e5 100644
3e5111
--- a/src/conf/domain_conf.c
3e5111
+++ b/src/conf/domain_conf.c
3e5111
@@ -55,6 +55,7 @@
3e5111
 #include "virtpm.h"
3e5111
 #include "virstring.h"
3e5111
 #include "virnetdev.h"
3e5111
+#include "virnetdevmacvlan.h"
3e5111
 #include "virhostdev.h"
3e5111
 #include "virmdev.h"
3e5111
 
3e5111
@@ -10016,8 +10017,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
3e5111
         def->data.direct.linkdev = dev;
3e5111
         dev = NULL;
3e5111
 
3e5111
-        if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
3e5111
+        if (ifname &&
3e5111
+            flags & VIR_DOMAIN_DEF_PARSE_INACTIVE &&
3e5111
+            (STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) ||
3e5111
+             STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX))) {
3e5111
             VIR_FREE(ifname);
3e5111
+        }
3e5111
 
3e5111
         break;
3e5111
 
3e5111
-- 
3e5111
2.12.2
3e5111