libxl: pass ipaddr to libxl toolstack

Do not silently ignore its value. LibXL support only one address, so
refuse multiple IPs.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
This commit is contained in:
Marek Marczykowski-Górecki 2015-02-10 03:17:23 +01:00 committed by Jim Fehlig
parent 104ba5966a
commit 8703ee58bd
2 changed files with 23 additions and 0 deletions

View File

@ -1051,6 +1051,11 @@ libxlMakeNic(virDomainDefPtr def,
case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (VIR_STRDUP(x_nic->script, l_nic->script) < 0) if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
return -1; return -1;
if (l_nic->nips > 0) {
x_nic->ip = virSocketAddrFormat(&l_nic->ips[0]->address);
if (!x_nic->ip)
return -1;
}
break; break;
case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_NETWORK:
{ {
@ -1068,6 +1073,12 @@ libxlMakeNic(virDomainDefPtr def,
return -1; return -1;
} }
if (l_nic->nips > 0) {
x_nic->ip = virSocketAddrFormat(&l_nic->ips[0]->address);
if (!x_nic->ip)
return -1;
}
if ((brname = virNetworkGetBridgeName(network))) { if ((brname = virNetworkGetBridgeName(network))) {
if (VIR_STRDUP(x_nic->bridge, brname) < 0) if (VIR_STRDUP(x_nic->bridge, brname) < 0)
fail = true; fail = true;

View File

@ -482,6 +482,18 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
STRNEQ(def->os.type, "hvm")) STRNEQ(def->os.type, "hvm"))
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
(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) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("multiple IP addresses not supported on device type %s"),
virDomainNetTypeToString(dev->data.net->type));
return -1;
}
}
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV || if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV ||
(dev->type == VIR_DOMAIN_DEVICE_NET && (dev->type == VIR_DOMAIN_DEVICE_NET &&
dev->data.net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) { dev->data.net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) {