diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 9dbda4a6cc77d4bd571a1efbb6a8c0eff8264059..766f9a08f5673c5f75ed68846626aec7733c5694 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -54,6 +54,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ on
+ off
+
+
+
+
+
@@ -167,4 +192,25 @@
+
+
+ (0x)?[0-9a-fA-F]{1,4}
+
+
+
+
+ (0x)?[0-9a-fA-F]{1,2}
+
+
+
+
+ (0x)?[0-1]?[0-9a-fA-F]
+
+
+
+
+ (0x)?[0-7]
+
+
+
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4903ca69e34c4fe1866cbf6d23881af36ccd0d76..35e9f825650de679b8695e023d2a48d49ca45745 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2652,30 +2652,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- on
- off
-
-
-
-
@@ -3376,26 +3352,6 @@
((0x)?[0-9a-fA-F]{1,3}\.){0,3}(0x)?[0-9a-fA-F]{1,3}
-
-
- (0x)?[0-9a-fA-F]{1,4}
-
-
-
-
- (0x)?[0-9a-fA-F]{1,2}
-
-
-
-
- (0x)?[0-1]?[0-9a-fA-F]
-
-
-
-
- (0x)?[0-7]
-
-
[0-9]{1,2}
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index e55105a144fbf53d5d6528596967597ab5d640d8..4abfd915dd719842041fdc1d0b241bda7f4f3cca 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -87,22 +87,51 @@
passthrough
private
vepa
+ hostdev
+
+
+
+
+
+
+
+ yes
+ no
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pci
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index db8c62f4ee10898f93a0b629652cf385404156d0..9d53d8e76f8206c8dac623f191d7dfd712507030 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -50,7 +50,12 @@
VIR_ENUM_IMPL(virNetworkForward,
VIR_NETWORK_FORWARD_LAST,
- "none", "nat", "route", "bridge", "private", "vepa", "passthrough" )
+ "none", "nat", "route", "bridge", "private", "vepa", "passthrough", "hostdev")
+
+VIR_ENUM_DECL(virNetworkForwardHostdevDevice)
+VIR_ENUM_IMPL(virNetworkForwardHostdevDevice,
+ VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_LAST,
+ "none", "pci", "netdev")
virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets,
const unsigned char *uuid)
@@ -96,7 +101,8 @@ virPortGroupDefClear(virPortGroupDefPtr def)
static void
virNetworkForwardIfDefClear(virNetworkForwardIfDefPtr def)
{
- VIR_FREE(def->dev);
+ if (def->type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV)
+ VIR_FREE(def->device.dev);
}
static void
@@ -943,11 +949,14 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
xmlNodePtr *portGroupNodes = NULL;
xmlNodePtr *forwardIfNodes = NULL;
xmlNodePtr *forwardPfNodes = NULL;
+ xmlNodePtr *forwardAddrNodes = NULL;
xmlNodePtr dnsNode = NULL;
xmlNodePtr virtPortNode = NULL;
xmlNodePtr forwardNode = NULL;
- int nIps, nPortGroups, nForwardIfs, nForwardPfs;
+ int nIps, nPortGroups, nForwardIfs, nForwardPfs, nForwardAddrs;
char *forwardDev = NULL;
+ char *forwardManaged = NULL;
+ char *type = NULL;
xmlNodePtr save = ctxt->node;
xmlNodePtr bandwidthNode = NULL;
xmlNodePtr vlanNode;
@@ -1100,17 +1109,35 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
}
forwardDev = virXPathString("string(./@dev)", ctxt);
+ forwardManaged = virXPathString("string(./@managed)", ctxt);
+ if(forwardManaged != NULL) {
+ if (STRCASEEQ(forwardManaged, "yes"))
+ def->managed = 1;
+ }
/* all of these modes can use a pool of physical interfaces */
nForwardIfs = virXPathNodeSet("./interface", ctxt, &forwardIfNodes);
nForwardPfs = virXPathNodeSet("./pf", ctxt, &forwardPfNodes);
+ nForwardAddrs = virXPathNodeSet("./address", ctxt, &forwardAddrNodes);
- if (nForwardIfs < 0 || nForwardPfs < 0) {
+ if (nForwardIfs < 0 || nForwardPfs < 0 || nForwardAddrs < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("No interface pool or SRIOV physical device given"));
goto error;
}
+ if ((nForwardIfs > 0) && (nForwardAddrs > 0)) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Address and interface attributes are mutually exclusive"));
+ goto error;
+ }
+
+ if ((nForwardPfs > 0) && ((nForwardIfs > 0) || (nForwardAddrs > 0))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Address/interface attributes and Physical function are mutually exclusive "));
+ goto error;
+ }
+
if (nForwardPfs == 1) {
if (VIR_ALLOC_N(def->forwardPfs, nForwardPfs) < 0) {
virReportOOMError();
@@ -1139,7 +1166,53 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
_("Use of more than one physical interface is not allowed"));
goto error;
}
- if (nForwardIfs > 0 || forwardDev) {
+ if (nForwardAddrs > 0) {
+ int ii;
+
+ if (VIR_ALLOC_N(def->forwardIfs, nForwardAddrs) < 0) {
+ virReportOOMError();
+ goto error;
+ }
+
+ if (forwardDev) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("A forward Dev should not be used when using address attribute"));
+ goto error;
+ }
+
+ for (ii = 0; ii < nForwardAddrs; ii++) {
+ type = virXMLPropString(forwardAddrNodes[ii], "type");
+
+ if (type) {
+ if ((def->forwardIfs[ii].type = virNetworkForwardHostdevDeviceTypeFromString(type)) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unknown address type '%s'"), type);
+ goto error;
+ }
+ } else {
+ virReportError(VIR_ERR_XML_ERROR,
+ "%s", _("No type specified for device address"));
+ goto error;
+ }
+
+ switch (def->forwardIfs[ii].type) {
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI:
+ if (virDevicePCIAddressParseXML(forwardAddrNodes[ii], &(def->forwardIfs[ii].device.pci)) < 0)
+ goto error;
+ break;
+
+ /* Add USB case here */
+
+ default:
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unknown address type '%s'"), type);
+ goto error;
+ }
+ VIR_FREE(type);
+ def->nForwardIfs++;
+ }
+ }
+ else if (nForwardIfs > 0 || forwardDev) {
int ii;
/* allocate array to hold all the portgroups */
@@ -1149,7 +1222,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
}
if (forwardDev) {
- def->forwardIfs[0].dev = forwardDev;
+ def->forwardIfs[0].device.dev = forwardDev;
+ def->forwardIfs[0].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
forwardDev = NULL;
def->nForwardIfs++;
}
@@ -1167,10 +1241,10 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
if ((ii == 0) && (def->nForwardIfs == 1)) {
/* both forwardDev and an interface element are present.
* If they don't match, it's an error. */
- if (STRNEQ(forwardDev, def->forwardIfs[0].dev)) {
+ if (STRNEQ(forwardDev, def->forwardIfs[0].device.dev)) {
virReportError(VIR_ERR_XML_ERROR,
_("forward dev '%s' must match first interface element dev '%s' in network '%s'"),
- def->forwardIfs[0].dev,
+ def->forwardIfs[0].device.dev,
forwardDev, def->name);
goto error;
}
@@ -1178,15 +1252,18 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
continue;
}
- def->forwardIfs[ii].dev = forwardDev;
+ def->forwardIfs[ii].device.dev = forwardDev;
forwardDev = NULL;
+ def->forwardIfs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
def->nForwardIfs++;
}
}
+ VIR_FREE(type);
VIR_FREE(forwardDev);
+ VIR_FREE(forwardManaged);
VIR_FREE(forwardPfNodes);
VIR_FREE(forwardIfNodes);
-
+ VIR_FREE(forwardAddrNodes);
switch (def->forwardType) {
case VIR_NETWORK_FORWARD_ROUTE:
case VIR_NETWORK_FORWARD_NAT:
@@ -1211,6 +1288,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
if (def->bridge) {
virReportError(VIR_ERR_XML_ERROR,
_("bridge name not allowed in %s mode (network '%s')"),
@@ -1310,17 +1388,18 @@ virNetworkDNSDefFormat(virBufferPtr buf,
if (def == NULL)
goto out;
- virBufferAddLit(buf, " \n");
+ virBufferAddLit(buf, "\n");
+ virBufferAdjustIndent(buf, 2);
for (i = 0 ; i < def->ntxtrecords ; i++) {
- virBufferAsprintf(buf, " \n",
+ virBufferAsprintf(buf, "\n",
def->txtrecords[i].name,
def->txtrecords[i].value);
}
for (i = 0 ; i < def->nsrvrecords ; i++) {
if (def->srvrecords[i].service && def->srvrecords[i].protocol) {
- virBufferAsprintf(buf, " srvrecords[i].service,
def->srvrecords[i].protocol);
@@ -1345,18 +1424,19 @@ virNetworkDNSDefFormat(virBufferPtr buf,
for (ii = 0 ; ii < def->nhosts; ii++) {
char *ip = virSocketAddrFormat(&def->hosts[ii].ip);
- virBufferAsprintf(buf, " \n", ip);
-
+ virBufferAsprintf(buf, "\n", ip);
+ virBufferAdjustIndent(buf, 2);
for (j = 0; j < def->hosts[ii].nnames; j++)
- virBufferAsprintf(buf, " %s\n",
- def->hosts[ii].names[j]);
+ virBufferAsprintf(buf, "%s\n",
+ def->hosts[ii].names[j]);
- virBufferAsprintf(buf, " \n");
+ virBufferAdjustIndent(buf, -2);
+ virBufferAsprintf(buf, "\n");
VIR_FREE(ip);
}
}
-
- virBufferAddLit(buf, " \n");
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "\n");
out:
return result;
}
@@ -1367,7 +1447,7 @@ virNetworkIpDefFormat(virBufferPtr buf,
{
int result = -1;
- virBufferAddLit(buf, " family) {
virBufferAsprintf(buf, " family='%s'", def->family);
@@ -1390,14 +1470,17 @@ virNetworkIpDefFormat(virBufferPtr buf,
virBufferAsprintf(buf," prefix='%u'", def->prefix);
}
virBufferAddLit(buf, ">\n");
+ virBufferAdjustIndent(buf, 2);
if (def->tftproot) {
- virBufferEscapeString(buf, " \n",
+ virBufferEscapeString(buf, "\n",
def->tftproot);
}
if ((def->nranges || def->nhosts)) {
int ii;
- virBufferAddLit(buf, " \n");
+ virBufferAddLit(buf, "\n");
+ virBufferAdjustIndent(buf, 2);
+
for (ii = 0 ; ii < def->nranges ; ii++) {
char *saddr = virSocketAddrFormat(&def->ranges[ii].start);
if (!saddr)
@@ -1407,13 +1490,13 @@ virNetworkIpDefFormat(virBufferPtr buf,
VIR_FREE(saddr);
goto error;
}
- virBufferAsprintf(buf, " \n",
+ virBufferAsprintf(buf, "\n",
saddr, eaddr);
VIR_FREE(saddr);
VIR_FREE(eaddr);
}
for (ii = 0 ; ii < def->nhosts ; ii++) {
- virBufferAddLit(buf, " hosts[ii].mac)
virBufferAsprintf(buf, "mac='%s' ", def->hosts[ii].mac);
if (def->hosts[ii].name)
@@ -1428,7 +1511,7 @@ virNetworkIpDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
if (def->bootfile) {
- virBufferEscapeString(buf, " bootfile);
if (VIR_SOCKET_ADDR_VALID(&def->bootserver)) {
char *ipaddr = virSocketAddrFormat(&def->bootserver);
@@ -1438,12 +1521,15 @@ virNetworkIpDefFormat(virBufferPtr buf,
VIR_FREE(ipaddr);
}
virBufferAddLit(buf, "/>\n");
+
}
- virBufferAddLit(buf, " \n");
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "\n");
}
- virBufferAddLit(buf, " \n");
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "\n");
result = 0;
error:
@@ -1454,19 +1540,19 @@ static int
virPortGroupDefFormat(virBufferPtr buf,
const virPortGroupDefPtr def)
{
- virBufferAsprintf(buf, " name);
+ virBufferAsprintf(buf, "name);
if (def->isDefault) {
virBufferAddLit(buf, " default='yes'");
}
virBufferAddLit(buf, ">\n");
- virBufferAdjustIndent(buf, 4);
+ virBufferAdjustIndent(buf, 2);
if (virNetDevVlanFormat(&def->vlan, buf) < 0)
return -1;
if (virNetDevVPortProfileFormat(def->virtPortProfile, buf) < 0)
return -1;
virNetDevBandwidthFormat(def->bandwidth, buf);
- virBufferAdjustIndent(buf, -4);
- virBufferAddLit(buf, " \n");
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "\n");
return 0;
}
@@ -1482,11 +1568,12 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags)
virBufferAsprintf(&buf, " connections='%d'", def->connections);
}
virBufferAddLit(&buf, ">\n");
- virBufferEscapeString(&buf, " %s\n", def->name);
+ virBufferAdjustIndent(&buf, 2);
+ virBufferEscapeString(&buf, "%s\n", def->name);
uuid = def->uuid;
virUUIDFormat(uuid, uuidstr);
- virBufferAsprintf(&buf, " %s\n", uuidstr);
+ virBufferAsprintf(&buf, "%s\n", uuidstr);
if (def->forwardType != VIR_NETWORK_FORWARD_NONE) {
const char *dev = NULL;
@@ -1500,38 +1587,57 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags)
def->forwardType, def->name);
goto error;
}
- virBufferAddLit(&buf, " \n", mode,
+ virBufferAsprintf(&buf, " mode='%s'", mode);
+ if (def->forwardType == VIR_NETWORK_FORWARD_HOSTDEV) {
+ if (def->managed == 1)
+ virBufferAddLit(&buf, " managed='yes'");
+ else
+ virBufferAddLit(&buf, " managed='no'");
+ }
+ virBufferAsprintf(&buf, "%s>\n",
(def->nForwardIfs || def->nForwardPfs) ? "" : "/");
+ virBufferAdjustIndent(&buf, 2);
/* For now, hard-coded to at most 1 forwardPfs */
if (def->nForwardPfs)
- virBufferEscapeString(&buf, " \n",
+ virBufferEscapeString(&buf, "\n",
def->forwardPfs[0].dev);
if (def->nForwardIfs &&
(!def->nForwardPfs || !(flags & VIR_NETWORK_XML_INACTIVE))) {
for (ii = 0; ii < def->nForwardIfs; ii++) {
- virBufferEscapeString(&buf, " forwardIfs[ii].dev);
- if (!(flags & VIR_NETWORK_XML_INACTIVE) &&
- (def->forwardIfs[ii].connections > 0)) {
- virBufferAsprintf(&buf, " connections='%d'",
- def->forwardIfs[ii].connections);
+ if (def->forwardType != VIR_NETWORK_FORWARD_HOSTDEV) {
+ virBufferEscapeString(&buf, "forwardIfs[ii].device.dev);
+ if (!(flags & VIR_NETWORK_XML_INACTIVE) &&
+ (def->forwardIfs[ii].connections > 0)) {
+ virBufferAsprintf(&buf, " connections='%d'",
+ def->forwardIfs[ii].connections);
+ }
+ virBufferAddLit(&buf, "/>\n");
+ }
+ else {
+ if (def->forwardIfs[ii].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI) {
+ if (virDevicePCIAddressFormat(&buf,
+ def->forwardIfs[ii].device.pci,
+ true) < 0)
+ goto error;
+ }
}
- virBufferAddLit(&buf, "/>\n");
}
}
+ virBufferAdjustIndent(&buf, -2);
if (def->nForwardPfs || def->nForwardIfs)
- virBufferAddLit(&buf, " \n");
+ virBufferAddLit(&buf, "\n");
}
if (def->forwardType == VIR_NETWORK_FORWARD_NONE ||
def->forwardType == VIR_NETWORK_FORWARD_NAT ||
def->forwardType == VIR_NETWORK_FORWARD_ROUTE) {
- virBufferAddLit(&buf, " bridge)
virBufferEscapeString(&buf, " name='%s'", def->bridge);
virBufferAsprintf(&buf, " stp='%s' delay='%ld' />\n",
@@ -1539,43 +1645,40 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags)
def->delay);
} else if (def->forwardType == VIR_NETWORK_FORWARD_BRIDGE &&
def->bridge) {
- virBufferEscapeString(&buf, " \n", def->bridge);
+ virBufferEscapeString(&buf, "\n", def->bridge);
}
if (def->mac_specified) {
char macaddr[VIR_MAC_STRING_BUFLEN];
virMacAddrFormat(&def->mac, macaddr);
- virBufferAsprintf(&buf, " \n", macaddr);
+ virBufferAsprintf(&buf, "\n", macaddr);
}
if (def->domain)
- virBufferAsprintf(&buf, " \n", def->domain);
+ virBufferAsprintf(&buf, "\n", def->domain);
if (virNetworkDNSDefFormat(&buf, def->dns) < 0)
goto error;
- virBufferAdjustIndent(&buf, 2);
if (virNetDevVlanFormat(&def->vlan, &buf) < 0)
goto error;
if (virNetDevBandwidthFormat(def->bandwidth, &buf) < 0)
goto error;
- virBufferAdjustIndent(&buf, -2);
for (ii = 0; ii < def->nips; ii++) {
if (virNetworkIpDefFormat(&buf, &def->ips[ii]) < 0)
goto error;
}
- virBufferAdjustIndent(&buf, 2);
if (virNetDevVPortProfileFormat(def->virtPortProfile, &buf) < 0)
goto error;
- virBufferAdjustIndent(&buf, -2);
for (ii = 0; ii < def->nPortGroups; ii++)
if (virPortGroupDefFormat(&buf, &def->portGroups[ii]) < 0)
goto error;
+ virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "\n");
if (virBufferError(&buf))
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index a029f707048cc605f08812634b140b0bb613d505..f49c3671be953d755dfd2d7441f100695c7e3242 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -37,6 +37,7 @@
# include "virnetdevvportprofile.h"
# include "virnetdevvlan.h"
# include "virmacaddr.h"
+# include "device_conf.h"
enum virNetworkForwardType {
VIR_NETWORK_FORWARD_NONE = 0,
@@ -46,10 +47,20 @@ enum virNetworkForwardType {
VIR_NETWORK_FORWARD_PRIVATE,
VIR_NETWORK_FORWARD_VEPA,
VIR_NETWORK_FORWARD_PASSTHROUGH,
+ VIR_NETWORK_FORWARD_HOSTDEV,
VIR_NETWORK_FORWARD_LAST,
};
+enum virNetworkForwardHostdevDeviceType {
+ VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NONE = 0,
+ VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI,
+ VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV,
+ /* USB Device to be added here when supported */
+
+ VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_LAST,
+};
+
typedef struct _virNetworkDHCPRangeDef virNetworkDHCPRangeDef;
typedef virNetworkDHCPRangeDef *virNetworkDHCPRangeDefPtr;
struct _virNetworkDHCPRangeDef {
@@ -132,14 +143,20 @@ struct _virNetworkIpDef {
typedef struct _virNetworkForwardIfDef virNetworkForwardIfDef;
typedef virNetworkForwardIfDef *virNetworkForwardIfDefPtr;
struct _virNetworkForwardIfDef {
- char *dev; /* name of device */
- int connections; /* how many guest interfaces are connected to this device? */
+ int type;
+ union {
+ virDevicePCIAddress pci; /*PCI Address of device */
+ /* when USB devices are supported a new variable to be added here */
+ char *dev; /* name of device */
+ }device;
+ int connections; /* how many guest interfaces are connected to this device? */
};
typedef struct _virNetworkForwardPfDef virNetworkForwardPfDef;
typedef virNetworkForwardPfDef *virNetworkForwardPfDefPtr;
struct _virNetworkForwardPfDef {
char *dev; /* name of device */
+ int connections; /* how many guest interfaces are connected to this device? */
};
typedef struct _virPortGroupDef virPortGroupDef;
@@ -168,6 +185,7 @@ struct _virNetworkDef {
bool mac_specified;
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.
@@ -243,8 +261,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].dev : NULL);
+ return ((def->forwardIfs && (def->nForwardIfs > n) &&
+ def->forwardIfs[n].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV)
+ ? def->forwardIfs[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 b42f1d84686e0ac48b4f4a39c0e8da27045b4d62..09d46d36b6f4478f50ea0fbc85270cb8b0226fe9 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -3,7 +3,7 @@
* esx_network_driver.c: network driver functions for managing VMware ESX
* host networks
*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2010-2012 Matthias Bolte
*
* This library is free software; you can redistribute it and/or
@@ -422,9 +422,18 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
for (i = 0; i < def->nForwardIfs; ++i) {
bool found = false;
+ if (def->forwardIfs[i].type !=
+ VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unsupported device type in network %s "
+ "interface pool"),
+ def->name);
+ goto cleanup;
+ }
+
for (physicalNic = physicalNicList; physicalNic != NULL;
physicalNic = physicalNic->_next) {
- if (STREQ(def->forwardIfs[i].dev, physicalNic->device)) {
+ if (STREQ(def->forwardIfs[i].device.dev, physicalNic->device)) {
if (esxVI_String_AppendValueToList
(&hostVirtualSwitchBondBridge->nicDevice,
physicalNic->key) < 0) {
@@ -439,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].dev);
+ def->forwardIfs[i].device.dev);
goto cleanup;
}
}
@@ -742,9 +751,12 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
for (physicalNic = physicalNicList; physicalNic != NULL;
physicalNic = physicalNic->_next) {
if (STREQ(physicalNicKey->value, physicalNic->key)) {
- def->forwardIfs[def->nForwardIfs].dev = strdup(physicalNic->device);
+ def->forwardIfs[def->nForwardIfs].type
+ = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
+ def->forwardIfs[def->nForwardIfs].device.dev
+ = strdup(physicalNic->device);
- if (def->forwardIfs[def->nForwardIfs].dev == NULL) {
+ if (def->forwardIfs[def->nForwardIfs].device.dev == NULL) {
virReportOOMError();
goto cleanup;
}
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 5619640534f57f558965032455ae1483a4397999..bf809bb31d89237343291261d83e668ee5b8218b 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2805,8 +2805,8 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
netdef->nForwardIfs = num_virt_fns;
for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- netdef->forwardIfs[ii].dev = strdup(vfname[ii]);
- if (!netdef->forwardIfs[ii].dev) {
+ netdef->forwardIfs[ii].device.dev = strdup(vfname[ii]);
+ if (!netdef->forwardIfs[ii].device.dev) {
virReportOOMError();
goto finish;
}
@@ -3057,7 +3057,7 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
netdef->name);
goto error;
}
- iface->data.network.actual->data.direct.linkdev = strdup(dev->dev);
+ iface->data.network.actual->data.direct.linkdev = strdup(dev->device.dev);
if (!iface->data.network.actual->data.direct.linkdev) {
virReportOOMError();
goto error;
@@ -3115,7 +3115,7 @@ validate:
/* we are now assured of success, so mark the allocation */
dev->connections++;
VIR_DEBUG("Using physical device %s, %d connections",
- dev->dev, dev->connections);
+ dev->device.dev, dev->connections);
}
if (netdef) {
@@ -3198,7 +3198,7 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
/* find the matching interface and increment its connections */
for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (STREQ(actualDev, netdef->forwardIfs[ii].dev)) {
+ if (STREQ(actualDev, netdef->forwardIfs[ii].device.dev)) {
dev = &netdef->forwardIfs[ii];
break;
}
@@ -3229,7 +3229,7 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
/* we are now assured of success, so mark the allocation */
dev->connections++;
VIR_DEBUG("Using physical device %s, %d connections",
- dev->dev, dev->connections);
+ dev->device.dev, dev->connections);
}
success:
@@ -3305,7 +3305,7 @@ networkReleaseActualDevice(virDomainNetDefPtr iface)
virNetworkForwardIfDefPtr dev = NULL;
for (ii = 0; ii < netdef->nForwardIfs; ii++) {
- if (STREQ(actualDev, netdef->forwardIfs[ii].dev)) {
+ if (STREQ(actualDev, netdef->forwardIfs[ii].device.dev)) {
dev = &netdef->forwardIfs[ii];
break;
}
@@ -3320,7 +3320,7 @@ networkReleaseActualDevice(virDomainNetDefPtr iface)
dev->connections--;
VIR_DEBUG("Releasing physical device %s, %d connections",
- dev->dev, dev->connections);
+ dev->device.dev, dev->connections);
}
success:
@@ -3410,7 +3410,7 @@ networkGetNetworkAddress(const char *netname, char **netaddr)
case VIR_NETWORK_FORWARD_VEPA:
case VIR_NETWORK_FORWARD_PASSTHROUGH:
if ((netdef->nForwardIfs > 0) && netdef->forwardIfs)
- dev_name = netdef->forwardIfs[0].dev;
+ dev_name = netdef->forwardIfs[0].device.dev;
if (!dev_name) {
virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/tests/networkxml2xmlin/hostdev-pf.xml b/tests/networkxml2xmlin/hostdev-pf.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7bf857d3a1008bfa660477ad644e0a8b94701cce
--- /dev/null
+++ b/tests/networkxml2xmlin/hostdev-pf.xml
@@ -0,0 +1,7 @@
+
+ hostdev
+ 81ff0d90-c91e-6742-64da-4a736edb9a9b
+
+
+
+
diff --git a/tests/networkxml2xmlin/hostdev.xml b/tests/networkxml2xmlin/hostdev.xml
new file mode 100644
index 0000000000000000000000000000000000000000..03f141106f9bb799220a437c63bb8dca59345280
--- /dev/null
+++ b/tests/networkxml2xmlin/hostdev.xml
@@ -0,0 +1,10 @@
+
+ hostdev
+ 81ff0d90-c91e-6742-64da-4a736edb9a9b
+
+
+
+
+
+
+
diff --git a/tests/networkxml2xmlin/passthrough-pf.xml b/tests/networkxml2xmlin/passthrough-pf.xml
index e63aae0507c2817f2b208b342a0754839e3416a6..ecdb9533e36a473413e2319cb4680465d427a36b 100644
--- a/tests/networkxml2xmlin/passthrough-pf.xml
+++ b/tests/networkxml2xmlin/passthrough-pf.xml
@@ -3,8 +3,6 @@
81ff0d90-c91e-6742-64da-4a736edb9a9b
-
-
diff --git a/tests/networkxml2xmlout/hostdev-pf.xml b/tests/networkxml2xmlout/hostdev-pf.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7bf857d3a1008bfa660477ad644e0a8b94701cce
--- /dev/null
+++ b/tests/networkxml2xmlout/hostdev-pf.xml
@@ -0,0 +1,7 @@
+
+ hostdev
+ 81ff0d90-c91e-6742-64da-4a736edb9a9b
+
+
+
+
diff --git a/tests/networkxml2xmlout/hostdev.xml b/tests/networkxml2xmlout/hostdev.xml
new file mode 100644
index 0000000000000000000000000000000000000000..03f141106f9bb799220a437c63bb8dca59345280
--- /dev/null
+++ b/tests/networkxml2xmlout/hostdev.xml
@@ -0,0 +1,10 @@
+
+ hostdev
+ 81ff0d90-c91e-6742-64da-4a736edb9a9b
+
+
+
+
+
+
+
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index 5a5531a9dcc7214ab6e2b62b46c80c72665be0a3..e57d1903993e2b69d63014f773707f2129d5a496 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -106,6 +106,8 @@ mymain(void)
DO_TEST("bandwidth-network");
DO_TEST("openvswitch-net");
DO_TEST_FULL("passthrough-pf", VIR_NETWORK_XML_INACTIVE);
+ DO_TEST("hostdev");
+ DO_TEST_FULL("hostdev-pf", VIR_NETWORK_XML_INACTIVE);
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
}