|
|
9119d9 |
From 2970e543f7d9446229332966a266103dbdbefdc6 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <2970e543f7d9446229332966a266103dbdbefdc6@dist-git>
|
|
|
9119d9 |
From: Laine Stump <laine@laine.org>
|
|
|
9119d9 |
Date: Mon, 15 Dec 2014 10:51:29 -0500
|
|
|
9119d9 |
Subject: [PATCH] network: store network macTableManager setting in NetDef
|
|
|
9119d9 |
actual object
|
|
|
9119d9 |
|
|
|
9119d9 |
This is part of the fix for:
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1099210
|
|
|
9119d9 |
|
|
|
9119d9 |
At the time that the network driver allocates a connection to a
|
|
|
9119d9 |
network, the tap device that will be used hasn't yet been created -
|
|
|
9119d9 |
that will be done later by qemu (or lxc or whoever) - but if the
|
|
|
9119d9 |
network has macTableManager='libvirt', then when we do get around to
|
|
|
9119d9 |
creating the tap device, we will need to add an entry for it to the
|
|
|
9119d9 |
network bridge's fdb (forwarding database) *and* turn off learning and
|
|
|
9119d9 |
unicast_flood for that tap device in the bridge's sysfs settings. This
|
|
|
9119d9 |
means that qemu needs to know both the bridge name as well as the
|
|
|
9119d9 |
setting of macTableManager, so we either need to create a new API to
|
|
|
9119d9 |
retrieve that info, or just pass it back in the ActualNetDef that is
|
|
|
9119d9 |
created during networkAllocateActualDevice. We choose the latter
|
|
|
9119d9 |
method, since it's already done for the bridge device, and it has the
|
|
|
9119d9 |
side effect of making the information available in domain status.
|
|
|
9119d9 |
|
|
|
9119d9 |
(NB: in the future, I think that the tap device should actually be
|
|
|
9119d9 |
created by networkAllocateActualDevice(), as that will solve several
|
|
|
9119d9 |
other problems, but that is a battle for another day, and this
|
|
|
9119d9 |
information will still be useful outside the network driver)
|
|
|
9119d9 |
|
|
|
9119d9 |
(cherry picked from commit 33f4a8bc038bf05ece1ed42e9bf77fba780d0cb1)
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/conf/domain_conf.c | 30 ++++++++++++++++++++++++++++++
|
|
|
9119d9 |
src/conf/domain_conf.h | 2 ++
|
|
|
9119d9 |
src/libvirt_private.syms | 1 +
|
|
|
9119d9 |
src/network/bridge_driver.c | 6 +++++-
|
|
|
9119d9 |
4 files changed, 38 insertions(+), 1 deletion(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
9119d9 |
index 4cbc431..8c161b5 100644
|
|
|
9119d9 |
--- a/src/conf/domain_conf.c
|
|
|
9119d9 |
+++ b/src/conf/domain_conf.c
|
|
|
9119d9 |
@@ -51,6 +51,7 @@
|
|
|
9119d9 |
#include "netdev_bandwidth_conf.h"
|
|
|
9119d9 |
#include "netdev_vlan_conf.h"
|
|
|
9119d9 |
#include "device_conf.h"
|
|
|
9119d9 |
+#include "network_conf.h"
|
|
|
9119d9 |
#include "virtpm.h"
|
|
|
9119d9 |
#include "virstring.h"
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -6842,6 +6843,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
|
|
9119d9 |
char *mode = NULL;
|
|
|
9119d9 |
char *addrtype = NULL;
|
|
|
9119d9 |
char *trustGuestRxFilters = NULL;
|
|
|
9119d9 |
+ char *macTableManager = NULL;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (VIR_ALLOC(actual) < 0)
|
|
|
9119d9 |
return -1;
|
|
|
9119d9 |
@@ -6958,6 +6960,16 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
actual->data.bridge.brname = brname;
|
|
|
9119d9 |
+ macTableManager = virXPathString("string(./source/@macTableManager)", ctxt);
|
|
|
9119d9 |
+ if (macTableManager &&
|
|
|
9119d9 |
+ (actual->data.bridge.macTableManager
|
|
|
9119d9 |
+ = virNetworkBridgeMACTableManagerTypeFromString(macTableManager)) <= 0) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
9119d9 |
+ _("Invalid macTableManager setting '%s' "
|
|
|
9119d9 |
+ "in domain interface's <actual> element"),
|
|
|
9119d9 |
+ macTableManager);
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
bandwidth_node = virXPathNode("./bandwidth", ctxt);
|
|
|
9119d9 |
@@ -6978,6 +6990,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
|
|
9119d9 |
VIR_FREE(mode);
|
|
|
9119d9 |
VIR_FREE(addrtype);
|
|
|
9119d9 |
VIR_FREE(trustGuestRxFilters);
|
|
|
9119d9 |
+ VIR_FREE(macTableManager);
|
|
|
9119d9 |
virDomainActualNetDefFree(actual);
|
|
|
9119d9 |
|
|
|
9119d9 |
ctxt->node = save_ctxt;
|
|
|
9119d9 |
@@ -16763,12 +16776,18 @@ virDomainActualNetDefContentsFormat(virBufferPtr buf,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
|
|
|
9119d9 |
actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
|
|
9119d9 |
+ int macTableManager = virDomainNetGetActualBridgeMACTableManager(def);
|
|
|
9119d9 |
+
|
|
|
9119d9 |
/* actualType == NETWORK includes the name of the bridge
|
|
|
9119d9 |
* that is used by the network, whether we are
|
|
|
9119d9 |
* "inSubElement" or not.
|
|
|
9119d9 |
*/
|
|
|
9119d9 |
virBufferEscapeString(buf, " bridge='%s'",
|
|
|
9119d9 |
virDomainNetGetActualBridgeName(def));
|
|
|
9119d9 |
+ if (macTableManager) {
|
|
|
9119d9 |
+ virBufferAsprintf(buf, " macTableManager='%s'",
|
|
|
9119d9 |
+ virNetworkBridgeMACTableManagerTypeToString(macTableManager));
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
} else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) {
|
|
|
9119d9 |
const char *mode;
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -20384,6 +20403,17 @@ virDomainNetGetActualBridgeName(virDomainNetDefPtr iface)
|
|
|
9119d9 |
return NULL;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
+int
|
|
|
9119d9 |
+virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface)
|
|
|
9119d9 |
+{
|
|
|
9119d9 |
+ if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
|
|
|
9119d9 |
+ iface->data.network.actual &&
|
|
|
9119d9 |
+ (iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
|
|
|
9119d9 |
+ iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_NETWORK))
|
|
|
9119d9 |
+ return iface->data.network.actual->data.bridge.macTableManager;
|
|
|
9119d9 |
+ return 0;
|
|
|
9119d9 |
+}
|
|
|
9119d9 |
+
|
|
|
9119d9 |
const char *
|
|
|
9119d9 |
virDomainNetGetActualDirectDev(virDomainNetDefPtr iface)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
|
|
9119d9 |
index 01d5aeb..b912845 100644
|
|
|
9119d9 |
--- a/src/conf/domain_conf.h
|
|
|
9119d9 |
+++ b/src/conf/domain_conf.h
|
|
|
9119d9 |
@@ -874,6 +874,7 @@ struct _virDomainActualNetDef {
|
|
|
9119d9 |
union {
|
|
|
9119d9 |
struct {
|
|
|
9119d9 |
char *brname;
|
|
|
9119d9 |
+ int macTableManager; /* enum virNetworkBridgeMACTableManagerType */
|
|
|
9119d9 |
} bridge;
|
|
|
9119d9 |
struct {
|
|
|
9119d9 |
char *linkdev;
|
|
|
9119d9 |
@@ -2496,6 +2497,7 @@ int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
|
|
|
9119d9 |
|
|
|
9119d9 |
int virDomainNetGetActualType(virDomainNetDefPtr iface);
|
|
|
9119d9 |
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
|
|
|
9119d9 |
+int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
|
|
|
9119d9 |
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
|
|
|
9119d9 |
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
|
|
|
9119d9 |
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
|
|
|
9119d9 |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
9119d9 |
index e4da444..cf3c842 100644
|
|
|
9119d9 |
--- a/src/libvirt_private.syms
|
|
|
9119d9 |
+++ b/src/libvirt_private.syms
|
|
|
9119d9 |
@@ -326,6 +326,7 @@ virDomainNetFind;
|
|
|
9119d9 |
virDomainNetFindIdx;
|
|
|
9119d9 |
virDomainNetGenerateMAC;
|
|
|
9119d9 |
virDomainNetGetActualBandwidth;
|
|
|
9119d9 |
+virDomainNetGetActualBridgeMACTableManager;
|
|
|
9119d9 |
virDomainNetGetActualBridgeName;
|
|
|
9119d9 |
virDomainNetGetActualDirectDev;
|
|
|
9119d9 |
virDomainNetGetActualDirectMode;
|
|
|
9119d9 |
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
|
|
|
9119d9 |
index 236095f..361029f 100644
|
|
|
9119d9 |
--- a/src/network/bridge_driver.c
|
|
|
9119d9 |
+++ b/src/network/bridge_driver.c
|
|
|
9119d9 |
@@ -3833,7 +3833,7 @@ networkAllocateActualDevice(virDomainDefPtr dom,
|
|
|
9119d9 |
*/
|
|
|
9119d9 |
iface->data.network.actual->type = VIR_DOMAIN_NET_TYPE_NETWORK;
|
|
|
9119d9 |
|
|
|
9119d9 |
- /* we also store the bridge device
|
|
|
9119d9 |
+ /* we also store the bridge device and macTableManager settings
|
|
|
9119d9 |
* in iface->data.network.actual->data.bridge for later use
|
|
|
9119d9 |
* after the domain's tap device is created (to attach to the
|
|
|
9119d9 |
* bridge and set flood/learning mode on the tap device)
|
|
|
9119d9 |
@@ -3841,6 +3841,8 @@ networkAllocateActualDevice(virDomainDefPtr dom,
|
|
|
9119d9 |
if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
|
|
|
9119d9 |
netdef->bridge) < 0)
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
+ iface->data.network.actual->data.bridge.macTableManager
|
|
|
9119d9 |
+ = netdef->macTableManager;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (networkPlugBandwidth(network, iface) < 0)
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
@@ -3856,6 +3858,8 @@ networkAllocateActualDevice(virDomainDefPtr dom,
|
|
|
9119d9 |
if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
|
|
|
9119d9 |
netdef->bridge) < 0)
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
+ iface->data.network.actual->data.bridge.macTableManager
|
|
|
9119d9 |
+ = netdef->macTableManager;
|
|
|
9119d9 |
|
|
|
9119d9 |
/* merge virtualports from interface, network, and portgroup to
|
|
|
9119d9 |
* arrive at actual virtualport to use
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.0
|
|
|
9119d9 |
|