]> xenbits.xensource.com Git - people/tklengyel/xen.git/commitdiff
libxl/xl: enable support for routed network configurations.
authorIan Campbell <ian.campbell@citrix.com>
Fri, 18 Feb 2011 15:32:02 +0000 (15:32 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 18 Feb 2011 15:32:02 +0000 (15:32 +0000)
Add "vifscript" option to xl.conf which configures the default vif
script to use (default remains "vif-bridge")

Write each VIFs "ip" option to xenstore so the vif-route script can
pick it up.

Reported-by: W. Michael Petullo <mike@flyn.org>.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/examples/xl.conf
tools/libxl/libxl.c
tools/libxl/xl.c
tools/libxl/xl.h
tools/libxl/xl_cmdimpl.c

index 09a3d46615b78d1e7b9d7c0fad9d61620f8214ba..6a520bf24bd0cdf346de3e09f0d5e6728b5040bc 100644 (file)
@@ -6,3 +6,6 @@
 
 # full path of the lockfile used by xl during domain creation
 #lockfile="/var/lock/xl"
+
+# default vif script 
+#vifscript="vif-bridge"
index 09cf3d948c8acf2a0aeb80b11faf7903c60053ac..1f7a529dbcde0dca15c031b279b26e72bfc204b8 100644 (file)
@@ -31,6 +31,8 @@
 #include <inttypes.h>
 #include <assert.h>
 
+#include <arpa/inet.h>
+
 #include "libxl.h"
 #include "libxl_utils.h"
 #include "libxl_internal.h"
@@ -1173,6 +1175,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;
     if ( asprintf(&nic_info->script, "%s/vif-bridge",
                libxl_xen_script_dir_path()) < 0 )
         return ERROR_FAIL;
@@ -1232,6 +1235,16 @@ 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");
+        }
+    }
     flexarray_append(back, "bridge");
     flexarray_append(back, libxl__strdup(&gc, nic->bridge));
     flexarray_append(back, "handle");
index 2ad117f56de2def53ca3da2ca2cabb29a7b56a31..9e3023c629cb0c79d877532aa61082ece3a462cb 100644 (file)
@@ -35,6 +35,7 @@
 xentoollog_logger_stdiostream *logger;
 int autoballoon = 1;
 char *lockfile;
+char *default_vifscript = NULL;
 
 static xentoollog_level minmsglevel = XTL_PROGRESS;
 
@@ -72,6 +73,9 @@ static void parse_global_config(const char *configfile,
         }
     }
 
+    if (!xlu_cfg_get_string (config, "vifscript", &buf))
+        default_vifscript = strdup(buf);
+
     xlu_cfg_destroy(config);
 }
  
index bb3aca23ed1f088f42c8f2cde13a54dbc63c24c9..653be2e982da29a246f75d2f49da3699b6b0211b 100644 (file)
@@ -101,5 +101,6 @@ extern xentoollog_logger_stdiostream *logger;
 /* global options */
 extern int autoballoon;
 extern char *lockfile;
+extern char *default_vifscript;
 
 #endif /* XL_H */
index 3bbd23938250bd360104c9ce9b092e5fddb6e8eb..9822e99401445d93005ac1eccef3fad01ef3c846 100644 (file)
@@ -798,6 +798,11 @@ static void parse_config_data(const char *configfile_filename_report,
             nic = d_config->vifs + d_config->num_vifs;
             CHK_ERRNO( libxl_device_nic_init(nic, d_config->num_vifs) );
 
+            if (default_vifscript) {
+                free(nic->script);
+                nic->script = strdup(default_vifscript);
+            }
+
             p = strtok(buf2, ",");
             if (!p)
                 goto skip;