diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index f947d89108..dce3360a7a 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1,7 +1,7 @@
/*
* network_conf.c: network XML handling
*
- * Copyright (C) 2006-2014 Red Hat, Inc.
+ * Copyright (C) 2006-2015 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -1638,14 +1638,6 @@ virNetworkForwardDefParseXML(const char *networkName,
goto cleanup;
}
- if (((nForwardIfs > 0) + (nForwardAddrs > 0) + (nForwardPfs > 0)) > 1) {
- virReportError(VIR_ERR_XML_ERROR,
- _("
, , and elements in "
- "of network %s are mutually exclusive"),
- networkName);
- goto cleanup;
- }
-
forwardDev = virXPathString("string(./@dev)", ctxt);
if (forwardDev && (nForwardAddrs > 0 || nForwardPfs > 0)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 404e90b639..f240d3bae5 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2734,6 +2734,7 @@ networkValidate(virNetworkDefPtr def,
virNetworkIpDefPtr ipdef;
bool ipv4def = false, ipv6def = false;
bool bandwidthAllowed = true;
+ bool usesInterface = false, usesAddress = false;
/* check for duplicate networks */
if (virNetworkObjIsDuplicate(&driver->networks, def, check_active) < 0)
@@ -2798,6 +2799,40 @@ networkValidate(virNetworkDefPtr def,
bandwidthAllowed = false;
}
+ /* we support configs with a single PF defined:
+ *
+ * or with a list of netdev names:
+ *
+ * OR a list of PCI addresses
+ *
+ * but not any combination of those.
+ *
+ * Since and are for some strange reason
+ * stored in the same array, we need to cycle through it and check
+ * the type of each.
+ */
+ for (i = 0; i < def->forward.nifs; i++) {
+ switch ((virNetworkForwardHostdevDeviceType)
+ def->forward.ifs[i].type) {
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV:
+ usesInterface = true;
+ break;
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI:
+ usesAddress = true;
+ break;
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NONE:
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_LAST:
+ break;
+ }
+ }
+ if ((def->forward.npfs > 0) + usesInterface + usesAddress > 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _(", , and elements of "
+ " in network %s are mutually exclusive"),
+ def->name);
+ return -1;
+ }
+
/* We only support dhcp on one IPv4 address and
* on one IPv6 address per defined network
*/