[PATCHv2] libxl: set IP address when creating NIC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ji-hoon Kim <relip@xxxxxx>

Currently libxlMakeNic() does not set ip address when creating NIC,
this patch makes it to set ip address.

Signed-off-by: Ji-hoon Kim <relip@xxxxxx>
---
 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,
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]