ia64/xen-unstable
changeset 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>
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 | b0f61c2c0746 |
children | 471e8ca6bc1f |
files | tools/examples/network-bridge tools/examples/vif-bridge tools/examples/xend-config.sxp tools/examples/xmexample.vmx tools/examples/xmexample1 tools/examples/xmexample2 tools/ioemu/target-i386-dm/qemu-ifup tools/misc/netfix tools/python/xen/xend/XendRoot.py tools/python/xen/xend/server/DevController.py tools/python/xen/xend/server/SrvDaemon.py tools/vnet/vnet-module/varp.c |
line diff
1.1 --- a/tools/examples/network-bridge Wed Oct 19 14:00:37 2005 +0100 1.2 +++ b/tools/examples/network-bridge Wed Oct 19 16:24:54 2005 +0100 1.3 @@ -5,8 +5,8 @@ 1.4 # The script name to use is defined in /etc/xen/xend-config.sxp 1.5 # in the network-script field. 1.6 # 1.7 -# This script creates a bridge (default xen-br0), adds a device 1.8 -# (default eth0) to it, copies the IP addresses from the device 1.9 +# This script creates a bridge (default xenbr${vifnum}), adds a device 1.10 +# (default eth${vifnum}) to it, copies the IP addresses from the device 1.11 # to the bridge and adjusts the routes accordingly. 1.12 # 1.13 # If all goes well, this should ensure that networking stays up. 1.14 @@ -20,9 +20,12 @@ 1.15 # 1.16 # Vars: 1.17 # 1.18 -# bridge The bridge to use (default xen-br0). 1.19 -# netdev The interface to add to the bridge (default eth0). 1.20 -# antispoof Whether to use iptables to prevent spoofing (default yes). 1.21 +# vifnum Virtual device number to use (default 0). Numbers >=1 1.22 +# require the netback driver to have nloopbacks set to a 1.23 +# higher value than its default of 1. 1.24 +# bridge The bridge to use (default xenbr${vifnum}). 1.25 +# netdev The interface to add to the bridge (default eth${vifnum}). 1.26 +# antispoof Whether to use iptables to prevent spoofing (default no). 1.27 # 1.28 # start: 1.29 # Creates the bridge and enslaves netdev to it. 1.30 @@ -60,11 +63,37 @@ shift 1.31 # Pull variables in args in to environment. 1.32 for arg ; do export "${arg}" ; done 1.33 1.34 -bridge=${bridge:-xen-br0} 1.35 -netdev=${netdev:-eth0} 1.36 +vifnum=${vifnum:-0} 1.37 +bridge=${bridge:-xenbr${vifnum}} 1.38 +netdev=${netdev:-eth${vifnum}} 1.39 antispoof=${antispoof:-no} 1.40 1.41 -echo "*network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof" >&2 1.42 +pdev="p${netdev}" 1.43 +vdev="veth${vifnum}" 1.44 +vif0="vif0.${vifnum}" 1.45 + 1.46 +echo "*network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof vifnum=$vifnum" >&2 1.47 + 1.48 +legacy_mask_to_prefix() { 1.49 + mask=$1 1.50 + first=${mask%%.*} 1.51 + second=${mask#*.} 1.52 + third=${second#*.} 1.53 + fourth=${third#*.} 1.54 + second=${second%%.*} 1.55 + third=${third%%.*} 1.56 + declare -i INT FULLMASK BIT 1.57 + INT=$((((($first*256)+$second)*256+$third)*256+$fourth)) 1.58 + FULLMASK=4294967295 1.59 + BIT=1 1.60 + for bit in `seq 32 -1 0`; do 1.61 + if test $FULLMASK -eq $INT; then PREFIX=$bit; return; fi 1.62 + FULLMASK=$(($FULLMASK-$BIT)) 1.63 + BIT=$((BIT*2)) 1.64 + done 1.65 + echo "ERROR converting netmask $mask to prefix" 1.66 + exit 1 1.67 +} 1.68 1.69 # Usage: transfer_addrs src dst 1.70 # Copy all IP addresses (including aliases) from device $src to device $dst. 1.71 @@ -99,6 +128,7 @@ s/inet/ip addr del/ 1.72 s@\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)/[0-9]\+@\1@ 1.73 s/${src}/dev ${src}/ 1.74 " | sh -e 1.75 + ip link set dev ${dst} up 1.76 } 1.77 1.78 # Usage: transfer_routes src dst 1.79 @@ -131,11 +161,11 @@ create_bridge () { 1.80 1.81 # Don't create the bridge if it already exists. 1.82 if ! brctl show | grep -q ${bridge} ; then 1.83 - brctl addbr ${bridge} 1.84 - brctl stp ${bridge} off 1.85 - brctl setfd ${bridge} 0 1.86 + brctl addbr ${bridge} 1.87 + brctl stp ${bridge} off 1.88 + brctl setfd ${bridge} 0 1.89 fi 1.90 - ifconfig ${bridge} up 1.91 + ip link set ${bridge} up 1.92 } 1.93 1.94 # Usage: add_to_bridge bridge dev 1.95 @@ -144,7 +174,7 @@ add_to_bridge () { 1.96 local dev=$2 1.97 # Don't add $dev to $bridge if it's already on a bridge. 1.98 if ! brctl show | grep -q ${dev} ; then 1.99 - brctl addif ${bridge} ${dev} 1.100 + brctl addif ${bridge} ${dev} 1.101 fi 1.102 } 1.103 1.104 @@ -166,8 +196,10 @@ show_status () { 1.105 local bridge=$2 1.106 1.107 echo '============================================================' 1.108 - ifconfig ${dev} 1.109 - ifconfig ${bridge} 1.110 + ip addr show ${dev} 1.111 + ip addr show ${bridge} 1.112 + echo ' ' 1.113 + brctl show ${bridge} 1.114 echo ' ' 1.115 ip route list 1.116 echo ' ' 1.117 @@ -177,100 +209,113 @@ show_status () { 1.118 1.119 op_start () { 1.120 if [ "${bridge}" == "null" ] ; then 1.121 - return 1.122 + return 1.123 fi 1.124 1.125 create_bridge ${bridge} 1.126 1.127 - if ifconfig 2>/dev/null | grep -q veth0 ; then 1.128 - return 1.129 + if ! ip link show 2>/dev/null | grep -q "^[0-9]*: ${vdev}"; then 1.130 + return 1.131 fi 1.132 1.133 - if ifconfig veth0 2>/dev/null | grep -q veth0 ; then 1.134 - mac=`ifconfig ${netdev} | grep HWadd | sed -e 's/.*\(..:..:..:..:..:..\).*/\1/'` 1.135 - if ! ifdown ${netdev} ; then 1.136 - # if ifup didn't work, see if we have an ip= on cmd line 1.137 - if egrep 'ip=[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:' /proc/cmdline ; 1.138 - then 1.139 - kip=`sed -e 's!.*ip=\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\):.*!\1!' /proc/cmdline` 1.140 - kmask=`sed -e 's!.*ip=[^:]*:[^:]*:[^:]*:\([^:]*\):.*!\1!' /proc/cmdline` 1.141 - kgate=`sed -e 's!.*ip=[^:]*:[^:]*:\([^:]*\):.*!\1!' /proc/cmdline` 1.142 - ifconfig ${netdev} 0.0.0.0 down 1.143 - fi 1.144 + if ip link show ${vdev} 2>/dev/null >/dev/null; then 1.145 + mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` 1.146 + eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- ${netdev}` 1.147 + transfer_addrs ${netdev} ${vdev} 1.148 + if ! ifdown ${netdev}; then 1.149 + # if ifup didn't work, see if we have an ip= on cmd line 1.150 + if egrep 'ip=[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:' /proc/cmdline; then 1.151 + kip=`sed -e 's!.*ip=\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\):.*!\1!' /proc/cmdline` 1.152 + kmask=`sed -e 's!.*ip=[^:]*:[^:]*:[^:]*:\([^:]*\):.*!\1!' /proc/cmdline` 1.153 + kgate=`sed -e 's!.*ip=[^:]*:[^:]*:\([^:]*\):.*!\1!' /proc/cmdline` 1.154 + ip link set ${netdev} down 1.155 + ip addr flush ${netdev} 1.156 + fi 1.157 fi 1.158 - ip link set ${netdev} name p${netdev} 1.159 - ip link set veth0 name ${netdev} 1.160 - ifconfig p${netdev} 0.0.0.0 -arp down 1.161 - ifconfig p${netdev} hw ether fe:ff:ff:ff:ff:ff 1.162 - ifconfig ${netdev} hw ether ${mac} 1.163 - add_to_bridge ${bridge} vif0.0 1.164 - add_to_bridge ${bridge} p${netdev} 1.165 + ip link set ${netdev} name ${pdev} 1.166 + ip link set ${vdev} name ${netdev} 1.167 + ip link set ${pdev} down arp off 1.168 + ip link set ${pdev} addr fe:ff:ff:ff:ff:ff 1.169 + ip addr flush ${pdev} 1.170 + ip link set ${netdev} addr ${mac} arp on 1.171 + add_to_bridge ${bridge} ${vif0} 1.172 + add_to_bridge ${bridge} ${pdev} 1.173 ip link set ${bridge} up 1.174 - ip link set vif0.0 up 1.175 - ip link set p${netdev} up 1.176 - if ! ifup ${netdev} ; then 1.177 - if [ ${kip} ] ; then 1.178 - # use the addresses we grocked from /proc/cmdline 1.179 - ifconfig ${netdev} ${kip} 1.180 - [ ${kmask} ] && ifconfig ${netdev} netmask ${kmask} 1.181 - ifconfig ${netdev} up 1.182 - [ ${kgate} ] && ip route add default via ${kgate} 1.183 + ip link set ${vif0} up 1.184 + ip link set ${pdev} up 1.185 + if ! ifup ${HWD_CONFIG_0} ${netdev} ; then 1.186 + if [ ${kip} ] ; then 1.187 + # use the addresses we grocked from /proc/cmdline 1.188 + if [ -z "${kmask}" ]; then 1.189 + PREFIX=32; 1.190 + else 1.191 + legacy_to_prefix ${kmask}; 1.192 fi 1.193 - fi 1.194 + ip addr add ${kip}/${PREFIX} dev ${netdev} 1.195 + ip link set dev ${netdev} up 1.196 + [ ${kgate} ] && ip route add default via ${kgate} 1.197 + fi 1.198 + fi 1.199 else 1.200 - # old style without veth0 1.201 - transfer_addrs ${netdev} ${bridge} 1.202 - transfer_routes ${netdev} ${bridge} 1.203 + # old style without ${vdev} 1.204 + transfer_addrs ${netdev} ${bridge} 1.205 + transfer_routes ${netdev} ${bridge} 1.206 fi 1.207 - 1.208 + 1.209 if [ ${antispoof} == 'yes' ] ; then 1.210 - antispoofing ${netdev} ${bridge} 1.211 + antispoofing ${netdev} ${bridge} 1.212 fi 1.213 } 1.214 1.215 op_stop () { 1.216 - if [ "${bridge}" == "null" ] ; then 1.217 - return 1.218 + if [ "${bridge}" == "null" ]; then 1.219 + return 1.220 + fi 1.221 + if ! ip link show ${bridge} >/dev/null 2>&1; then 1.222 + return 1.223 fi 1.224 1.225 - if ifconfig peth0 2>/dev/null | grep -q peth0 ; then 1.226 - 1.227 - ifconfig vif0.0 down 1.228 - mac=`ifconfig eth0 | grep HWadd | \ 1.229 - sed -e 's/.*\(..:..:..:..:..:..\).*/\1/'` 1.230 - ifconfig ${netdev} 0.0.0.0 down 1.231 - ifconfig ${netdev} hw ether fe:ff:ff:ff:ff:ff 1.232 + if ip link show ${pdev} 2>/dev/null >/dev/null; then 1.233 + ip link set dev ${vif0} down 1.234 + mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` 1.235 + transfer_addrs ${netdev} ${pdev} 1.236 + ifdown ${netdev} 1.237 + ip link set ${netdev} down arp off 1.238 + ip link set ${netdev} addr fe:ff:ff:ff:ff:ff 1.239 + ip link set ${pdev} down 1.240 + ip addr flush ${netdev} 1.241 + ip link set ${pdev} addr ${mac} arp on 1.242 1.243 - ifconfig p${netdev} down 1.244 - ifconfig p${netdev} hw ether ${mac} arp 1.245 - brctl delif ${bridge} p${netdev} 1.246 + brctl delif ${bridge} ${pdev} 1.247 + brctl delif ${bridge} ${vif0} 1.248 + ip link set ${bridge} down 1.249 1.250 - ip link set eth0 name veth0 1.251 - ip link set peth0 name eth0 1.252 - ifconfig ${bridge} down 1.253 - brctl delbr ${bridge} 1.254 - ifup eth0 1.255 + ip link set ${netdev} name ${vdev} 1.256 + ip link set ${pdev} name ${netdev} 1.257 + ifup ${netdev} 1.258 1.259 else 1.260 - transfer_routes ${bridge} ${netdev} 1.261 + transfer_routes ${bridge} ${netdev} 1.262 + ip link set ${bridge} down 1.263 fi 1.264 + brctl delbr ${bridge} 1.265 } 1.266 1.267 case ${OP} in 1.268 start) 1.269 - op_start 1.270 - ;; 1.271 + op_start 1.272 + ;; 1.273 1.274 stop) 1.275 - op_stop 1.276 - ;; 1.277 + op_stop 1.278 + ;; 1.279 1.280 status) 1.281 - show_status ${netdev} ${bridge} 1.282 - ;; 1.283 + show_status ${netdev} ${bridge} 1.284 + ;; 1.285 1.286 *) 1.287 - echo 'Unknown command: ' ${OP} >&2 1.288 - echo 'Valid commands are: start, stop, status' >&2 1.289 - exit 1 1.290 + echo 'Unknown command: ' ${OP} >&2 1.291 + echo 'Valid commands are: start, stop, status' >&2 1.292 + exit 1 1.293 esac
2.1 --- a/tools/examples/vif-bridge Wed Oct 19 14:00:37 2005 +0100 2.2 +++ b/tools/examples/vif-bridge Wed Oct 19 16:24:54 2005 +0100 2.3 @@ -8,7 +8,7 @@ 2.4 # 2.5 # Example invocation: 2.6 # 2.7 -# vif-bridge up domain=VM1 vif=vif1.0 bridge=xen-br0 ip="128.232.38.45/28 10.10.10.55/24" 2.8 +# vif-bridge up domain=VM1 vif=vif1.0 bridge=xenbr0 ip="128.232.38.45/28 10.10.10.55/24" 2.9 # 2.10 # 2.11 # Usage:
3.1 --- a/tools/examples/xend-config.sxp Wed Oct 19 14:00:37 2005 +0100 3.2 +++ b/tools/examples/xend-config.sxp Wed Oct 19 16:24:54 2005 +0100 3.3 @@ -33,7 +33,7 @@ 3.4 # The script used to start/stop networking for xend. 3.5 (network-script network-bridge) 3.6 # The default bridge that virtual interfaces should be connected to. 3.7 -(vif-bridge xen-br0) 3.8 +(vif-bridge xenbr0) 3.9 # The default script used to control virtual interfaces. 3.10 (vif-script vif-bridge) 3.11
4.1 --- a/tools/examples/xmexample.vmx Wed Oct 19 14:00:37 2005 +0100 4.2 +++ b/tools/examples/xmexample.vmx Wed Oct 19 16:24:54 2005 +0100 4.3 @@ -35,7 +35,7 @@ vcpus=1 4.4 4.5 # Optionally define mac and/or bridge for the network interfaces. 4.6 # Random MACs are assigned if not given. 4.7 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 4.8 +#vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ] 4.9 4.10 #---------------------------------------------------------------------------- 4.11 # Define the disk devices you want the domain to have access to, and
5.1 --- a/tools/examples/xmexample1 Wed Oct 19 14:00:37 2005 +0100 5.2 +++ b/tools/examples/xmexample1 Wed Oct 19 16:24:54 2005 +0100 5.3 @@ -36,7 +36,7 @@ name = "ExampleDomain" 5.4 5.5 # Optionally define mac and/or bridge for the network interfaces. 5.6 # Random MACs are assigned if not given. 5.7 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 5.8 +#vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ] 5.9 5.10 #---------------------------------------------------------------------------- 5.11 # Define the disk devices you want the domain to have access to, and
6.1 --- a/tools/examples/xmexample2 Wed Oct 19 14:00:37 2005 +0100 6.2 +++ b/tools/examples/xmexample2 Wed Oct 19 16:24:54 2005 +0100 6.3 @@ -67,7 +67,7 @@ vcpus = 4 # make your domain a 4-way 6.4 6.5 # Optionally define mac and/or bridge for the network interfaces. 6.6 # Random MACs are assigned if not given. 6.7 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 6.8 +#vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ] 6.9 6.10 #---------------------------------------------------------------------------- 6.11 # Define the disk devices you want the domain to have access to, and
7.1 --- a/tools/ioemu/target-i386-dm/qemu-ifup Wed Oct 19 14:00:37 2005 +0100 7.2 +++ b/tools/ioemu/target-i386-dm/qemu-ifup Wed Oct 19 16:24:54 2005 +0100 7.3 @@ -7,4 +7,4 @@ echo 'config qemu network with xen bridg 7.4 echo $* 7.5 7.6 ifconfig $1 0.0.0.0 up 7.7 -brctl addif xen-br0 $1 7.8 +brctl addif xenbr0 $1
8.1 --- a/tools/misc/netfix Wed Oct 19 14:00:37 2005 +0100 8.2 +++ b/tools/misc/netfix Wed Oct 19 16:24:54 2005 +0100 8.3 @@ -3,7 +3,7 @@ 8.4 #============================================================================ 8.5 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com> 8.6 #============================================================================ 8.7 -# Move the IP address from eth0 onto the Xen bridge (xen-br0). 8.8 +# Move the IP address from eth0 onto the Xen bridge (xenbr0). 8.9 # Only works if the bridge control utils (brctl) have been installed. 8.10 #============================================================================ 8.11 8.12 @@ -19,7 +19,7 @@ long_options = ['help', 'verbose', 'qui 8.13 'interface=', 'bridge=', 'create'] 8.14 8.15 defaults['interface'] = 'eth0' 8.16 -defaults['bridge'] = 'xen-br0' 8.17 +defaults['bridge'] = 'xenbr0' 8.18 8.19 def usage(): 8.20 print """Usage:
9.1 --- a/tools/python/xen/xend/XendRoot.py Wed Oct 19 14:00:37 2005 +0100 9.2 +++ b/tools/python/xen/xend/XendRoot.py Wed Oct 19 16:24:54 2005 +0100 9.3 @@ -253,7 +253,7 @@ class XendRoot: 9.4 return self.get_config_bool('enable-dump', 'no') 9.5 9.6 def get_vif_bridge(self): 9.7 - return self.get_config_value('vif-bridge', 'xen-br0') 9.8 + return self.get_config_value('vif-bridge', 'xenbr0') 9.9 9.10 def get_vif_script(self): 9.11 return self.get_config_value('vif-script', 'vif-bridge')
10.1 --- a/tools/python/xen/xend/server/DevController.py Wed Oct 19 14:00:37 2005 +0100 10.2 +++ b/tools/python/xen/xend/server/DevController.py Wed Oct 19 16:24:54 2005 +0100 10.3 @@ -160,7 +160,7 @@ class DevController: 10.4 if result: 10.5 result = int(result) 10.6 else: 10.7 - result = 1 10.8 + result = 0 10.9 t.write("nextDeviceID", str(result + 1)) 10.10 if t.commit(): 10.11 return result
11.1 --- a/tools/python/xen/xend/server/SrvDaemon.py Wed Oct 19 14:00:37 2005 +0100 11.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py Wed Oct 19 16:24:54 2005 +0100 11.3 @@ -32,34 +32,6 @@ class Daemon: 11.4 self.traceindent = 0 11.5 self.child = 0 11.6 11.7 - def daemon_pids(self): 11.8 - pids = [] 11.9 - pidex = '(?P<pid>\d+)' 11.10 - pythonex = '(?P<python>\S*python\S*)' 11.11 - cmdex = '(?P<cmd>.*)' 11.12 - procre = re.compile('^\s*' + pidex + '\s*' + pythonex + '\s*' + cmdex + '$') 11.13 - xendre = re.compile('^\S+/xend\s*(start|restart)\s*.*$') 11.14 - procs = os.popen('ps -e -o pid,args 2>/dev/null') 11.15 - for proc in procs: 11.16 - pm = procre.match(proc) 11.17 - if not pm: continue 11.18 - xm = xendre.match(pm.group('cmd')) 11.19 - if not xm: continue 11.20 - pids.append(int(pm.group('pid'))) 11.21 - return pids 11.22 - 11.23 - def new_cleanup(self, kill=0): 11.24 - err = 0 11.25 - pids = self.daemon_pids() 11.26 - if kill: 11.27 - for pid in pids: 11.28 - print "Killing daemon pid=%d" % pid 11.29 - os.kill(pid, signal.SIGHUP) 11.30 - elif pids: 11.31 - err = 1 11.32 - print "Daemon already running: ", pids 11.33 - return err 11.34 - 11.35 def read_pid(self, pidfile): 11.36 """Read process id from a file. 11.37 11.38 @@ -115,12 +87,9 @@ class Daemon: 11.39 os.remove(pidfile) 11.40 return running 11.41 11.42 - def cleanup_xend(self, kill=False): 11.43 + def cleanup_xend(self, kill): 11.44 return self.cleanup_process(XEND_PID_FILE, "xend", kill) 11.45 11.46 - def cleanup(self, kill=False): 11.47 - self.cleanup_xend(kill=kill) 11.48 - 11.49 def status(self): 11.50 """Returns the status of the xend daemon. 11.51 The return value is defined by the LSB: 11.52 @@ -156,16 +125,13 @@ class Daemon: 11.53 # Detach from TTY. 11.54 os.setsid() 11.55 11.56 - # Detach from standard file descriptors. 11.57 - # I do this at the file-descriptor level: the overlying Python file 11.58 - # objects also use fd's 0, 1 and 2. 11.59 + # Detach from standard file descriptors, and redirect them to 11.60 + # /dev/null or the log as appropriate. 11.61 os.close(0) 11.62 os.close(1) 11.63 os.close(2) 11.64 if XEND_DEBUG: 11.65 os.open('/dev/null', os.O_RDONLY) 11.66 - # XXX KAF: Why doesn't this capture output from C extensions that 11.67 - # fprintf(stdout) or fprintf(stderr) ?? 11.68 os.open(XEND_DEBUG_LOG, os.O_WRONLY|os.O_CREAT) 11.69 os.dup(1) 11.70 else: 11.71 @@ -180,7 +146,7 @@ class Daemon: 11.72 0 Success 11.73 4 Insufficient privileges 11.74 """ 11.75 - xend_pid = self.cleanup_xend() 11.76 + xend_pid = self.cleanup_xend(False) 11.77 11.78 if self.set_user(): 11.79 return 4 11.80 @@ -294,7 +260,10 @@ class Daemon: 11.81 return 1 11.82 11.83 def stop(self): 11.84 - return self.cleanup(kill=True) 11.85 + result = self.cleanup_xend(True) 11.86 + from xen.xend import Vifctl 11.87 + Vifctl.network("stop") 11.88 + return result 11.89 11.90 def run(self, status): 11.91 try:
12.1 --- a/tools/vnet/vnet-module/varp.c Wed Oct 19 14:00:37 2005 +0100 12.2 +++ b/tools/vnet/vnet-module/varp.c Wed Oct 19 16:24:54 2005 +0100 12.3 @@ -176,7 +176,7 @@ u32 varp_mcast_addr = 0; 12.4 /** UDP port (network order). */ 12.5 u16 varp_port = 0; 12.6 12.7 -char *varp_device = "xen-br0"; 12.8 +char *varp_device = "xenbr0"; 12.9 12.10 #define VarpTable_read_lock(z, flags) do{ (flags) = 0; down(&(z)->lock); } while(0) 12.11 #define VarpTable_read_unlock(z, flags) do{ (flags) = 0; up(&(z)->lock); } while(0)