diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ab89dab61e..38590a6821 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4034,27 +4034,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index def3099a99..81bc93de05 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2182,8 +2182,6 @@ virDomainHostdevSubsysSCSIiSCSIClear(virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc
void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
{
- size_t i;
-
if (!def)
return;
@@ -2207,13 +2205,8 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
VIR_FREE(def->source.caps.u.misc.chardev);
break;
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
- VIR_FREE(def->source.caps.u.net.iface);
- for (i = 0; i < def->source.caps.u.net.nips; i++)
- VIR_FREE(def->source.caps.u.net.ips[i]);
- VIR_FREE(def->source.caps.u.net.ips);
- for (i = 0; i < def->source.caps.u.net.nroutes; i++)
- virNetDevIPRouteFree(def->source.caps.u.net.routes[i]);
- VIR_FREE(def->source.caps.u.net.routes);
+ VIR_FREE(def->source.caps.u.net.ifname);
+ virNetDevIPInfoClear(&def->source.caps.u.net.ip);
break;
}
break;
@@ -6240,10 +6233,6 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
virDomainHostdevDefPtr def)
{
xmlNodePtr sourcenode;
- xmlNodePtr *ipnodes = NULL;
- int nipnodes;
- xmlNodePtr *routenodes = NULL;
- int nroutenodes;
int ret = -1;
/* @type is passed in from the caller rather than read from the
@@ -6292,55 +6281,15 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
}
break;
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
- if (!(def->source.caps.u.net.iface =
+ if (!(def->source.caps.u.net.ifname =
virXPathString("string(./source/interface[1])", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing element in hostdev net device"));
goto error;
}
-
- /* Parse possible IP addresses */
- if ((nipnodes = virXPathNodeSet("./ip", ctxt, &ipnodes)) < 0)
+ if (virDomainNetIPInfoParseXML(_("Domain hostdev device"),
+ ctxt, &def->source.caps.u.net.ip) < 0)
goto error;
-
- if (nipnodes) {
- size_t i;
- for (i = 0; i < nipnodes; i++) {
- virNetDevIPAddrPtr ip = virDomainNetIPParseXML(ipnodes[i]);
-
- if (!ip)
- goto error;
-
- if (VIR_APPEND_ELEMENT(def->source.caps.u.net.ips,
- def->source.caps.u.net.nips, ip) < 0) {
- VIR_FREE(ip);
- goto error;
- }
- }
- }
-
- /* Look for possible gateways */
- if ((nroutenodes = virXPathNodeSet("./route", ctxt, &routenodes)) < 0)
- goto error;
-
- if (nroutenodes) {
- size_t i;
- for (i = 0; i < nroutenodes; i++) {
- virNetDevIPRoutePtr route = NULL;
-
- if (!(route = virNetDevIPRouteParseXML(_("Domain hostdev device"),
- routenodes[i],
- ctxt)))
- goto error;
-
-
- if (VIR_APPEND_ELEMENT(def->source.caps.u.net.routes,
- def->source.caps.u.net.nroutes, route) < 0) {
- virNetDevIPRouteFree(route);
- goto error;
- }
- }
- }
break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -6350,8 +6299,6 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
}
ret = 0;
error:
- VIR_FREE(ipnodes);
- VIR_FREE(routenodes);
return ret;
}
@@ -13728,8 +13675,8 @@ static int
virDomainHostdevMatchCapsNet(virDomainHostdevDefPtr a,
virDomainHostdevDefPtr b)
{
- return STREQ_NULLABLE(a->source.caps.u.net.iface,
- b->source.caps.u.net.iface);
+ return STREQ_NULLABLE(a->source.caps.u.net.ifname,
+ b->source.caps.u.net.ifname);
}
@@ -20522,7 +20469,7 @@ virDomainHostdevDefFormatCaps(virBufferPtr buf,
break;
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
virBufferEscapeString(buf, "%s\n",
- def->source.caps.u.net.iface);
+ def->source.caps.u.net.ifname);
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -20534,14 +20481,9 @@ virDomainHostdevDefFormatCaps(virBufferPtr buf,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "\n");
- if (def->source.caps.type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) {
- if (virDomainNetIPsFormat(buf, def->source.caps.u.net.ips,
- def->source.caps.u.net.nips) < 0)
- return -1;
- if (virDomainNetRoutesFormat(buf, def->source.caps.u.net.routes,
- def->source.caps.u.net.nroutes) < 0)
- return -1;
- }
+ if (def->source.caps.type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET &&
+ virDomainNetIPInfoFormat(buf, &def->source.caps.u.net.ip) < 0)
+ return -1;
return 0;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6f9c536fe3..45094d710e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -395,11 +395,8 @@ struct _virDomainHostdevCaps {
char *chardev;
} misc;
struct {
- char *iface;
- size_t nips;
- virNetDevIPAddrPtr *ips;
- size_t nroutes;
- virNetDevIPRoutePtr *routes;
+ char *ifname;
+ virNetDevIPInfo ip;
} net;
} u;
};
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 2aee41c193..e58ff1b6b0 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1984,7 +1984,7 @@ static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
continue;
- if (virNetDevSetNamespace(hdcaps.u.net.iface, ctrl->initpid) < 0)
+ if (virNetDevSetNamespace(hdcaps.u.net.ifname, ctrl->initpid) < 0)
return -1;
}
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 5450c5d973..c261b88184 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -402,7 +402,7 @@ lxcCreateHostdevDef(int mode, int type, const char *data)
hostdev->source.caps.type = type;
if (type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET &&
- VIR_STRDUP(hostdev->source.caps.u.net.iface, data) < 0) {
+ VIR_STRDUP(hostdev->source.caps.u.net.ifname, data) < 0) {
virDomainHostdevDefFree(hostdev);
hostdev = NULL;
}
@@ -492,25 +492,25 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
/* This still requires the user to manually setup the vlan interface
* on the host */
if (isVlan && data->vlanid) {
- VIR_FREE(hostdev->source.caps.u.net.iface);
- if (virAsprintf(&hostdev->source.caps.u.net.iface,
+ VIR_FREE(hostdev->source.caps.u.net.ifname);
+ if (virAsprintf(&hostdev->source.caps.u.net.ifname,
"%s.%s", data->link, data->vlanid) < 0)
goto error;
}
- hostdev->source.caps.u.net.ips = data->ips;
- hostdev->source.caps.u.net.nips = data->nips;
+ hostdev->source.caps.u.net.ip.ips = data->ips;
+ hostdev->source.caps.u.net.ip.nips = data->nips;
if (data->gateway_ipv4 &&
lxcAddNetworkRouteDefinition(data->gateway_ipv4, AF_INET,
- &hostdev->source.caps.u.net.routes,
- &hostdev->source.caps.u.net.nroutes) < 0)
+ &hostdev->source.caps.u.net.ip.routes,
+ &hostdev->source.caps.u.net.ip.nroutes) < 0)
goto error;
if (data->gateway_ipv6 &&
lxcAddNetworkRouteDefinition(data->gateway_ipv6, AF_INET6,
- &hostdev->source.caps.u.net.routes,
- &hostdev->source.caps.u.net.nroutes) < 0)
+ &hostdev->source.caps.u.net.ip.routes,
+ &hostdev->source.caps.u.net.ip.nroutes) < 0)
goto error;
if (VIR_EXPAND_N(data->def->hostdevs, data->def->nhostdevs, 1) < 0)