ia64/xen-unstable

annotate tools/hotplug/NetBSD/block-nbsd @ 19818:415505139333

Get rid of hardcoded pathes for stubdom and hotplug scripts

- Have the buid system generate a file which exports the install paths
for the hotplug scripts and stubdom / stubdom-dm
- Move file generation code from tools/python/Makefile into a gmake
macro
in Config.mk to avoid maintenance of three duplicates each with its
own
tweaks and bugs
- Export gmake variables into ioemu as shell variables
for upcoming ioemu patches
- Do above as a gmake macro to avoid maintenance of several duplicates
- Adjust hotplug scripts to find the right xen binaries from the
install directory
- Adjust stubdom-dm to use the install directories

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