ia64/xen-unstable

view tools/hotplug/Linux/xen-hotplug-common.sh @ 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 #
2 # Copyright (c) 2005 XenSource Ltd.
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of version 2.1 of the GNU Lesser General Public
6 # License as published by the Free Software Foundation.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
19 dir=$(dirname "$0")
20 . "$dir/hotplugpath.sh"
21 . "$dir/logging.sh"
22 . "$dir/xen-script-common.sh"
23 . "$dir/locking.sh"
25 exec 2>>/var/log/xen/xen-hotplug.log
27 export PATH="${BINDIR}:${SBINDIR}:${LIBEXEC}:${PRIVATE_BINDIR}:/sbin:/bin:/usr/bin:/usr/sbin:$PATH"
28 export LANG="POSIX"
29 unset $(set | grep ^LC_ | cut -d= -f1)
31 fatal() {
32 xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \
33 "$XENBUS_PATH/hotplug-status" error
34 log err "$@"
35 exit 1
36 }
38 success() {
39 # Tell DevController that backend is "connected"
40 xenstore_write "$XENBUS_PATH/hotplug-status" connected
41 }
43 do_or_die() {
44 "$@" || fatal "$@ failed"
45 }
47 do_without_error() {
48 "$@" 2>/dev/null || log debug "$@ failed"
49 }
51 sigerr() {
52 fatal "$0 failed; error detected."
53 }
55 trap sigerr ERR
58 ##
59 # xenstore_read <path>+
60 #
61 # Read each of the given paths, returning each result on a separate line, or
62 # exit this script if any of the paths is missing.
63 #
64 xenstore_read() {
65 local v=$(xenstore-read "$@" || true)
66 [ "$v" != "" ] || fatal "xenstore-read $@ failed."
67 echo "$v"
68 }
71 ##
72 # xenstore_read_default <path> <default>
73 #
74 # Read the given path, returning the value there or the given default if the
75 # path is not present.
76 #
77 xenstore_read_default() {
78 xenstore-read "$1" 2>/dev/null || echo "$2"
79 }
82 ##
83 # xenstore_write (<path> <value>)+
84 #
85 # Write each of the key/value pairs to the store, and exit this script if any
86 # such writing fails.
87 #
88 xenstore_write() {
89 log debug "Writing $@ to xenstore."
90 xenstore-write "$@" || fatal "Writing $@ to xenstore failed."
91 }
94 log debug "$@" "XENBUS_PATH=$XENBUS_PATH"