All the same information was already there, just in slightly different
places in the virDomainNetDef.
---
docs/schemas/domaincommon.rng | 22 +------------------
src/conf/domain_conf.c | 50 ++++++-------------------------------------
src/conf/domain_conf.h | 7 ++----
src/libxl/libxl_conf.c | 10 ++++-----
src/libxl/libxl_domain.c | 2 +-
src/lxc/lxc_container.c | 10 ++++-----
src/lxc/lxc_native.c | 12 +++++------
src/openvz/openvz_driver.c | 10 ++++-----
src/uml/uml_conf.c | 4 ++--
src/vbox/vbox_common.c | 6 +++---
src/vz/vz_sdk.c | 2 +-
src/xenconfig/xen_common.c | 12 +++++------
src/xenconfig/xen_sxpr.c | 12 +++++------
13 files changed, 49 insertions(+), 110 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 38590a6..563cb3c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2420,27 +2420,7 @@
<empty/>
</element>
</optional>
- <zeroOrMore>
- <element name="ip">
- <attribute name="address">
- <ref name="ipAddr"/>
- </attribute>
- <optional>
- <attribute name="family">
- <ref name="addr-family"/>
- </attribute>
- </optional>
- <optional>
- <attribute name="prefix">
- <ref name="ipPrefix"/>
- </attribute>
- </optional>
- <empty/>
- </element>
- </zeroOrMore>
- <zeroOrMore>
- <ref name="route"/>
- </zeroOrMore>
+ <ref name="interface-ip-info"/>
<optional>
<element name="script">
<attribute name="path">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7072f86..9dcfb57 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1740,8 +1740,6 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr def)
void
virDomainNetDefClear(virDomainNetDefPtr def)
{
- size_t i;
-
if (!def)
return;
@@ -1801,14 +1799,7 @@ virDomainNetDefClear(virDomainNetDefPtr def)
VIR_FREE(def->ifname_guest);
VIR_FREE(def->ifname_guest_actual);
- for (i = 0; i < def->nips; i++)
- VIR_FREE(def->ips[i]);
- VIR_FREE(def->ips);
-
- for (i = 0; i < def->nroutes; i++)
- virNetDevIPRouteFree(def->routes[i]);
- VIR_FREE(def->routes);
-
+ virNetDevIPInfoClear(&def->guestIP);
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def->filter);
@@ -8890,7 +8881,7 @@ virDomainNetAppendIPAddress(virDomainNetDefPtr def,
goto error;
ipDef->prefix = prefix;
- if (VIR_APPEND_ELEMENT(def->ips, def->nips, ipDef) < 0)
+ if (VIR_APPEND_ELEMENT(def->guestIP.ips, def->guestIP.nips, ipDef) < 0)
goto error;
return 0;
@@ -8952,11 +8943,6 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
virDomainActualNetDefPtr actual = NULL;
xmlNodePtr oldnode = ctxt->node;
int ret, val;
- size_t i;
- size_t nips = 0;
- virNetDevIPAddrPtr *ips = NULL;
- size_t nroutes = 0;
- virNetDevIPRoutePtr *routes = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
@@ -9072,24 +9058,6 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
localport = virXPathString("string(./local/@port)", ctxt);
ctxt->node = tmpnode;
}
- } else if (xmlStrEqual(cur->name, BAD_CAST "ip")) {
- virNetDevIPAddrPtr ip = NULL;
-
- if (!(ip = virDomainNetIPParseXML(cur)))
- goto error;
-
- if (VIR_APPEND_ELEMENT(ips, nips, ip) < 0)
- goto error;
- } else if (xmlStrEqual(cur->name, BAD_CAST "route")) {
- virNetDevIPRoutePtr route = NULL;
- if (!(route = virNetDevIPRouteParseXML(_("Domain interface"),
- cur, ctxt)))
- goto error;
-
- if (VIR_APPEND_ELEMENT(routes, nroutes, route) < 0) {
- virNetDevIPRouteFree(route);
- goto error;
- }
} else if (!ifname &&
xmlStrEqual(cur->name, BAD_CAST "target")) {
ifname = virXMLPropString(cur, "dev");
@@ -9412,12 +9380,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
break;
}
- for (i = 0; i < nips; i++) {
- if (VIR_APPEND_ELEMENT(def->ips, def->nips, ips[i]) < 0)
- goto error;
- }
- def->nroutes = nroutes;
- def->routes = routes;
+ if (virDomainNetIPInfoParseXML(_("guest interface"),
+ ctxt, &def->guestIP) < 0)
+ goto error;
if (script != NULL) {
def->script = script;
@@ -9699,7 +9664,6 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
VIR_FREE(addrtype);
VIR_FREE(domain_name);
VIR_FREE(trustGuestRxFilters);
- VIR_FREE(ips);
VIR_FREE(vhost_path);
VIR_FREE(localaddr);
VIR_FREE(localport);
@@ -20891,9 +20855,7 @@ virDomainNetDefFormat(virBufferPtr buf,
return -1;
}
- if (virDomainNetIPsFormat(buf, def->ips, def->nips) < 0)
- return -1;
- if (virDomainNetRoutesFormat(buf, def->routes, def->nroutes) < 0)
+ if (virDomainNetIPInfoFormat(buf, &def->guestIP) < 0)
return -1;
virBufferEscapeString(buf, "<script path='%s'/>\n",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0c723de..0df5579 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -966,8 +966,9 @@ struct _virDomainNetDef {
char *script;
char *domain_name; /* backend domain name */
char *ifname;
- char *ifname_guest;
char *ifname_guest_actual;
+ char *ifname_guest;
+ virNetDevIPInfo guestIP;
virDomainDeviceInfo info;
char *filter;
virNWFilterHashTablePtr filterparams;
@@ -975,10 +976,6 @@ struct _virDomainNetDef {
virNetDevVlan vlan;
int trustGuestRxFilters; /* enum virTristateBool */
int linkstate;
- size_t nips;
- virNetDevIPAddrPtr *ips;
- size_t nroutes;
- virNetDevIPRoutePtr *routes;
};
/* Used for prefix of ifname of any network name generated dynamically
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 5989819..eb10156 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1,7 +1,7 @@
/*
* libxl_conf.c: libxl configuration management
*
- * Copyright (C) 2012-2014 Red Hat, Inc.
+ * Copyright (C) 2012-2014, 2016 Red Hat, Inc.
* Copyright (c) 2011-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
* Copyright (C) 2011 Univention GmbH.
*
@@ -908,8 +908,8 @@ libxlMakeNic(virDomainDefPtr def,
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
goto cleanup;
- if (l_nic->nips > 0) {
- x_nic->ip = virSocketAddrFormat(&l_nic->ips[0]->address);
+ if (l_nic->guestIP.nips > 0) {
+ x_nic->ip =
virSocketAddrFormat(&l_nic->guestIP.ips[0]->address);
if (!x_nic->ip)
goto cleanup;
}
@@ -924,8 +924,8 @@ libxlMakeNic(virDomainDefPtr def,
goto cleanup;
}
- if (l_nic->nips > 0) {
- x_nic->ip = virSocketAddrFormat(&l_nic->ips[0]->address);
+ if (l_nic->guestIP.nips > 0) {
+ x_nic->ip =
virSocketAddrFormat(&l_nic->guestIP.ips[0]->address);
if (!x_nic->ip)
goto cleanup;
}
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 221af87..6f76cae 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -296,7 +296,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
(dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_ETHERNET ||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK)) {
- if (dev->data.net->nips > 1) {
+ if (dev->data.net->guestIP.nips > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("multiple IP addresses not supported on device type
%s"),
virDomainNetTypeToString(dev->data.net->type));
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 1000d88..a5ced92 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -512,8 +512,8 @@ static int lxcContainerRenameAndEnableInterfaces(virDomainDefPtr
vmDef,
if (rc < 0)
goto error_out;
- for (j = 0; j < netDef->nips; j++) {
- virNetDevIPAddrPtr ip = netDef->ips[j];
+ for (j = 0; j < netDef->guestIP.nips; j++) {
+ virNetDevIPAddrPtr ip = netDef->guestIP.ips[j];
int prefix;
char *ipStr = virSocketAddrFormat(&ip->address);
@@ -537,7 +537,7 @@ static int lxcContainerRenameAndEnableInterfaces(virDomainDefPtr
vmDef,
VIR_FREE(ipStr);
}
- if (netDef->nips ||
+ if (netDef->guestIP.nips ||
netDef->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP) {
VIR_DEBUG("Enabling %s", newname);
rc = virNetDevSetOnline(newname, true);
@@ -545,8 +545,8 @@ static int lxcContainerRenameAndEnableInterfaces(virDomainDefPtr
vmDef,
goto error_out;
/* Set the routes */
- for (j = 0; j < netDef->nroutes; j++) {
- virNetDevIPRoutePtr route = netDef->routes[j];
+ for (j = 0; j < netDef->guestIP.nroutes; j++) {
+ virNetDevIPRoutePtr route = netDef->guestIP.routes[j];
if (virNetDevIPRouteAdd(newname,
virNetDevIPRouteGetAddress(route),
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index f074f03..e1dde3a 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -522,19 +522,19 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
data->name)))
goto error;
- net->ips = data->ips;
- net->nips = data->nips;
+ net->guestIP.ips = data->ips;
+ net->guestIP.nips = data->nips;
if (data->gateway_ipv4 &&
lxcAddNetworkRouteDefinition(data->gateway_ipv4, AF_INET,
- &net->routes,
- &net->nroutes) < 0)
+ &net->guestIP.routes,
+ &net->guestIP.nroutes) < 0)
goto error;
if (data->gateway_ipv6 &&
lxcAddNetworkRouteDefinition(data->gateway_ipv6, AF_INET6,
- &net->routes,
- &net->nroutes) < 0)
+ &net->guestIP.routes,
+ &net->guestIP.nroutes) < 0)
goto error;
if (VIR_EXPAND_N(data->def->nets, data->def->nnets, 1) < 0)
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index b114246..48c264b 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1,7 +1,7 @@
/*
* openvz_driver.c: core driver methods for managing OpenVZ VEs
*
- * Copyright (C) 2010-2015 Red Hat, Inc.
+ * Copyright (C) 2010-2016 Red Hat, Inc.
* Copyright (C) 2006, 2007 Binary Karma
* Copyright (C) 2006 Shuveb Hussain
* Copyright (C) 2007 Anoop Joe Cyriac
@@ -856,7 +856,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
(net->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
- net->nips == 0)) {
+ net->guestIP.nips == 0)) {
virBuffer buf = VIR_BUFFER_INITIALIZER;
int veid = openvzGetVEID(vpsid);
@@ -906,12 +906,12 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
virCommandAddArg(cmd, "--netif_add");
virCommandAddArgBuffer(cmd, &buf);
} else if (net->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
- net->nips > 0) {
+ net->guestIP.nips > 0) {
size_t i;
/* --ipadd ip */
- for (i = 0; i < net->nips; i++) {
- char *ipStr = virSocketAddrFormat(&net->ips[i]->address);
+ for (i = 0; i < net->guestIP.nips; i++) {
+ char *ipStr = virSocketAddrFormat(&net->guestIP.ips[i]->address);
if (!ipStr)
goto cleanup;
virCommandAddArgList(cmd, "--ipadd", ipStr, NULL);
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index a97ae64..dc68203 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -1,7 +1,7 @@
/*
* uml_conf.c: UML driver configuration
*
- * Copyright (C) 2006-2014 Red Hat, Inc.
+ * Copyright (C) 2006-2014, 2016 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -173,7 +173,7 @@ umlBuildCommandLineNet(virConnectPtr conn,
virBufferAddLit(&buf, "tuntap,");
if (def->ifname)
virBufferAdd(&buf, def->ifname, -1);
- if (def->nips > 0) {
+ if (def->guestIP.nips > 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("IP address not supported for ethernet
interface"));
goto error;
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 6dd5b9c..8e49268 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -1313,11 +1313,11 @@ vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data,
IMachine *machine)
} else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
VIR_DEBUG("NIC(%zu): brname: %s", i,
def->nets[i]->data.bridge.brname);
VIR_DEBUG("NIC(%zu): script: %s", i, def->nets[i]->script);
- if (def->nets[i]->nips == 1) {
- char *ipStr =
virSocketAddrFormat(&def->nets[i]->ips[0]->address);
+ if (def->nets[i]->guestIP.nips == 1) {
+ char *ipStr =
virSocketAddrFormat(&def->nets[i]->guestIP.ips[0]->address);
VIR_DEBUG("NIC(%zu): ipaddr: %s", i, ipStr);
VIR_FREE(ipStr);
- } else if (def->nets[i]->nips > 1) {
+ } else if (def->nets[i]->guestIP.nips > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Driver does not support setting multiple IP
addresses"));
return -1;
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index cb06240..5c92f97 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -2566,7 +2566,7 @@ static int prlsdkCheckNetUnsupportedParams(virDomainNetDefPtr net)
return -1;
}
- if (net->ifname_guest) {
+ if (net->guestIf.name) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Setting guest interface name is not "
"supported by vz driver."));
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 2fe29fd..f62a5b1 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -1153,11 +1153,11 @@ xenFormatNet(virConnectPtr conn,
switch (net->type) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
virBufferAsprintf(&buf, ",bridge=%s", net->data.bridge.brname);
- if (net->nips == 1) {
- char *ipStr = virSocketAddrFormat(&net->ips[0]->address);
+ if (net->guestIP.nips == 1) {
+ char *ipStr = virSocketAddrFormat(&net->guestIP.ips[0]->address);
virBufferAsprintf(&buf, ",ip=%s", ipStr);
VIR_FREE(ipStr);
- } else if (net->nips > 1) {
+ } else if (net->guestIP.nips > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Driver does not support setting multiple IP
addresses"));
goto cleanup;
@@ -1168,11 +1168,11 @@ xenFormatNet(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (net->script)
virBufferAsprintf(&buf, ",script=%s", net->script);
- if (net->nips == 1) {
- char *ipStr = virSocketAddrFormat(&net->ips[0]->address);
+ if (net->guestIP.nips == 1) {
+ char *ipStr = virSocketAddrFormat(&net->guestIP.ips[0]->address);
virBufferAsprintf(&buf, ",ip=%s", ipStr);
VIR_FREE(ipStr);
- } else if (net->nips > 1) {
+ } else if (net->guestIP.nips > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Driver does not support setting multiple IP
addresses"));
goto cleanup;
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index 21de1a2..ea6c177 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -1875,11 +1875,11 @@ xenFormatSxprNet(virConnectPtr conn,
script = def->script;
virBufferEscapeSexpr(buf, "(script '%s')", script);
- if (def->nips == 1) {
- char *ipStr = virSocketAddrFormat(&def->ips[0]->address);
+ if (def->guestIP.nips == 1) {
+ char *ipStr = virSocketAddrFormat(&def->guestIP.ips[0]->address);
virBufferEscapeSexpr(buf, "(ip '%s')", ipStr);
VIR_FREE(ipStr);
- } else if (def->nips > 1) {
+ } else if (def->guestIP.nips > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Driver does not support setting multiple IP
addresses"));
return -1;
@@ -1916,11 +1916,11 @@ xenFormatSxprNet(virConnectPtr conn,
if (def->script)
virBufferEscapeSexpr(buf, "(script '%s')",
def->script);
- if (def->nips == 1) {
- char *ipStr = virSocketAddrFormat(&def->ips[0]->address);
+ if (def->guestIP.nips == 1) {
+ char *ipStr = virSocketAddrFormat(&def->guestIP.ips[0]->address);
virBufferEscapeSexpr(buf, "(ip '%s')", ipStr);
VIR_FREE(ipStr);
- } else if (def->nips > 1) {
+ } else if (def->guestIP.nips > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Driver does not support setting multiple IP
addresses"));
return -1;
--
2.5.5