
Jihoon Kim wrote:
From: Ji-hoon Kim <relip@me.com>
Currently libxlMakeNic() does not set ip address when creating NIC, this patch makes it to set ip address.
FYI, Marek recently sent a patch to do the same https://www.redhat.com/archives/libvir-list/2015-February/msg00139.html I like Marek's error checking for multiple IPs in libxlDomainDeviceDefPostParse(), but do think that <ip address=''> should also be supported for <interface type=network>. Regards, Jim
Signed-off-by: Ji-hoon Kim <relip@me.com> --- src/libxl/libxl_conf.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 0555b91..e49715d 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1042,6 +1042,20 @@ libxlMakeNic(virDomainDefPtr def, if (VIR_STRDUP(x_nic->ifname, l_nic->ifname) < 0) return -1;
+ if (l_nic->nips == 1) { + char *ipStr = virSocketAddrFormat(&l_nic->ips[0]->address); + if (VIR_STRDUP(x_nic->ip, ipStr) < 0) { + VIR_FREE(ipStr); + return -1; + } + VIR_FREE(ipStr); + } + else if (l_nic->nips > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Driver does not support setting multiple IP addresses")); + return -1; + } + switch (actual_type) { case VIR_DOMAIN_NET_TYPE_BRIDGE: if (VIR_STRDUP(x_nic->bridge,