WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Recent xl and network-route scripts

To: "W. Michael Petullo" <mike@xxxxxxxx>
Subject: Re: [Xen-devel] Recent xl and network-route scripts
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Thu, 17 Feb 2011 10:10:09 +0000
Cc: Todd Deshane <todd.deshane@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 17 Feb 2011 02:11:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1297934374.16356.1364.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <20110217011331.GA3090@xxxxxxxxx> <20110217072944.GA5345@xxxxxxxxxxx> <1297934374.16356.1364.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Thu, 2011-02-17 at 09:19 +0000, Ian Campbell wrote:
> I'll see if I can out a patch together for both of these issues shortly.

Does this work for you?

I don't have a routed setup handy to try it myself but I have verified
that the things appear in xenstore as I would expect.

You will need to edit/create /etc/xen/xl.conf and add:
        vifscript = "vif-route"

You will also need to ensure your host network is setup appropriately
since one difference between xm and xl is that xl does not attempt to
reconfigure the host network instead leaving this up to distro provided
tools etc.

Looking at the network-route script it seems that it should be
sufficient to (assuming eth0 is your physical device):
        echo 1 >/proc/sys/net/ipv4/ip_forward
        echo 1 >/proc/sys/net/ipv4/conf/eth0/proxy_arp
which I think is equivalent to adding the following to /etc/sysctl.conf
and running "sysctl -f" (this method will persist over reboot too)
        sys.net.ipv4.ip_forward = 1
        sys.net.ipv4.conf.eth0.proxy_arp = 1

(Pasi, Todd: this would be a useful addition to the
http://wiki.xensource.com/xenwiki/MigrationGuideToXen4.1+
page)

If this doesn't help then it would be useful to see the result of 
        xenstore-ls /local/domain/0/backends/vif/<domid>/0
        echo
        xenstore-ls /local/domain/<domid>/device/vif/0
when the domain is running from both xl and xm.

Ian.

8<------------------------------------

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1297936972 0
# Node ID c529d4d7d79ba3fe69ffb6cbacac5c9e3e5cf246
# Parent  1728ed4bbec9e82ca13c2639c8e4ef8b4dc231b6
libxl/xl: enable support for routed network configurations.

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@xxxxxxxx>.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 1728ed4bbec9 -r c529d4d7d79b tools/examples/xl.conf
--- a/tools/examples/xl.conf    Wed Feb 16 11:47:54 2011 +0000
+++ b/tools/examples/xl.conf    Thu Feb 17 10:02:52 2011 +0000
@@ -6,3 +6,6 @@ autoballoon=0
 
 # full path of the lockfile used by xl during domain creation
 #lockfile="/var/lock/xl"
+
+# default vif script 
+#vifscript="vif-bridge"
diff -r 1728ed4bbec9 -r c529d4d7d79b tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Feb 16 11:47:54 2011 +0000
+++ b/tools/libxl/libxl.c       Thu Feb 17 10:02:52 2011 +0000
@@ -30,6 +30,8 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <assert.h>
+
+#include <arpa/inet.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -1123,6 +1125,7 @@ int libxl_device_nic_init(libxl_device_n
     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;
@@ -1182,6 +1185,16 @@ int libxl_device_nic_add(libxl_ctx *ctx,
     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");
diff -r 1728ed4bbec9 -r c529d4d7d79b tools/libxl/xl.c
--- a/tools/libxl/xl.c  Wed Feb 16 11:47:54 2011 +0000
+++ b/tools/libxl/xl.c  Thu Feb 17 10:02:52 2011 +0000
@@ -35,6 +35,7 @@ xentoollog_logger_stdiostream *logger;
 xentoollog_logger_stdiostream *logger;
 int autoballoon = 1;
 char *lockfile;
+char *default_vifscript = NULL;
 
 static xentoollog_level minmsglevel = XTL_PROGRESS;
 
@@ -71,6 +72,9 @@ static void parse_global_config(const ch
             exit(1);
         }
     }
+
+    if (!xlu_cfg_get_string (config, "vifscript", &buf))
+        default_vifscript = strdup(buf);
 
     xlu_cfg_destroy(config);
 }
diff -r 1728ed4bbec9 -r c529d4d7d79b tools/libxl/xl.h
--- a/tools/libxl/xl.h  Wed Feb 16 11:47:54 2011 +0000
+++ b/tools/libxl/xl.h  Thu Feb 17 10:02:52 2011 +0000
@@ -101,5 +101,6 @@ extern xentoollog_logger_stdiostream *lo
 /* global options */
 extern int autoballoon;
 extern char *lockfile;
+extern char *default_vifscript;
 
 #endif /* XL_H */
diff -r 1728ed4bbec9 -r c529d4d7d79b tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Wed Feb 16 11:47:54 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Thu Feb 17 10:02:52 2011 +0000
@@ -782,6 +782,11 @@ static void parse_config_data(const char
             d_config->vifs = (libxl_device_nic *) realloc(d_config->vifs, 
sizeof (libxl_device_nic) * (d_config->num_vifs+1));
             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)



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>