ia64/xen-unstable

view tools/examples/external-device-migrate @ 10098:48c0f5489d44

Remove Emacs variables settings from tail of our Linux files.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu May 18 11:39:03 2006 +0100 (2006-05-18)
parents 8685b64538fa
children b86fe3d23f05
line source
1 #!/bin/sh
3 # Copyright (c) 2005 IBM Corporation
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of version 2.1 of the GNU Lesser General Public
7 # License as published by the Free Software Foundation.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #
20 # This script is called by XenD for migration of external devices
21 # It does not handle the migration of those devices itself, but
22 # passes the requests on to further applications
23 # It handles the low-level command line parsing and some of the
24 # synchronization
26 dir=$(dirname "$0")
27 . "$dir/logging.sh"
30 function ext_dev_migrate_usage() {
31 cat <<EOF
32 Pass the following command line parameters to the script:
34 -step <n> : n-th migration step
35 -host <host> : the destination host
36 -domname <domain name> : name of the domain that is migrating
37 -type <device type> : the type of device that is migrating
38 -subtype <dev. subtype>: the subtype of the device
39 -recover : indicates recovery request; an error
40 occurred during migration
41 -help : display this help screen
42 EOF
43 }
45 # Parse the command line paramters. The following parameters must be
46 # passed as the first ones in the sequence:
47 # -step [required]
48 # -host [required]
49 # -domname [required]
50 # -type [required]
51 # -subtype [optional]
52 # -recover [optional]
53 # The remaining ones will be passed to the called function.
54 function evaluate_params()
55 {
56 local step host domname typ recover filename func stype
57 stype=""
58 while [ 1 ]; do
59 if [ "$1" == "-step" ]; then
60 shift
61 step=$1
62 elif [ "$1" == "-host" ]; then
63 shift
64 host=$1
65 elif [ "$1" == "-domname" ]; then
66 shift
67 domname=$1
68 elif [ "$1" == "-type" ]; then
69 shift
70 typ=$1
71 elif [ "$1" == "-subtype" ]; then
72 shift
73 stype="_$1"
74 elif [ "$1" == "-recover" ]; then
75 recover=1
76 elif [ "$1" == "-help" ]; then
77 ext_dev_migrate_usage
78 exit
79 else
80 break
81 fi
82 shift
83 done
85 if [ "$step" == "" -o \
86 "$host" == "" -o \
87 "$typ" == "" -o \
88 "$domname" == "" ]; then
89 echo "Error: Parameter(s) missing (-step/-host/-type/-domname)"
90 echo ""
91 echo "$0 -help for usage."
92 exit
93 fi
95 filename="$dir/$typ$stype-migration.sh"
96 if [ ! -r $filename ]; then
97 echo "Error: Could not find script '$filename'"
98 return
99 fi
100 . "$filename"
102 if [ "$recover" == "1" ]; then
103 func="$typ"_recover
104 eval $func $host $domname $step $*
105 else
106 func="$typ"_migration_step
107 eval $func $host $domname $step $*
108 fi
109 }
111 evaluate_params $*