ia64/xen-unstable

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