render / rpms / libvirt

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

6d3351
 
6d3351
     

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