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

[Xen-devel] [patch] Add support for "hostonly" xen bridges.

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [patch] Add support for "hostonly" xen bridges.
From: kraxel@xxxxxxx
Date: Thu, 05 Oct 2006 10:48:58 +0200
Delivery-date: Thu, 05 Oct 2006 01:52:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.44-15
Add support for "hostonly" networking, i.e. create a bridge without a
physical network device linked in.  The virtual machines can see each
other and the host, but can't (directly) talk to the outside.  Pass
"netdev=none" to the network-bridge script to activate this.

I'm using this on a laptop which has different network connections at
different times (wired / wireless), so it is inconvinient to add the
physical device into the bridge.  In case the laptop is offline the
virtual network still works just fine.  It also avoids the problem that
bridging doesn't work with wireless due to being limited to one mac
address then.

dom0 on that laptop also runs a dhcp server for the virtual network.
Guests can talk to the internet via apache configured as http proxy.
Another possible approach for guest internet access is NATing the
virtual network.

---
 tools/examples/network-bridge |   37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

Index: build-32-unstable-11624/tools/examples/network-bridge
===================================================================
--- build-32-unstable-11624.orig/tools/examples/network-bridge
+++ build-32-unstable-11624/tools/examples/network-bridge
@@ -269,6 +269,31 @@ op_stop () {
     brctl delbr ${bridge}
 }
 
+op_start_hostonly () {
+    if [ "${bridge}" = "null" ] ; then
+       return
+    fi
+    if link_exists "${bridge}"; then
+       return
+    fi
+
+    create_bridge ${bridge}
+    setup_bridge_port ${vif0}
+    add_to_bridge  ${bridge} ${vif0}
+}
+
+op_stop_hostonly () {
+    if [ "${bridge}" = "null" ]; then
+       return
+    fi
+    if ! link_exists "$bridge"; then
+       return
+    fi
+
+    brctl delbr ${bridge}
+}
+
+
 # adds $dev to $bridge but waits for $dev to be in running state first
 add_to_bridge2() {
     local bridge=$1
@@ -293,11 +318,19 @@ add_to_bridge2() {
 
 case "$command" in
     start)
-       op_start
+       if test "$netdev" = "none"; then
+               op_start_hostonly
+       else
+               op_start
+       fi
        ;;
     
     stop)
-       op_stop
+       if test "$netdev" = "none"; then
+               op_stop_hostonly
+       else
+               op_stop
+       fi
        ;;
 
     status)

--


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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [patch] Add support for "hostonly" xen bridges., kraxel <=