提交 a861054f 编写于 作者: M Marek Marczykowski-Górecki 提交者: Jim Fehlig

xenconfig: add support for multiple IP addresses

Xen's xl config format has long supported specifying multiple IP
addresses for virtual interfaces. E.g.

vif = [ "ip=10.0.0.1 10.1.1.1 2000::1, ..." ]

Add support for converting multiple IP addresses to/from domXML.
Reviewed-by: NJim Fehlig <jfehlig@suse.com>
上级 82ef04fe
......@@ -847,7 +847,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def, const char *vif_typename)
while (list) {
char model[10];
char type[10];
char ip[16];
char ip[128];
char mac[18];
char bridge[50];
char vifname[50];
......@@ -964,8 +964,18 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def, const char *vif_typename)
if (bridge[0] && VIR_STRDUP(net->data.bridge.brname, bridge) < 0)
goto cleanup;
}
if (ip[0] && virDomainNetAppendIPAddress(net, ip, AF_INET, 0) < 0)
goto cleanup;
if (ip[0]) {
char **ip_list = virStringSplit(ip, " ", 0);
size_t i;
for (i = 0; ip_list[i]; i++) {
if (virDomainNetAppendIPAddress(net, ip_list[i], 0, 0) < 0) {
virStringListFree(ip_list);
goto cleanup;
}
}
virStringListFree(ip_list);
}
if (script && script[0] &&
VIR_STRDUP(net->script, script) < 0)
......@@ -1207,14 +1217,10 @@ xenFormatNet(virConnectPtr conn,
switch (net->type) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
virBufferAsprintf(&buf, ",bridge=%s", net->data.bridge.brname);
if (net->guestIP.nips == 1) {
char *ipStr = virSocketAddrFormat(&net->guestIP.ips[0]->address);
if (net->guestIP.nips > 0) {
char *ipStr = xenMakeIPList(&net->guestIP);
virBufferAsprintf(&buf, ",ip=%s", ipStr);
VIR_FREE(ipStr);
} else if (net->guestIP.nips > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Driver does not support setting multiple IP addresses"));
goto cleanup;
}
virBufferAsprintf(&buf, ",script=%s", DEFAULT_VIF_SCRIPT);
break;
......@@ -1222,14 +1228,10 @@ xenFormatNet(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (net->script)
virBufferAsprintf(&buf, ",script=%s", net->script);
if (net->guestIP.nips == 1) {
char *ipStr = virSocketAddrFormat(&net->guestIP.ips[0]->address);
if (net->guestIP.nips > 0) {
char *ipStr = xenMakeIPList(&net->guestIP);
virBufferAsprintf(&buf, ",ip=%s", ipStr);
VIR_FREE(ipStr);
} else if (net->guestIP.nips > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Driver does not support setting multiple IP addresses"));
goto cleanup;
}
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册