ia64/xen-unstable

annotate tools/hotplug/NetBSD/block-nbsd @ 19497:2f6ed9318c03

network-bridge: Fix do_ifup in the case of ${bridge} != ${netdev}

On RHEL5.2, ifup ${bridge} fails if ${bridge} != ${netdev},
because RHEL5.2's ifup ${bridge} runs the following sequence:

1. Search CONFIG that has the same mac address of ${bridge}.=20
ifcfg-${netdev} is found.
2. Run "ip link set dev ${netdev} up".
# ${bridge} is expected.
3. Output "Failed to bring up ${netdev}."
Because ${netdev} does not exist.

Thus, do_ifup() should not use ifup if ${bridge} != ${netdev}.

Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 02 11:48:10 2009 +0100 (2009-04-02)
parents 4bfc67b09e9c
children 415505139333
rev   line source
keir@18770 1 #!/bin/sh -e
keir@18770 2
keir@18770 3 # $NetBSD: block-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $
keir@18770 4 # Called by xenbackendd
keir@18770 5 # Usage: block xsdir_backend_path state
keir@18770 6
keir@18770 7 PATH=/bin:/usr/bin:/sbin:/usr/sbin
keir@18770 8 export PATH
keir@18770 9
keir@18770 10 error() {
keir@18770 11 echo "$@" >&2
keir@18770 12 xenstore_write $xpath/hotplug-status error
keir@18770 13 exit 1
keir@18770 14 }
keir@18770 15
keir@18770 16
keir@18770 17 xpath=$1
keir@18770 18 xstatus=$2
keir@18770 19 xtype=$(xenstore-read "$xpath/type")
keir@18770 20 xparams=$(xenstore-read "$xpath/params")
keir@18770 21
keir@18770 22 case $xstatus in
keir@18770 23 6)
keir@18770 24 # device removed
keir@18770 25 case $xtype in
keir@18770 26 file)
keir@18770 27 vnd=$(xenstore-read "$xpath/vnd" || echo none)
keir@18770 28 if [ $vnd != none ]; then
keir@18770 29 vnconfig -u $vnd
keir@18770 30 fi
keir@18770 31 ;;
keir@18770 32 phy)
keir@18770 33 ;;
keir@18770 34 *)
keir@18770 35 echo "unknown type $xtype" >&2
keir@18770 36 ;;
keir@18770 37 esac
keir@18770 38 xenstore-rm $xpath
keir@18770 39 exit 0
keir@18770 40 ;;
keir@18770 41 2)
keir@18770 42 case $xtype in
keir@18770 43 file)
keir@18770 44 # Store the list of available vnd(4) devices in
keir@18770 45 #``available_disks'', and mark them as ``free''.
keir@18770 46 list=`ls -1 /dev/vnd[0-9]*d | sed "s,/dev/vnd,,;s,d,," | sort -n`
keir@18770 47 for i in $list; do
keir@18770 48 disk="vnd$i"
keir@18770 49 available_disks="$available_disks $disk"
keir@18770 50 eval $disk=free
keir@18770 51 done
keir@18770 52 # Mark the used vnd(4) devices as ``used''.
keir@18770 53 for disk in `sysctl hw.disknames`; do
keir@18770 54 case $disk in
keir@18770 55 vnd[0-9]*) eval $disk=used ;;
keir@18770 56 esac
keir@18770 57 done
keir@18770 58 # Configure the first free vnd(4) device.
keir@18770 59 for disk in $available_disks; do
keir@18770 60 eval status=\$$disk
keir@18770 61 if [ "$status" = "free" ] && \
keir@18770 62 vnconfig /dev/${disk}d $xparams >/dev/null; then
keir@18770 63 device=/dev/${disk}d
keir@18770 64 echo vnconfig /dev/${disk}d $xparams
keir@18770 65 break
keir@18770 66 fi
keir@18770 67 done
keir@18770 68 if [ x$device = x ] ; then
keir@18770 69 error "no available vnd device"
keir@18770 70 fi
keir@18770 71 echo xenstore-write $xpath/vnd $device
keir@18770 72 xenstore-write $xpath/vnd $device
keir@18770 73 ;;
keir@18770 74 phy)
keir@18770 75 device=$xparams
keir@18770 76 ;;
keir@18770 77 esac
keir@18770 78 physical_device=$(stat -f '%r' "$device")
keir@18770 79 echo xenstore-write $xpath/physical-device $physical_device
keir@18770 80 xenstore-write $xpath/physical-device $physical_device
keir@18770 81 echo xenstore-write $xpath/hotplug-status connected
keir@18770 82 xenstore-write $xpath/hotplug-status connected
keir@18770 83 exit 0
keir@18770 84 ;;
keir@18770 85 *)
keir@18770 86 exit 0
keir@18770 87 ;;
keir@18770 88 esac