ia64/xen-unstable

changeset 15389:865c4ae59be3

tools: Allow xendomains to handle domain names >16 characters

The xendomains init script parses the output of "xm list", and
since xm list restricts the length of domains to 16 characters the
xendomain script cannot handle long domain names.

This patch makesit parse the output of "xm list -l" instead.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
author kfraser@localhost.localdomain
date Tue Jun 19 16:29:22 2007 +0100 (2007-06-19)
parents 896b536d66c9
children eeeb77195ac2
files tools/examples/init.d/xendomains
line diff
     1.1 --- a/tools/examples/init.d/xendomains	Tue Jun 19 16:08:15 2007 +0100
     1.2 +++ b/tools/examples/init.d/xendomains	Tue Jun 19 16:29:22 2007 +0100
     1.3 @@ -182,25 +182,31 @@ rdnames()
     1.4  
     1.5  parseln()
     1.6  {
     1.7 -    name=`echo "$1" | cut -c0-17`
     1.8 -    name=${name%% *}
     1.9 -    rest=`echo "$1" | cut -c18- `
    1.10 -    read id mem cpu vcpu state tm < <(echo "$rest")
    1.11 +    if [[ "$1" =~ "\(domain" ]]; then
    1.12 +        name=;id=
    1.13 +    else if [[ "$1" =~ "\(name" ]]; then
    1.14 +        name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/')
    1.15 +    else if [[ "$1" =~ "\(domid" ]]; then
    1.16 +        id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/')
    1.17 +    fi; fi; fi
    1.18 +
    1.19 +    [ -n "$name" -a -n "$id" ] && return 0 || return 1
    1.20  }
    1.21  
    1.22  is_running()
    1.23  {
    1.24      rdname $1
    1.25      RC=1
    1.26 +    name=;id=
    1.27      while read LN; do
    1.28 -	parseln "$LN"
    1.29 +	parseln "$LN" || continue
    1.30  	if test $id = 0; then continue; fi
    1.31  	case $name in 
    1.32  	    ($NM)
    1.33  		RC=0
    1.34  		;;
    1.35  	esac
    1.36 -    done < <(xm list | grep -v '^Name')
    1.37 +    done < <(xm list -l | grep '(\(domain\|domid\|name\)')
    1.38      return $RC
    1.39  }
    1.40  
    1.41 @@ -267,13 +273,14 @@ start()
    1.42  
    1.43  all_zombies()
    1.44  {
    1.45 +    name=;id=
    1.46      while read LN; do
    1.47 -	parseln "$LN"
    1.48 +	parseln "$LN" || continue
    1.49  	if test $id = 0; then continue; fi
    1.50  	if test "$state" != "-b---d" -a "$state" != "-----d"; then
    1.51  	    return 1;
    1.52  	fi
    1.53 -    done < <(xm list | grep -v '^Name')
    1.54 +    done < <(xm list -l | grep '(\(domain\|domid\|name\)')
    1.55      return 0
    1.56  }
    1.57  
    1.58 @@ -309,8 +316,9 @@ stop()
    1.59  	rdnames
    1.60      fi
    1.61      echo -n "Shutting down Xen domains:"
    1.62 +    name=;id=
    1.63      while read LN; do
    1.64 -	parseln "$LN"
    1.65 +	parseln "$LN" || continue
    1.66  	if test $id = 0; then continue; fi
    1.67  	echo -n " $name"
    1.68  	if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
    1.69 @@ -384,7 +392,7 @@ stop()
    1.70  	    fi
    1.71  	    kill $WDOG_PID >/dev/null 2>&1
    1.72  	fi
    1.73 -    done < <(xm list | grep -v '^Name')
    1.74 +    done < <(xm list -l | grep '(\(domain\|domid\|name\)')
    1.75  
    1.76      # NB. this shuts down ALL Xen domains (politely), not just the ones in
    1.77      # AUTODIR/*
    1.78 @@ -409,15 +417,16 @@ stop()
    1.79  
    1.80  check_domain_up()
    1.81  {
    1.82 +    name=;id=
    1.83      while read LN; do
    1.84 -	parseln "$LN"
    1.85 +	parseln "$LN" || continue
    1.86  	if test $id = 0; then continue; fi
    1.87  	case $name in 
    1.88  	    ($1)
    1.89  		return 0
    1.90  		;;
    1.91  	esac
    1.92 -    done < <(xm list | grep -v "^Name")
    1.93 +    done < <(xm list -l | grep '(\(domain\|domid\|name\)')
    1.94      return 1
    1.95  }
    1.96