]> xenbits.xensource.com Git - people/tklengyel/xen.git/commitdiff
xl/libxl: treat vif "ip" fields as a simple string
authorIan Campbell <ian.campbell@citrix.com>
Fri, 25 Feb 2011 17:03:55 +0000 (17:03 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 25 Feb 2011 17:03:55 +0000 (17:03 +0000)
Currently we parse the string as an IPv4 address but this does not
handle IPv6. We then format the IP address as a string into xenstore.
Rather than add further parsing and formatting to support IPv6 simply
treat the field as a string, which it turns out is all xend does.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl.idl
tools/libxl/libxltypes.py
tools/libxl/xl_cmdimpl.c

index 1f7a529dbcde0dca15c031b279b26e72bfc204b8..d0b2f74912254bad6654b81cb82a7a7d465e40ce 100644 (file)
@@ -31,8 +31,6 @@
 #include <inttypes.h>
 #include <assert.h>
 
-#include <arpa/inet.h>
-
 #include "libxl.h"
 #include "libxl_utils.h"
 #include "libxl_internal.h"
@@ -1175,7 +1173,7 @@ int libxl_device_nic_init(libxl_device_nic *nic_info, int devnum)
     nic_info->mac[5] = r[2];
     nic_info->ifname = NULL;
     nic_info->bridge = strdup("xenbr0");
-    nic_info->ip.s_addr = 0UL;
+    nic_info->ip = NULL;
     if ( asprintf(&nic_info->script, "%s/vif-bridge",
                libxl_xen_script_dir_path()) < 0 )
         return ERROR_FAIL;
@@ -1235,16 +1233,11 @@ int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic)
     flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",
                                                  nic->mac[0], nic->mac[1], nic->mac[2],
                                                  nic->mac[3], nic->mac[4], nic->mac[5]));
-    if (nic->ip.s_addr != 0UL) {
-        char dst[INET_ADDRSTRLEN];
-        const char *addr = inet_ntop(AF_INET, &nic->ip.s_addr, &dst[0], INET_ADDRSTRLEN);
-        if (addr) {
-            flexarray_append(back, "ip");
-            flexarray_append(back, libxl__strdup(&gc, addr));
-        } else {
-            LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "Unable to format IP address");
-        }
+    if (nic->ip) {
+        flexarray_append(back, "ip");
+        flexarray_append(back, libxl__strdup(&gc, nic->ip));
     }
+
     flexarray_append(back, "bridge");
     flexarray_append(back, libxl__strdup(&gc, nic->bridge));
     flexarray_append(back, "handle");
index 2cfede4dc2bbbb390ca96f352e98fb8a7543a9ff..377417a8c88809b291bb6732075e16ea633f70b7 100644 (file)
@@ -220,7 +220,7 @@ libxl_device_nic = Struct("device_nic", [
     ("mtu", integer),
     ("model", string),
     ("mac", libxl_mac),
-    ("ip", inaddr_ip),
+    ("ip", string),
     ("bridge", string),
     ("ifname", string),
     ("script", string),
index 53b0d25392252c5c3221b69414b01c83b0809bcb..9c9e6427e75829f07c73ad0667ab49a84de6ca3c 100644 (file)
@@ -159,8 +159,6 @@ domid = UInt(32)
 
 string = Builtin("char *", namespace = None, destructor_fn = "free")
 
-inaddr_ip = Builtin("struct in_addr", namespace = None)
-
 class OrderedDict(dict):
     """A dictionary which remembers insertion order.
 
index 9822e99401445d93005ac1eccef3fad01ef3c846..0fad4711ce4421a78bac567cd680d0ea8185aff9 100644 (file)
@@ -30,7 +30,6 @@
 #include <signal.h>
 #include <sys/socket.h>
 #include <sys/select.h>
-#include <arpa/inet.h>
 #include <sys/utsname.h> /* for utsname in xl info */
 #include <xenctrl.h>
 #include <ctype.h>
@@ -843,7 +842,8 @@ static void parse_config_data(const char *configfile_filename_report,
                     else
                         nic->nictype = NICTYPE_VIF;
                 } else if (!strcmp(p, "ip")) {
-                    inet_pton(AF_INET, p2 + 1, &nic->ip);
+                    free(nic->ip);
+                    nic->ip = strdup(p2 + 1);
                 } else if (!strcmp(p, "script")) {
                     free(nic->script);
                     nic->script = strdup(p2 + 1);
@@ -4257,10 +4257,8 @@ int main_networkattach(int argc, char **argv)
         } else if (!strncmp("bridge=", *argv, 7)) {
             nic.bridge = (*argv) + 7;
         } else if (!strncmp("ip=", *argv, 3)) {
-            if (!inet_aton((*argv) + 3, &(nic.ip))) {
-                fprintf(stderr, "Invalid parameter `ip'.\n");
-                return 1;
-            }
+            free(nic.ip);
+            nic.ip = strdup((*argv) + 3);
         } else if (!strncmp("script=", *argv, 6)) {
             nic.script = (*argv) + 6;
         } else if (!strncmp("backend=", *argv, 8)) {