ia64/xen-unstable

view netbsd-2.0-xen-sparse/mkbuildtree @ 7446:18eb059ae471

New network-bridge script and associated gubbins.

This is Kurt Garloff's reworked network-bridge script:

* we got rid of ifconfig
* it works for netdev != eth0
* arp on and off are symmetric as are ifdown and ifup
* ifup will be passed the ifcfg config file name if needed
(the ifup may otherwise figure that the veth0 hardware is
NOT the same as the original ${netdev} and not use the same
config -- this happens on SUSE. Charles Coffing tracked this
one down.)

Plus Kurt's avoid-dash patch:

the network setup scripts on SUSE have trouble with the bridge
name xen-br0; they don't expect the '-'.
Arguably this should be fixed.
But I assume there's more scripts out there which may not like it,
so I suggest the following patch to rename xen-br0 to xenbr0.

Plus Charles Duffy's patch to support multiple bridges:

The attached patch allows the network-bridge script to be used to
generate multiple bridges corresponding to different physical
interfaces. It adds a new parameter, "vifnum", used to refer both to
the loopback interface to be used and to set defaults regarding the
physical interface and bridge name.

Thus, if one wishes to start xenbr0 on eth0 and xenbr1 on eth1, one
need only call:

network-bridge start ## vifnum is 0 by default
network-bridge start vifnum=1

...well, that and set loopback.nloopbacks=2 in the Dom0 kernel
parameters.

Plus renaming of virtnum to vifnum in Charles' patch, as requested by Ian Pratt.

Plus a fix to DevController to allocate vif IDs starting from 0 (i.e. vif2.0
is now domain 2's first vif, as opposed to vif2.1 in the recent past).

Plus tidying up inside network-bridge using some helper variables.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Wed Oct 19 16:24:54 2005 +0100 (2005-10-19)
parents a01199a95070
children
line source
1 #!/bin/bash
3 # mkbuildtree <build tree>
4 #
5 # Creates symbolic links in <build tree> for the sparse tree
6 # in the current directory.
8 # Script to determine the relative path between two directories.
9 # Copyright (c) D. J. Hawkey Jr. 2002
10 # Fixed for Xen project by K. Fraser in 2003.
11 abs_to_rel ()
12 {
13 local CWD SRCPATH
15 if [ "$1" != "/" -a "${1##*[^/]}" = "/" ]; then
16 SRCPATH=${1%?}
17 else
18 SRCPATH=$1
19 fi
20 if [ "$2" != "/" -a "${2##*[^/]}" = "/" ]; then
21 DESTPATH=${2%?}
22 else
23 DESTPATH=$2
24 fi
26 CWD=$PWD
27 [ "${1%%[^/]*}" != "/" ] && cd $1 && SRCPATH=$PWD
28 [ "${2%%[^/]*}" != "/" ] && cd $2 && DESTPATH=$PWD
29 [ "$CWD" != "$PWD" ] && cd $CWD
31 BASEPATH=$SRCPATH
33 [ "$SRCPATH" = "$DESTPATH" ] && DESTPATH="." && return
34 [ "$SRCPATH" = "/" ] && DESTPATH=${DESTPATH#?} && return
36 while [ "$BASEPATH/" != "${DESTPATH%${DESTPATH#$BASEPATH/}}" ]; do
37 BASEPATH=${BASEPATH%/*}
38 done
40 SRCPATH=${SRCPATH#$BASEPATH}
41 DESTPATH=${DESTPATH#$BASEPATH}
42 DESTPATH=${DESTPATH#?}
43 while [ -n "$SRCPATH" ]; do
44 SRCPATH=${SRCPATH%/*}
45 DESTPATH="../$DESTPATH"
46 done
48 [ -z "$BASEPATH" ] && BASEPATH="/"
49 [ "${DESTPATH##*[^/]}" = "/" ] && DESTPATH=${DESTPATH%?}
50 }
52 # relative_lndir <target_dir>
53 # Creates a tree of symlinks in the current working directory that mirror
54 # real files in <target_dir>. <target_dir> should be relative to the current
55 # working directory. Symlinks in <target_dir> are ignored. Source-control files
56 # are ignored.
57 relative_lndir ()
58 {
59 local SYMLINK_DIR REAL_DIR pref i j
60 SYMLINK_DIR=$PWD
61 REAL_DIR=$1
62 (
63 cd $REAL_DIR
64 for i in `find . -type d | grep -v SCCS`; do
65 [ -d $SYMLINK_DIR/$i ] || mkdir -p $SYMLINK_DIR/$i
66 (
67 cd $i
68 pref=`echo $i | sed -e 's#/[^/]*#../#g' -e 's#^\.##'`
69 for j in `find . -type f -o -type l -maxdepth 1`; do
70 ln -sf ${pref}${REAL_DIR}/$i/$j ${SYMLINK_DIR}/$i/$j
71 done
72 )
73 done
74 )
75 }
77 [ "$1" == "" ] && { echo "Syntax: $0 <linux tree to xenify>"; exit 1; }
79 # Get absolute path to the destination directory
80 pushd . >/dev/null
81 cd ${1}
82 AD=$PWD
83 popd >/dev/null
85 # Get absolute path to the source directory
86 AS=`pwd`
88 # Get name of sparse directory
89 SDN=$(basename $AS)
91 # Get path to source, relative to destination
92 abs_to_rel ${AD} ${AS}
93 RS=$DESTPATH
95 # Remove old copies of files and directories at the destination
96 for i in `find sys -type f -o -type l` ; do rm -f ${AD}/${i#./} ; done
98 # We now work from the destination directory
99 cd ${AD}
101 # Remove old symlinks
102 find sys -type l | while read f
103 do
104 case $(readlink $f) in
105 */$SDN/*)
106 rm -f $f
107 ;;
108 esac
109 done
111 if [ -f ${AD}/BUILDING ]; then
112 # Create symlinks of files and directories which exist in the sparse source
113 (cd sys && relative_lndir ../${RS}/sys)
114 else
115 # Create symlinks of files and directories which exist in the sparse source
116 relative_lndir ${RS}
117 rm -f mkbuildtree
118 fi
120 # Create links to the shared definitions of the Xen interface
121 rm -rf ${AD}/sys/arch/xen/include/xen-public
122 mkdir ${AD}/sys/arch/xen/include/xen-public
123 cd ${AD}/sys/arch/xen/include/xen-public
124 relative_lndir ../../../../../${RS}/../xen/include/public
126 # Remove files which don't exist anymore
127 rm -rf ${AD}/sys/arch/xen/xen/events.c
128 rm -rf ${AD}/sys/arch/xen/include/events.h