mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
network: store network macTableManager setting in NetDef actual object
At the time that the network driver allocates a connection to a network, the tap device that will be used hasn't yet been created - that will be done later by qemu (or lxc or whoever) - but if the network has macTableManager='libvirt', then when we do get around to creating the tap device, we will need to add an entry for it to the network bridge's fdb (forwarding database) *and* turn off learning and unicast_flood for that tap device in the bridge's sysfs settings. This means that qemu needs to know both the bridge name as well as the setting of macTableManager, so we either need to create a new API to retrieve that info, or just pass it back in the ActualNetDef that is created during networkAllocateActualDevice. We choose the latter method, since it's already done for the bridge device, and it has the side effect of making the information available in domain status. (NB: in the future, I think that the tap device should actually be created by networkAllocateActualDevice(), as that will solve several other problems, but that is a battle for another day, and this information will still be useful outside the network driver)
This commit is contained in:
parent
a360912179
commit
33f4a8bc03
@ -51,6 +51,7 @@
|
|||||||
#include "netdev_bandwidth_conf.h"
|
#include "netdev_bandwidth_conf.h"
|
||||||
#include "netdev_vlan_conf.h"
|
#include "netdev_vlan_conf.h"
|
||||||
#include "device_conf.h"
|
#include "device_conf.h"
|
||||||
|
#include "network_conf.h"
|
||||||
#include "virtpm.h"
|
#include "virtpm.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
|
|
||||||
@ -7003,6 +7004,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
|||||||
char *mode = NULL;
|
char *mode = NULL;
|
||||||
char *addrtype = NULL;
|
char *addrtype = NULL;
|
||||||
char *trustGuestRxFilters = NULL;
|
char *trustGuestRxFilters = NULL;
|
||||||
|
char *macTableManager = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(actual) < 0)
|
if (VIR_ALLOC(actual) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -7119,6 +7121,16 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
actual->data.bridge.brname = brname;
|
actual->data.bridge.brname = brname;
|
||||||
|
macTableManager = virXPathString("string(./source/@macTableManager)", ctxt);
|
||||||
|
if (macTableManager &&
|
||||||
|
(actual->data.bridge.macTableManager
|
||||||
|
= virNetworkBridgeMACTableManagerTypeFromString(macTableManager)) <= 0) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("Invalid macTableManager setting '%s' "
|
||||||
|
"in domain interface's <actual> element"),
|
||||||
|
macTableManager);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bandwidth_node = virXPathNode("./bandwidth", ctxt);
|
bandwidth_node = virXPathNode("./bandwidth", ctxt);
|
||||||
@ -7139,6 +7151,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
|||||||
VIR_FREE(mode);
|
VIR_FREE(mode);
|
||||||
VIR_FREE(addrtype);
|
VIR_FREE(addrtype);
|
||||||
VIR_FREE(trustGuestRxFilters);
|
VIR_FREE(trustGuestRxFilters);
|
||||||
|
VIR_FREE(macTableManager);
|
||||||
virDomainActualNetDefFree(actual);
|
virDomainActualNetDefFree(actual);
|
||||||
|
|
||||||
ctxt->node = save_ctxt;
|
ctxt->node = save_ctxt;
|
||||||
@ -17156,12 +17169,18 @@ virDomainActualNetDefContentsFormat(virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
|
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
|
||||||
actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
||||||
|
int macTableManager = virDomainNetGetActualBridgeMACTableManager(def);
|
||||||
|
|
||||||
/* actualType == NETWORK includes the name of the bridge
|
/* actualType == NETWORK includes the name of the bridge
|
||||||
* that is used by the network, whether we are
|
* that is used by the network, whether we are
|
||||||
* "inSubElement" or not.
|
* "inSubElement" or not.
|
||||||
*/
|
*/
|
||||||
virBufferEscapeString(buf, " bridge='%s'",
|
virBufferEscapeString(buf, " bridge='%s'",
|
||||||
virDomainNetGetActualBridgeName(def));
|
virDomainNetGetActualBridgeName(def));
|
||||||
|
if (macTableManager) {
|
||||||
|
virBufferAsprintf(buf, " macTableManager='%s'",
|
||||||
|
virNetworkBridgeMACTableManagerTypeToString(macTableManager));
|
||||||
|
}
|
||||||
} else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) {
|
} else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) {
|
||||||
const char *mode;
|
const char *mode;
|
||||||
|
|
||||||
@ -20760,6 +20779,17 @@ virDomainNetGetActualBridgeName(virDomainNetDefPtr iface)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface)
|
||||||
|
{
|
||||||
|
if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
|
||||||
|
iface->data.network.actual &&
|
||||||
|
(iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
|
||||||
|
iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_NETWORK))
|
||||||
|
return iface->data.network.actual->data.bridge.macTableManager;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
virDomainNetGetActualDirectDev(virDomainNetDefPtr iface)
|
virDomainNetGetActualDirectDev(virDomainNetDefPtr iface)
|
||||||
{
|
{
|
||||||
|
@ -888,6 +888,7 @@ struct _virDomainActualNetDef {
|
|||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
char *brname;
|
char *brname;
|
||||||
|
int macTableManager; /* enum virNetworkBridgeMACTableManagerType */
|
||||||
} bridge;
|
} bridge;
|
||||||
struct {
|
struct {
|
||||||
char *linkdev;
|
char *linkdev;
|
||||||
@ -2540,6 +2541,7 @@ int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
|
|||||||
|
|
||||||
int virDomainNetGetActualType(virDomainNetDefPtr iface);
|
int virDomainNetGetActualType(virDomainNetDefPtr iface);
|
||||||
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
|
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
|
||||||
|
int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
|
||||||
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
|
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
|
||||||
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
|
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
|
||||||
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
|
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
|
||||||
|
@ -328,6 +328,7 @@ virDomainNetFind;
|
|||||||
virDomainNetFindIdx;
|
virDomainNetFindIdx;
|
||||||
virDomainNetGenerateMAC;
|
virDomainNetGenerateMAC;
|
||||||
virDomainNetGetActualBandwidth;
|
virDomainNetGetActualBandwidth;
|
||||||
|
virDomainNetGetActualBridgeMACTableManager;
|
||||||
virDomainNetGetActualBridgeName;
|
virDomainNetGetActualBridgeName;
|
||||||
virDomainNetGetActualDirectDev;
|
virDomainNetGetActualDirectDev;
|
||||||
virDomainNetGetActualDirectMode;
|
virDomainNetGetActualDirectMode;
|
||||||
|
@ -3795,7 +3795,7 @@ networkAllocateActualDevice(virDomainDefPtr dom,
|
|||||||
*/
|
*/
|
||||||
iface->data.network.actual->type = VIR_DOMAIN_NET_TYPE_NETWORK;
|
iface->data.network.actual->type = VIR_DOMAIN_NET_TYPE_NETWORK;
|
||||||
|
|
||||||
/* we also store the bridge device
|
/* we also store the bridge device and macTableManager settings
|
||||||
* in iface->data.network.actual->data.bridge for later use
|
* in iface->data.network.actual->data.bridge for later use
|
||||||
* after the domain's tap device is created (to attach to the
|
* after the domain's tap device is created (to attach to the
|
||||||
* bridge and set flood/learning mode on the tap device)
|
* bridge and set flood/learning mode on the tap device)
|
||||||
@ -3803,6 +3803,8 @@ networkAllocateActualDevice(virDomainDefPtr dom,
|
|||||||
if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
|
if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
|
||||||
netdef->bridge) < 0)
|
netdef->bridge) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
iface->data.network.actual->data.bridge.macTableManager
|
||||||
|
= netdef->macTableManager;
|
||||||
|
|
||||||
if (networkPlugBandwidth(network, iface) < 0)
|
if (networkPlugBandwidth(network, iface) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -3818,6 +3820,8 @@ networkAllocateActualDevice(virDomainDefPtr dom,
|
|||||||
if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
|
if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
|
||||||
netdef->bridge) < 0)
|
netdef->bridge) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
iface->data.network.actual->data.bridge.macTableManager
|
||||||
|
= netdef->macTableManager;
|
||||||
|
|
||||||
/* merge virtualports from interface, network, and portgroup to
|
/* merge virtualports from interface, network, and portgroup to
|
||||||
* arrive at actual virtualport to use
|
* arrive at actual virtualport to use
|
||||||
|
Loading…
Reference in New Issue
Block a user