The attributes of a <network> element's <forward> element were
previously stored directly in the virNetworkDef object, but
virNetworkUpdateForward() needs to operate on a <forward> in
isolation, so this patchs pulls out all those attributes into a
separate virNetworkForwardDef struct (and shortens their names
appropriately). This new object is contained in the virNetworkDef, not
pointed to by it, so there is no extra memory management.
This patch makes no functional changes, it only changes, e.g.,
"nForwardIfs" to "forward.nifs".
---
src/conf/network_conf.c | 148 ++++++++++++++++-----------------
src/conf/network_conf.h | 34 ++++----
src/esx/esx_network_driver.c | 30 +++----
src/network/bridge_driver.c | 192 +++++++++++++++++++++----------------------
src/vbox/vbox_tmpl.c | 4 +-
5 files changed, 207 insertions(+), 201 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 1bdf33a..64b0557 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -187,15 +187,15 @@ void virNetworkDefFree(virNetworkDefPtr def)
VIR_FREE(def->bridge);
VIR_FREE(def->domain);
- for (ii = 0 ; ii < def->nForwardPfs && def->forwardPfs ; ii++) {
- virNetworkForwardPfDefClear(&def->forwardPfs[ii]);
+ for (ii = 0 ; ii < def->forward.npfs && def->forward.pfs ; ii++) {
+ virNetworkForwardPfDefClear(&def->forward.pfs[ii]);
}
- VIR_FREE(def->forwardPfs);
+ VIR_FREE(def->forward.pfs);
- for (ii = 0 ; ii < def->nForwardIfs && def->forwardIfs ; ii++) {
- virNetworkForwardIfDefClear(&def->forwardIfs[ii]);
+ for (ii = 0 ; ii < def->forward.nifs && def->forward.ifs ; ii++) {
+ virNetworkForwardIfDefClear(&def->forward.ifs[ii]);
}
- VIR_FREE(def->forwardIfs);
+ VIR_FREE(def->forward.ifs);
for (ii = 0 ; ii < def->nips && def->ips ; ii++) {
virNetworkIpDefClear(&def->ips[ii]);
@@ -1438,13 +1438,13 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
forwardNode = virXPathNode("./forward", ctxt);
if (!forwardNode) {
- def->forwardType = VIR_NETWORK_FORWARD_NONE;
+ def->forward.type = VIR_NETWORK_FORWARD_NONE;
def->stp = (stp && STREQ(stp, "off")) ? 0 : 1;
} else {
ctxt->node = forwardNode;
tmp = virXPathString("string(./@mode)", ctxt);
if (tmp) {
- if ((def->forwardType = virNetworkForwardTypeFromString(tmp)) < 0) {
+ if ((def->forward.type = virNetworkForwardTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown forwarding type '%s'"),
tmp);
VIR_FREE(tmp);
@@ -1452,14 +1452,14 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
}
VIR_FREE(tmp);
} else {
- def->forwardType = VIR_NETWORK_FORWARD_NAT;
+ def->forward.type = VIR_NETWORK_FORWARD_NAT;
}
forwardDev = virXPathString("string(./@dev)", ctxt);
forwardManaged = virXPathString("string(./@managed)", ctxt);
if (forwardManaged != NULL) {
if (STRCASEEQ(forwardManaged, "yes"))
- def->managed = 1;
+ def->forward.managed = true;
}
/* all of these modes can use a pool of physical interfaces */
@@ -1486,7 +1486,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
}
if (nForwardPfs == 1) {
- if (VIR_ALLOC_N(def->forwardPfs, nForwardPfs) < 0) {
+ if (VIR_ALLOC_N(def->forward.pfs, nForwardPfs) < 0) {
virReportOOMError();
goto error;
}
@@ -1505,9 +1505,9 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
goto error;
}
- def->forwardPfs->dev = forwardDev;
+ def->forward.pfs->dev = forwardDev;
forwardDev = NULL;
- def->nForwardPfs++;
+ def->forward.npfs++;
} else if (nForwardPfs > 1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Use of more than one physical interface is not
allowed"));
@@ -1516,7 +1516,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
if (nForwardAddrs > 0) {
int ii;
- if (VIR_ALLOC_N(def->forwardIfs, nForwardAddrs) < 0) {
+ if (VIR_ALLOC_N(def->forward.ifs, nForwardAddrs) < 0) {
virReportOOMError();
goto error;
}
@@ -1531,7 +1531,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
type = virXMLPropString(forwardAddrNodes[ii], "type");
if (type) {
- if ((def->forwardIfs[ii].type =
virNetworkForwardHostdevDeviceTypeFromString(type)) < 0) {
+ if ((def->forward.ifs[ii].type =
virNetworkForwardHostdevDeviceTypeFromString(type)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown address type '%s'"),
type);
goto error;
@@ -1542,9 +1542,9 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
goto error;
}
- switch (def->forwardIfs[ii].type) {
+ switch (def->forward.ifs[ii].type) {
case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI:
- if (virDevicePCIAddressParseXML(forwardAddrNodes[ii],
&(def->forwardIfs[ii].device.pci)) < 0)
+ if (virDevicePCIAddressParseXML(forwardAddrNodes[ii],
&(def->forward.ifs[ii].device.pci)) < 0)
goto error;
break;
@@ -1556,23 +1556,23 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
goto error;
}
VIR_FREE(type);
- def->nForwardIfs++;
+ def->forward.nifs++;
}
}
else if (nForwardIfs > 0 || forwardDev) {
int ii;
/* allocate array to hold all the portgroups */
- if (VIR_ALLOC_N(def->forwardIfs, MAX(nForwardIfs, 1)) < 0) {
+ if (VIR_ALLOC_N(def->forward.ifs, MAX(nForwardIfs, 1)) < 0) {
virReportOOMError();
goto error;
}
if (forwardDev) {
- def->forwardIfs[0].device.dev = forwardDev;
- def->forwardIfs[0].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
+ def->forward.ifs[0].device.dev = forwardDev;
+ def->forward.ifs[0].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
forwardDev = NULL;
- def->nForwardIfs++;
+ def->forward.nifs++;
}
/* parse each forwardIf */
@@ -1585,13 +1585,13 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
goto error;
}
- if ((ii == 0) && (def->nForwardIfs == 1)) {
+ if ((ii == 0) && (def->forward.nifs == 1)) {
/* both forwardDev and an interface element are present.
* If they don't match, it's an error. */
- if (STRNEQ(forwardDev, def->forwardIfs[0].device.dev)) {
+ if (STRNEQ(forwardDev, def->forward.ifs[0].device.dev)) {
virReportError(VIR_ERR_XML_ERROR,
_("forward dev '%s' must match first
interface element dev '%s' in network '%s'"),
- def->forwardIfs[0].device.dev,
+ def->forward.ifs[0].device.dev,
forwardDev, def->name);
goto error;
}
@@ -1599,10 +1599,10 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
continue;
}
- def->forwardIfs[ii].device.dev = forwardDev;
+ def->forward.ifs[ii].device.dev = forwardDev;
forwardDev = NULL;
- def->forwardIfs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
- def->nForwardIfs++;
+ def->forward.ifs[ii].type =
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
+ def->forward.nifs++;
}
}
VIR_FREE(type);
@@ -1611,7 +1611,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
VIR_FREE(forwardPfNodes);
VIR_FREE(forwardIfNodes);
VIR_FREE(forwardAddrNodes);
- switch (def->forwardType) {
+ switch (def->forward.type) {
case VIR_NETWORK_FORWARD_ROUTE:
case VIR_NETWORK_FORWARD_NAT:
/* It's pointless to specify L3 forwarding without specifying
@@ -1620,11 +1620,11 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
if (def->nips == 0) {
virReportError(VIR_ERR_XML_ERROR,
_("%s forwarding requested, but no IP address
provided for network '%s'"),
- virNetworkForwardTypeToString(def->forwardType),
+ virNetworkForwardTypeToString(def->forward.type),
def->name);
goto error;
}
- if (def->nForwardIfs > 1) {
+ if (def->forward.nifs > 1) {
virReportError(VIR_ERR_XML_ERROR,
_("multiple forwarding interfaces specified for
network '%s', only one is supported"),
def->name);
@@ -1639,7 +1639,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
if (def->bridge) {
virReportError(VIR_ERR_XML_ERROR,
_("bridge name not allowed in %s mode (network
'%s')"),
- virNetworkForwardTypeToString(def->forwardType),
+ virNetworkForwardTypeToString(def->forward.type),
def->name);
goto error;
}
@@ -1648,16 +1648,16 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
if (def->delay || stp) {
virReportError(VIR_ERR_XML_ERROR,
_("bridge delay/stp options only allowed in route,
nat, and isolated mode, not in %s (network '%s')"),
- virNetworkForwardTypeToString(def->forwardType),
+ virNetworkForwardTypeToString(def->forward.type),
def->name);
goto error;
}
- if (def->bridge && (def->nForwardIfs || nForwardPfs)) {
+ if (def->bridge && (def->forward.nifs || def->forward.npfs))
{
virReportError(VIR_ERR_XML_ERROR,
_("A network with forward mode='%s' can
specify "
"a bridge name or a forward dev, but not "
"both (network '%s')"),
- virNetworkForwardTypeToString(def->forwardType),
+ virNetworkForwardTypeToString(def->forward.type),
def->name);
goto error;
}
@@ -1934,53 +1934,53 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int
flags)
virUUIDFormat(uuid, uuidstr);
virBufferAsprintf(&buf, "<uuid>%s</uuid>\n", uuidstr);
- if (def->forwardType != VIR_NETWORK_FORWARD_NONE) {
+ if (def->forward.type != VIR_NETWORK_FORWARD_NONE) {
const char *dev = NULL;
- if (!def->nForwardPfs)
+ if (!def->forward.npfs)
dev = virNetworkDefForwardIf(def, 0);
- const char *mode = virNetworkForwardTypeToString(def->forwardType);
+ const char *mode = virNetworkForwardTypeToString(def->forward.type);
if (!mode) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown forward type %d in network
'%s'"),
- def->forwardType, def->name);
+ def->forward.type, def->name);
goto error;
}
virBufferAddLit(&buf, "<forward");
virBufferEscapeString(&buf, " dev='%s'", dev);
virBufferAsprintf(&buf, " mode='%s'", mode);
- if (def->forwardType == VIR_NETWORK_FORWARD_HOSTDEV) {
- if (def->managed == 1)
+ if (def->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
+ if (def->forward.managed)
virBufferAddLit(&buf, " managed='yes'");
else
virBufferAddLit(&buf, " managed='no'");
}
virBufferAsprintf(&buf, "%s>\n",
- (def->nForwardIfs || def->nForwardPfs) ? "" :
"/");
+ (def->forward.nifs || def->forward.npfs) ? "" :
"/");
virBufferAdjustIndent(&buf, 2);
- /* For now, hard-coded to at most 1 forwardPfs */
- if (def->nForwardPfs)
+ /* For now, hard-coded to at most 1 forward.pfs */
+ if (def->forward.npfs)
virBufferEscapeString(&buf, "<pf dev='%s'/>\n",
- def->forwardPfs[0].dev);
+ def->forward.pfs[0].dev);
- if (def->nForwardIfs &&
- (!def->nForwardPfs || !(flags & VIR_NETWORK_XML_INACTIVE))) {
- for (ii = 0; ii < def->nForwardIfs; ii++) {
- if (def->forwardType != VIR_NETWORK_FORWARD_HOSTDEV) {
+ if (def->forward.nifs &&
+ (!def->forward.npfs || !(flags & VIR_NETWORK_XML_INACTIVE))) {
+ for (ii = 0; ii < def->forward.nifs; ii++) {
+ if (def->forward.type != VIR_NETWORK_FORWARD_HOSTDEV) {
virBufferEscapeString(&buf, "<interface
dev='%s'",
- def->forwardIfs[ii].device.dev);
+ def->forward.ifs[ii].device.dev);
if (!(flags & VIR_NETWORK_XML_INACTIVE) &&
- (def->forwardIfs[ii].connections > 0)) {
+ (def->forward.ifs[ii].connections > 0)) {
virBufferAsprintf(&buf, "
connections='%d'",
- def->forwardIfs[ii].connections);
+ def->forward.ifs[ii].connections);
}
virBufferAddLit(&buf, "/>\n");
}
else {
- if (def->forwardIfs[ii].type ==
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI) {
+ if (def->forward.ifs[ii].type ==
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI) {
if (virDevicePCIAddressFormat(&buf,
- def->forwardIfs[ii].device.pci,
+
def->forward.ifs[ii].device.pci,
true) < 0)
goto error;
}
@@ -1988,13 +1988,13 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int
flags)
}
}
virBufferAdjustIndent(&buf, -2);
- if (def->nForwardPfs || def->nForwardIfs)
+ if (def->forward.npfs || def->forward.nifs)
virBufferAddLit(&buf, "</forward>\n");
}
- if (def->forwardType == VIR_NETWORK_FORWARD_NONE ||
- def->forwardType == VIR_NETWORK_FORWARD_NAT ||
- def->forwardType == VIR_NETWORK_FORWARD_ROUTE) {
+ if (def->forward.type == VIR_NETWORK_FORWARD_NONE ||
+ def->forward.type == VIR_NETWORK_FORWARD_NAT ||
+ def->forward.type == VIR_NETWORK_FORWARD_ROUTE) {
virBufferAddLit(&buf, "<bridge");
if (def->bridge)
@@ -2002,7 +2002,7 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int
flags)
virBufferAsprintf(&buf, " stp='%s' delay='%ld'
/>\n",
def->stp ? "on" : "off",
def->delay);
- } else if (def->forwardType == VIR_NETWORK_FORWARD_BRIDGE &&
+ } else if (def->forward.type == VIR_NETWORK_FORWARD_BRIDGE &&
def->bridge) {
virBufferEscapeString(&buf, "<bridge name='%s' />\n",
def->bridge);
}
@@ -2162,9 +2162,9 @@ virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets,
goto error;
}
- if (def->forwardType == VIR_NETWORK_FORWARD_NONE ||
- def->forwardType == VIR_NETWORK_FORWARD_NAT ||
- def->forwardType == VIR_NETWORK_FORWARD_ROUTE) {
+ if (def->forward.type == VIR_NETWORK_FORWARD_NONE ||
+ def->forward.type == VIR_NETWORK_FORWARD_NAT ||
+ def->forward.type == VIR_NETWORK_FORWARD_ROUTE) {
/* Generate a bridge if none is specified, but don't check for collisions
* if a bridge is hardcoded, so the network is at least defined.
@@ -2734,17 +2734,17 @@ virNetworkDefUpdateForwardInterface(virNetworkDefPtr def,
}
/* check if an <interface> with same dev name already exists */
- for (ii = 0; ii < def->nForwardIfs; ii++) {
- if (def->forwardIfs[ii].type
+ for (ii = 0; ii < def->forward.nifs; ii++) {
+ if (def->forward.ifs[ii].type
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV &&
- STREQ(iface.device.dev, def->forwardIfs[ii].device.dev))
+ STREQ(iface.device.dev, def->forward.ifs[ii].device.dev))
break;
}
if ((command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST) ||
(command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) {
- if (ii < def->nForwardIfs) {
+ if (ii < def->forward.nifs) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("there is an existing interface entry "
"in network '%s' that matches "
@@ -2754,17 +2754,17 @@ virNetworkDefUpdateForwardInterface(virNetworkDefPtr def,
}
/* add to beginning/end of list */
- if (VIR_INSERT_ELEMENT(def->forwardIfs,
+ if (VIR_INSERT_ELEMENT(def->forward.ifs,
command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
- ? 0 : def->nForwardIfs,
- def->nForwardIfs, &iface) < 0) {
+ ? 0 : def->forward.nifs,
+ def->forward.nifs, &iface) < 0) {
virReportOOMError();
goto cleanup;
}
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
- if (ii == def->nForwardIfs) {
+ if (ii == def->forward.nifs) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("couldn't find an interface entry "
"in network '%s' matching <interface
dev='%s'>"),
@@ -2773,19 +2773,19 @@ virNetworkDefUpdateForwardInterface(virNetworkDefPtr def,
}
/* fail if the interface is being used */
- if (def->forwardIfs[ii].connections > 0) {
+ if (def->forward.ifs[ii].connections > 0) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("unable to delete interface '%s' "
"in network '%s'. It is currently being used
"
" by %d domains."),
iface.device.dev, def->name,
- def->forwardIfs[ii].connections);
+ def->forward.ifs[ii].connections);
goto cleanup;
}
/* remove it */
- virNetworkForwardIfDefClear(&def->forwardIfs[ii]);
- VIR_DELETE_ELEMENT(def->forwardIfs, ii, def->nForwardIfs);
+ virNetworkForwardIfDefClear(&def->forward.ifs[ii]);
+ VIR_DELETE_ELEMENT(def->forward.ifs, ii, def->forward.nifs);
} else {
virNetworkDefUpdateUnknownCommand(command);
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index c0d4fa2..e1d666b 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -161,6 +161,22 @@ struct _virNetworkForwardPfDef {
int connections; /* how many guest interfaces are connected to this device? */
};
+typedef struct _virNetworkForwardDef virNetworkForwardDef;
+typedef virNetworkForwardDef *virNetworkForwardDefPtr;
+struct _virNetworkForwardDef {
+ int type; /* One of virNetworkForwardType constants */
+ bool managed; /* managed attribute for hostdev mode */
+
+ /* If there are multiple forward devices (i.e. a pool of
+ * interfaces), they will be listed here.
+ */
+ size_t npfs;
+ virNetworkForwardPfDefPtr pfs;
+
+ size_t nifs;
+ virNetworkForwardIfDefPtr ifs;
+};
+
typedef struct _virPortGroupDef virPortGroupDef;
typedef virPortGroupDef *virPortGroupDefPtr;
struct _virPortGroupDef {
@@ -191,17 +207,7 @@ struct _virNetworkDef {
*/
bool ipv6nogw;
- int forwardType; /* One of virNetworkForwardType constants */
- int managed; /* managed attribute for hostdev mode */
-
- /* If there are multiple forward devices (i.e. a pool of
- * interfaces), they will be listed here.
- */
- size_t nForwardPfs;
- virNetworkForwardPfDefPtr forwardPfs;
-
- size_t nForwardIfs;
- virNetworkForwardIfDefPtr forwardIfs;
+ virNetworkForwardDef forward;
size_t nips;
virNetworkIpDefPtr ips; /* ptr to array of IP addresses on this network */
@@ -280,9 +286,9 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int
flags);
static inline const char *
virNetworkDefForwardIf(const virNetworkDefPtr def, size_t n)
{
- return ((def->forwardIfs && (def->nForwardIfs > n) &&
- def->forwardIfs[n].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV)
- ? def->forwardIfs[n].device.dev : NULL);
+ return ((def->forward.ifs && (def->forward.nifs > n) &&
+ def->forward.ifs[n].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV)
+ ? def->forward.ifs[n].device.dev : NULL);
}
virPortGroupDefPtr virPortGroupFindByName(virNetworkDefPtr net,
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index c8f101a..6a87abd 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -372,11 +372,11 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
}
/* FIXME: Add support for NAT */
- if (def->forwardType != VIR_NETWORK_FORWARD_NONE &&
- def->forwardType != VIR_NETWORK_FORWARD_BRIDGE) {
+ if (def->forward.type != VIR_NETWORK_FORWARD_NONE &&
+ def->forward.type != VIR_NETWORK_FORWARD_BRIDGE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported forward mode '%s'"),
- virNetworkForwardTypeToString(def->forwardType));
+ virNetworkForwardTypeToString(def->forward.type));
goto cleanup;
}
@@ -405,7 +405,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
goto cleanup;
}
- if (def->forwardType != VIR_NETWORK_FORWARD_NONE && def->nForwardIfs
> 0) {
+ if (def->forward.type != VIR_NETWORK_FORWARD_NONE && def->forward.nifs
> 0) {
if (esxVI_HostVirtualSwitchBondBridge_Alloc
(&hostVirtualSwitchBondBridge) < 0) {
goto cleanup;
@@ -419,10 +419,10 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
goto cleanup;
}
- for (i = 0; i < def->nForwardIfs; ++i) {
+ for (i = 0; i < def->forward.nifs; ++i) {
bool found = false;
- if (def->forwardIfs[i].type !=
+ if (def->forward.ifs[i].type !=
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported device type in network %s "
@@ -433,7 +433,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
for (physicalNic = physicalNicList; physicalNic != NULL;
physicalNic = physicalNic->_next) {
- if (STREQ(def->forwardIfs[i].device.dev, physicalNic->device)) {
+ if (STREQ(def->forward.ifs[i].device.dev, physicalNic->device)) {
if (esxVI_String_AppendValueToList
(&hostVirtualSwitchBondBridge->nicDevice,
physicalNic->key) < 0) {
@@ -448,7 +448,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
if (! found) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find PhysicalNic with name
'%s'"),
- def->forwardIfs[i].device.dev);
+ def->forward.ifs[i].device.dev);
goto cleanup;
}
}
@@ -721,7 +721,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
goto cleanup;
}
- def->forwardType = VIR_NETWORK_FORWARD_NONE;
+ def->forward.type = VIR_NETWORK_FORWARD_NONE;
/* Count PhysicalNics on HostVirtualSwitch */
count = 0;
@@ -732,9 +732,9 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
}
if (count > 0) {
- def->forwardType = VIR_NETWORK_FORWARD_BRIDGE;
+ def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
- if (VIR_ALLOC_N(def->forwardIfs, count) < 0) {
+ if (VIR_ALLOC_N(def->forward.ifs, count) < 0) {
virReportOOMError();
goto cleanup;
}
@@ -751,17 +751,17 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
for (physicalNic = physicalNicList; physicalNic != NULL;
physicalNic = physicalNic->_next) {
if (STREQ(physicalNicKey->value, physicalNic->key)) {
- def->forwardIfs[def->nForwardIfs].type
+ def->forward.ifs[def->forward.nifs].type
= VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
- def->forwardIfs[def->nForwardIfs].device.dev
+ def->forward.ifs[def->forward.nifs].device.dev
= strdup(physicalNic->device);
- if (def->forwardIfs[def->nForwardIfs].device.dev == NULL) {
+ if (def->forward.ifs[def->forward.nifs].device.dev == NULL) {
virReportOOMError();
goto cleanup;
}
- ++def->nForwardIfs;
+ ++def->forward.nifs;
found = true;
break;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index a5b9182..c94a9a1 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -711,7 +711,7 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
* host's /etc/resolv.conf (since this could be used as a channel
* to build a connection to the outside).
*/
- if (network->def->forwardType == VIR_NETWORK_FORWARD_NONE) {
+ if (network->def->forward.type == VIR_NETWORK_FORWARD_NONE) {
virCommandAddArgList(cmd, "--dhcp-option=3",
"--no-resolv", NULL);
}
@@ -1325,9 +1325,9 @@ networkRefreshDaemons(struct network_driver *driver)
virNetworkObjLock(network);
if (virNetworkObjIsActive(network) &&
- ((network->def->forwardType == VIR_NETWORK_FORWARD_NONE) ||
- (network->def->forwardType == VIR_NETWORK_FORWARD_NAT) ||
- (network->def->forwardType == VIR_NETWORK_FORWARD_ROUTE))) {
+ ((network->def->forward.type == VIR_NETWORK_FORWARD_NONE) ||
+ (network->def->forward.type == VIR_NETWORK_FORWARD_NAT) ||
+ (network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE))) {
/* Only the three L3 network types that are configured by
* libvirt will have a dnsmasq or radvd daemon associated
* with them. Here we send a SIGHUP to an existing
@@ -1862,12 +1862,12 @@ networkAddIpSpecificIptablesRules(struct network_driver *driver,
* forward mode is NAT. This is because IPv6 has no NAT.
*/
- if (network->def->forwardType == VIR_NETWORK_FORWARD_NAT) {
+ if (network->def->forward.type == VIR_NETWORK_FORWARD_NAT) {
if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET))
return networkAddMasqueradingIptablesRules(driver, network, ipdef);
else if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET6))
return networkAddRoutingIptablesRules(driver, network, ipdef);
- } else if (network->def->forwardType == VIR_NETWORK_FORWARD_ROUTE) {
+ } else if (network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE) {
return networkAddRoutingIptablesRules(driver, network, ipdef);
}
return 0;
@@ -1878,12 +1878,12 @@ networkRemoveIpSpecificIptablesRules(struct network_driver
*driver,
virNetworkObjPtr network,
virNetworkIpDefPtr ipdef)
{
- if (network->def->forwardType == VIR_NETWORK_FORWARD_NAT) {
+ if (network->def->forward.type == VIR_NETWORK_FORWARD_NAT) {
if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET))
networkRemoveMasqueradingIptablesRules(driver, network, ipdef);
else if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET6))
networkRemoveRoutingIptablesRules(driver, network, ipdef);
- } else if (network->def->forwardType == VIR_NETWORK_FORWARD_ROUTE) {
+ } else if (network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE) {
networkRemoveRoutingIptablesRules(driver, network, ipdef);
}
}
@@ -1951,9 +1951,9 @@ networkReloadIptablesRules(struct network_driver *driver)
virNetworkObjLock(network);
if (virNetworkObjIsActive(network) &&
- ((network->def->forwardType == VIR_NETWORK_FORWARD_NONE) ||
- (network->def->forwardType == VIR_NETWORK_FORWARD_NAT) ||
- (network->def->forwardType == VIR_NETWORK_FORWARD_ROUTE))) {
+ ((network->def->forward.type == VIR_NETWORK_FORWARD_NONE) ||
+ (network->def->forward.type == VIR_NETWORK_FORWARD_NAT) ||
+ (network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE))) {
/* Only the three L3 network types that are configured by libvirt
* need to have iptables rules reloaded.
*/
@@ -2253,8 +2253,8 @@ networkStartNetworkVirtual(struct network_driver *driver,
if (virNetDevSetOnline(network->def->bridge, 1) < 0)
goto err2;
- /* If forwardType != NONE, turn on global IP forwarding */
- if (network->def->forwardType != VIR_NETWORK_FORWARD_NONE &&
+ /* If forward.type != NONE, turn on global IP forwarding */
+ if (network->def->forward.type != VIR_NETWORK_FORWARD_NONE &&
networkEnableIpForwarding(v4present, v6present) < 0) {
virReportSystemError(errno, "%s",
_("failed to enable IP forwarding"));
@@ -2424,7 +2424,7 @@ networkStartNetwork(struct network_driver *driver,
if (virNetworkObjSetDefTransient(network, true) < 0)
return -1;
- switch (network->def->forwardType) {
+ switch (network->def->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
case VIR_NETWORK_FORWARD_NAT:
@@ -2486,7 +2486,7 @@ static int networkShutdownNetwork(struct network_driver *driver,
unlink(stateFile);
VIR_FREE(stateFile);
- switch (network->def->forwardType) {
+ switch (network->def->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
case VIR_NETWORK_FORWARD_NAT:
@@ -2739,9 +2739,9 @@ networkValidate(struct network_driver *driver,
/* Only the three L3 network types that are configured by libvirt
* need to have a bridge device name / mac address provided
*/
- if (def->forwardType == VIR_NETWORK_FORWARD_NONE ||
- def->forwardType == VIR_NETWORK_FORWARD_NAT ||
- def->forwardType == VIR_NETWORK_FORWARD_ROUTE) {
+ if (def->forward.type == VIR_NETWORK_FORWARD_NONE ||
+ def->forward.type == VIR_NETWORK_FORWARD_NAT ||
+ def->forward.type == VIR_NETWORK_FORWARD_ROUTE) {
if (virNetworkSetBridgeName(&driver->networks, def, 1))
return -1;
@@ -2756,7 +2756,7 @@ networkValidate(struct network_driver *driver,
_("Unsupported <ip> element in network %s "
"with forward mode='%s'"),
def->name,
- virNetworkForwardTypeToString(def->forwardType));
+ virNetworkForwardTypeToString(def->forward.type));
return -1;
}
if (def->dns.ntxts || def->dns.nhosts || def->dns.nsrvs) {
@@ -2764,7 +2764,7 @@ networkValidate(struct network_driver *driver,
_("Unsupported <dns> element in network %s "
"with forward mode='%s'"),
def->name,
- virNetworkForwardTypeToString(def->forwardType));
+ virNetworkForwardTypeToString(def->forward.type));
return -1;
}
if (def->domain) {
@@ -2772,7 +2772,7 @@ networkValidate(struct network_driver *driver,
_("Unsupported <domain> element in network %s
"
"with forward mode='%s'"),
def->name,
- virNetworkForwardTypeToString(def->forwardType));
+ virNetworkForwardTypeToString(def->forward.type));
return -1;
}
}
@@ -2797,7 +2797,7 @@ networkValidate(struct network_driver *driver,
* a pool, and those using an Open vSwitch bridge.
*/
- vlanAllowed = (def->forwardType == VIR_NETWORK_FORWARD_BRIDGE &&
+ vlanAllowed = (def->forward.type == VIR_NETWORK_FORWARD_BRIDGE &&
def->virtPortProfile &&
def->virtPortProfile->virtPortType ==
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH);
@@ -2810,7 +2810,7 @@ networkValidate(struct network_driver *driver,
* supports a vlan tag.
*/
if (def->portGroups[ii].virtPortProfile) {
- if (def->forwardType != VIR_NETWORK_FORWARD_BRIDGE ||
+ if (def->forward.type != VIR_NETWORK_FORWARD_BRIDGE ||
def->portGroups[ii].virtPortProfile->virtPortType
!= VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
badVlanUse = true;
@@ -3105,9 +3105,9 @@ networkUpdate(virNetworkPtr net,
if ((section == VIR_NETWORK_SECTION_IP ||
section == VIR_NETWORK_SECTION_FORWARD ||
section == VIR_NETWORK_SECTION_FORWARD_INTERFACE) &&
- (network->def->forwardType == VIR_NETWORK_FORWARD_NONE ||
- network->def->forwardType == VIR_NETWORK_FORWARD_NAT ||
- network->def->forwardType == VIR_NETWORK_FORWARD_ROUTE)) {
+ (network->def->forward.type == VIR_NETWORK_FORWARD_NONE ||
+ network->def->forward.type == VIR_NETWORK_FORWARD_NAT ||
+ network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE)) {
/* these could affect the iptables rules */
networkRemoveIptablesRules(driver, network);
if (networkAddIptablesRules(driver, network) < 0)
@@ -3405,37 +3405,37 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
struct pci_config_address **virt_fns;
int ret = -1, ii = 0;
- if ((virNetDevGetVirtualFunctions(netdef->forwardPfs->dev,
+ if ((virNetDevGetVirtualFunctions(netdef->forward.pfs->dev,
&vfname, &virt_fns, &num_virt_fns))
< 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get Virtual functions on %s"),
- netdef->forwardPfs->dev);
+ netdef->forward.pfs->dev);
goto finish;
}
if (num_virt_fns == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("No Vf's present on SRIOV PF %s"),
- netdef->forwardPfs->dev);
+ netdef->forward.pfs->dev);
goto finish;
}
- if ((VIR_ALLOC_N(netdef->forwardIfs, num_virt_fns)) < 0) {
+ if ((VIR_ALLOC_N(netdef->forward.ifs, num_virt_fns)) < 0) {
virReportOOMError();
goto finish;
}
- netdef->nForwardIfs = num_virt_fns;
+ netdef->forward.nifs = num_virt_fns;
- for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if ((netdef->forwardType == VIR_NETWORK_FORWARD_BRIDGE) ||
- (netdef->forwardType == VIR_NETWORK_FORWARD_PRIVATE) ||
- (netdef->forwardType == VIR_NETWORK_FORWARD_VEPA) ||
- (netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
- netdef->forwardIfs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
+ for (ii = 0; ii < netdef->forward.nifs; ii++) {
+ if ((netdef->forward.type == VIR_NETWORK_FORWARD_BRIDGE) ||
+ (netdef->forward.type == VIR_NETWORK_FORWARD_PRIVATE) ||
+ (netdef->forward.type == VIR_NETWORK_FORWARD_VEPA) ||
+ (netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
+ netdef->forward.ifs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
if (vfname[ii]) {
- netdef->forwardIfs[ii].device.dev = strdup(vfname[ii]);
- if (!netdef->forwardIfs[ii].device.dev) {
+ netdef->forward.ifs[ii].device.dev = strdup(vfname[ii]);
+ if (!netdef->forward.ifs[ii].device.dev) {
virReportOOMError();
goto finish;
}
@@ -3446,13 +3446,13 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
goto finish;
}
}
- else if (netdef->forwardType == VIR_NETWORK_FORWARD_HOSTDEV) {
+ else if (netdef->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
/* VF's are always PCI devices */
- netdef->forwardIfs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI;
- netdef->forwardIfs[ii].device.pci.domain = virt_fns[ii]->domain;
- netdef->forwardIfs[ii].device.pci.bus = virt_fns[ii]->bus;
- netdef->forwardIfs[ii].device.pci.slot = virt_fns[ii]->slot;
- netdef->forwardIfs[ii].device.pci.function = virt_fns[ii]->function;
+ netdef->forward.ifs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI;
+ netdef->forward.ifs[ii].device.pci.domain = virt_fns[ii]->domain;
+ netdef->forward.ifs[ii].device.pci.bus = virt_fns[ii]->bus;
+ netdef->forward.ifs[ii].device.pci.slot = virt_fns[ii]->slot;
+ netdef->forward.ifs[ii].device.pci.function = virt_fns[ii]->function;
}
}
@@ -3535,16 +3535,16 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
goto error;
}
- if ((netdef->forwardType == VIR_NETWORK_FORWARD_NONE) ||
- (netdef->forwardType == VIR_NETWORK_FORWARD_NAT) ||
- (netdef->forwardType == VIR_NETWORK_FORWARD_ROUTE)) {
+ if ((netdef->forward.type == VIR_NETWORK_FORWARD_NONE) ||
+ (netdef->forward.type == VIR_NETWORK_FORWARD_NAT) ||
+ (netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE)) {
/* for these forward types, the actual net type really *is*
*NETWORK; we just keep the info from the portgroup in
* iface->data.network.actual
*/
if (iface->data.network.actual)
iface->data.network.actual->type = VIR_DOMAIN_NET_TYPE_NETWORK;
- } else if ((netdef->forwardType == VIR_NETWORK_FORWARD_BRIDGE) &&
+ } else if ((netdef->forward.type == VIR_NETWORK_FORWARD_BRIDGE) &&
netdef->bridge) {
/* <forward type='bridge'/> <bridge name='xxx'/>
@@ -3587,7 +3587,7 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
}
}
- } else if (netdef->forwardType == VIR_NETWORK_FORWARD_HOSTDEV) {
+ } else if (netdef->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
if (!iface->data.network.actual
&& (VIR_ALLOC(iface->data.network.actual) < 0)) {
@@ -3596,15 +3596,15 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
}
iface->data.network.actual->type = actualType =
VIR_DOMAIN_NET_TYPE_HOSTDEV;
- if (netdef->nForwardPfs > 0 && netdef->nForwardIfs <= 0
&&
+ if (netdef->forward.npfs > 0 && netdef->forward.nifs <= 0
&&
networkCreateInterfacePool(netdef) < 0) {
goto error;
}
/* pick first dev with 0 connections */
- for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (netdef->forwardIfs[ii].connections == 0) {
- dev = &netdef->forwardIfs[ii];
+ for (ii = 0; ii < netdef->forward.nifs; ii++) {
+ if (netdef->forward.ifs[ii].connections == 0) {
+ dev = &netdef->forward.ifs[ii];
break;
}
}
@@ -3619,7 +3619,7 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
iface->data.network.actual->data.hostdev.def.parent.data.net = iface;
iface->data.network.actual->data.hostdev.def.info = &iface->info;
iface->data.network.actual->data.hostdev.def.mode =
VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
- iface->data.network.actual->data.hostdev.def.managed = netdef->managed;
+ iface->data.network.actual->data.hostdev.def.managed =
netdef->forward.managed ? 1 : 0;
iface->data.network.actual->data.hostdev.def.source.subsys.type =
dev->type;
iface->data.network.actual->data.hostdev.def.source.subsys.u.pci =
dev->device.pci;
@@ -3648,10 +3648,10 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
}
}
- } else if ((netdef->forwardType == VIR_NETWORK_FORWARD_BRIDGE) ||
- (netdef->forwardType == VIR_NETWORK_FORWARD_PRIVATE) ||
- (netdef->forwardType == VIR_NETWORK_FORWARD_VEPA) ||
- (netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
+ } else if ((netdef->forward.type == VIR_NETWORK_FORWARD_BRIDGE) ||
+ (netdef->forward.type == VIR_NETWORK_FORWARD_PRIVATE) ||
+ (netdef->forward.type == VIR_NETWORK_FORWARD_VEPA) ||
+ (netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
/* <forward type='bridge|private|vepa|passthrough'> are all
* VIR_DOMAIN_NET_TYPE_DIRECT.
@@ -3665,7 +3665,7 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
/* Set type=direct and appropriate <source mode='xxx'/> */
iface->data.network.actual->type = actualType =
VIR_DOMAIN_NET_TYPE_DIRECT;
- switch (netdef->forwardType) {
+ switch (netdef->forward.type) {
case VIR_NETWORK_FORWARD_BRIDGE:
iface->data.network.actual->data.direct.mode =
VIR_NETDEV_MACVLAN_MODE_BRIDGE;
break;
@@ -3707,7 +3707,7 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
/* If there is only a single device, just return it (caller will detect
* any error if exclusive use is required but could not be acquired).
*/
- if ((netdef->nForwardIfs <= 0) && (netdef->nForwardPfs <= 0))
{
+ if ((netdef->forward.nifs <= 0) && (netdef->forward.npfs <=
0)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("network '%s' uses a direct mode, but "
"has no forward dev and no interface pool"),
@@ -3716,7 +3716,7 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
} else {
/* pick an interface from the pool */
- if (netdef->nForwardPfs > 0 && netdef->nForwardIfs == 0
&&
+ if (netdef->forward.npfs > 0 && netdef->forward.nifs == 0
&&
networkCreateInterfacePool(netdef) < 0) {
goto error;
}
@@ -3727,25 +3727,25 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
* just search for the one with the lowest number of
* connections.
*/
- if ((netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH) ||
- ((netdef->forwardType == VIR_NETWORK_FORWARD_PRIVATE) &&
+ if ((netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH) ||
+ ((netdef->forward.type == VIR_NETWORK_FORWARD_PRIVATE) &&
iface->data.network.actual->virtPortProfile &&
(iface->data.network.actual->virtPortProfile->virtPortType
== VIR_NETDEV_VPORT_PROFILE_8021QBH))) {
/* pick first dev with 0 connections */
- for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (netdef->forwardIfs[ii].connections == 0) {
- dev = &netdef->forwardIfs[ii];
+ for (ii = 0; ii < netdef->forward.nifs; ii++) {
+ if (netdef->forward.ifs[ii].connections == 0) {
+ dev = &netdef->forward.ifs[ii];
break;
}
}
} else {
/* pick least used dev */
- dev = &netdef->forwardIfs[0];
- for (ii = 1; ii < netdef->nForwardIfs; ii++) {
- if (netdef->forwardIfs[ii].connections < dev->connections)
- dev = &netdef->forwardIfs[ii];
+ dev = &netdef->forward.ifs[0];
+ for (ii = 1; ii < netdef->forward.nifs; ii++) {
+ if (netdef->forward.ifs[ii].connections < dev->connections)
+ dev = &netdef->forward.ifs[ii];
}
}
/* dev points at the physical device we want to use */
@@ -3885,11 +3885,11 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
goto success;
}
- if (netdef->nForwardPfs > 0 && netdef->nForwardIfs == 0 &&
+ if (netdef->forward.npfs > 0 && netdef->forward.nifs == 0
&&
networkCreateInterfacePool(netdef) < 0) {
goto error;
}
- if (netdef->nForwardIfs == 0) {
+ if (netdef->forward.nifs == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("network '%s' uses a direct or hostdev mode,
"
"but has no forward dev and no interface pool"),
@@ -3909,11 +3909,11 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
}
/* find the matching interface and increment its connections */
- for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (netdef->forwardIfs[ii].type
+ for (ii = 0; ii < netdef->forward.nifs; ii++) {
+ if (netdef->forward.ifs[ii].type
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV &&
- STREQ(actualDev, netdef->forwardIfs[ii].device.dev)) {
- dev = &netdef->forwardIfs[ii];
+ STREQ(actualDev, netdef->forward.ifs[ii].device.dev)) {
+ dev = &netdef->forward.ifs[ii];
break;
}
}
@@ -3931,8 +3931,8 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
* must be 0 in those cases.
*/
if ((dev->connections > 0) &&
- ((netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH) ||
- ((netdef->forwardType == VIR_NETWORK_FORWARD_PRIVATE) &&
+ ((netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH) ||
+ ((netdef->forward.type == VIR_NETWORK_FORWARD_PRIVATE) &&
iface->data.network.actual->virtPortProfile &&
(iface->data.network.actual->virtPortProfile->virtPortType
== VIR_NETDEV_VPORT_PROFILE_8021QBH)))) {
@@ -3960,12 +3960,12 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
}
/* find the matching interface and increment its connections */
- for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (netdef->forwardIfs[ii].type
+ for (ii = 0; ii < netdef->forward.nifs; ii++) {
+ if (netdef->forward.ifs[ii].type
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI &&
virDevicePCIAddressEqual(&hostdev->source.subsys.u.pci,
- &netdef->forwardIfs[ii].device.pci)) {
- dev = &netdef->forwardIfs[ii];
+ &netdef->forward.ifs[ii].device.pci)) {
+ dev = &netdef->forward.ifs[ii];
break;
}
}
@@ -3987,7 +3987,7 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
* current connections count must be 0 in those cases.
*/
if ((dev->connections > 0) &&
- netdef->forwardType == VIR_NETWORK_FORWARD_HOSTDEV) {
+ netdef->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("network '%s' claims the PCI device at "
"domain=%d bus=%d slot=%d function=%d "
@@ -4062,7 +4062,7 @@ networkReleaseActualDevice(virDomainNetDefPtr iface)
goto success;
}
- if (netdef->nForwardIfs == 0) {
+ if (netdef->forward.nifs == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("network '%s' uses a direct/hostdev mode, but
"
"has no forward dev and no interface pool"),
@@ -4081,11 +4081,11 @@ networkReleaseActualDevice(virDomainNetDefPtr iface)
goto error;
}
- for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (netdef->forwardIfs[ii].type
+ for (ii = 0; ii < netdef->forward.nifs; ii++) {
+ if (netdef->forward.ifs[ii].type
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV &&
- STREQ(actualDev, netdef->forwardIfs[ii].device.dev)) {
- dev = &netdef->forwardIfs[ii];
+ STREQ(actualDev, netdef->forward.ifs[ii].device.dev)) {
+ dev = &netdef->forward.ifs[ii];
break;
}
}
@@ -4112,12 +4112,12 @@ networkReleaseActualDevice(virDomainNetDefPtr iface)
goto error;
}
- for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (netdef->forwardIfs[ii].type
+ for (ii = 0; ii < netdef->forward.nifs; ii++) {
+ if (netdef->forward.ifs[ii].type
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI &&
virDevicePCIAddressEqual(&hostdev->source.subsys.u.pci,
- &netdef->forwardIfs[ii].device.pci)) {
- dev = &netdef->forwardIfs[ii];
+ &netdef->forward.ifs[ii].device.pci)) {
+ dev = &netdef->forward.ifs[ii];
break;
}
}
@@ -4202,7 +4202,7 @@ networkGetNetworkAddress(const char *netname, char **netaddr)
}
netdef = network->def;
- switch (netdef->forwardType) {
+ switch (netdef->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
case VIR_NETWORK_FORWARD_NAT:
case VIR_NETWORK_FORWARD_ROUTE:
@@ -4227,8 +4227,8 @@ networkGetNetworkAddress(const char *netname, char **netaddr)
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
case VIR_NETWORK_FORWARD_PASSTHROUGH:
- if ((netdef->nForwardIfs > 0) && netdef->forwardIfs)
- dev_name = netdef->forwardIfs[0].device.dev;
+ if ((netdef->forward.nifs > 0) && netdef->forward.ifs)
+ dev_name = netdef->forward.ifs[0].device.dev;
if (!dev_name) {
virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index f9fa442..e0f9b6f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -7725,7 +7725,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn,
const char *
virSocketAddr netmask;
if ((!def) ||
- (def->forwardType != VIR_NETWORK_FORWARD_NONE) ||
+ (def->forward.type != VIR_NETWORK_FORWARD_NONE) ||
(def->nips == 0 || !def->ips))
goto cleanup;
@@ -8129,7 +8129,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network,
VBOX_UTF8_TO_UTF16(networkNameUtf8 , &networkNameUtf16);
- def->forwardType = VIR_NETWORK_FORWARD_NONE;
+ def->forward.type = VIR_NETWORK_FORWARD_NONE;
data->vboxObj->vtbl->FindDHCPServerByNetworkName(data->vboxObj,
networkNameUtf16,
--
1.7.11.7