ia64/xen-unstable

changeset 4952:3b25e1de5efb

bitkeeper revision 1.1429 (4289ccd8fb0eTpyK6vZqNWsrHJLttA)

Merge firebug.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-unstable.bk
into firebug.cl.cam.ac.uk:/local/scratch/cl349/xen-unstable.bk
author cl349@firebug.cl.cam.ac.uk
date Tue May 17 10:52:08 2005 +0000 (2005-05-17)
parents cdb951900d9d 98d34d775063
children 939209814d75 09082591e3b7 c7fbd1dc68a0
files tools/examples/block-enbd tools/examples/block-file tools/examples/network tools/examples/network-nat tools/examples/vif-bridge tools/examples/vif-nat tools/examples/vif-route tools/python/xen/util/process.py tools/python/xen/xend/Blkctl.py tools/python/xen/xend/Vifctl.py
line diff
     1.1 --- a/tools/examples/block-enbd	Tue May 17 10:39:50 2005 +0000
     1.2 +++ b/tools/examples/block-enbd	Tue May 17 10:52:08 2005 +0000
     1.3 @@ -27,7 +27,7 @@ case $1 in
     1.4  	;;
     1.5  
     1.6  	*)
     1.7 -		echo 'Unknown command: ' $1
     1.8 -		echo 'Valid commands are: bind, unbind'
     1.9 +		echo 'Unknown command: ' $1 >&2
    1.10 +		echo 'Valid commands are: bind, unbind' >&2
    1.11  		exit 1
    1.12  esac
     2.1 --- a/tools/examples/block-file	Tue May 17 10:39:50 2005 +0000
     2.2 +++ b/tools/examples/block-file	Tue May 17 10:52:08 2005 +0000
     2.3 @@ -25,7 +25,7 @@ case $1 in
     2.4  	;;
     2.5  
     2.6  	*)
     2.7 -		echo 'Unknown command: ' $1
     2.8 -		echo 'Valid commands are: bind, unbind'
     2.9 +		echo 'Unknown command: ' $1 >&2
    2.10 +		echo 'Valid commands are: bind, unbind' >&2
    2.11  		exit 1
    2.12  esac
     3.1 --- a/tools/examples/network	Tue May 17 10:39:50 2005 +0000
     3.2 +++ b/tools/examples/network	Tue May 17 10:52:08 2005 +0000
     3.3 @@ -53,7 +53,7 @@ bridge=${bridge:-xen-br0}
     3.4  netdev=${netdev:-eth0}
     3.5  antispoof=${antispoof:-yes}
     3.6  
     3.7 -echo "network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof"
     3.8 +echo "*network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof" >&2
     3.9  
    3.10  # Usage: transfer_addrs src dst
    3.11  # Copy all IP addresses (including aliases) from device $src to device $dst.
    3.12 @@ -232,7 +232,7 @@ case ${OP} in
    3.13         ;;
    3.14  
    3.15      *)
    3.16 -       echo 'Unknown command: ' ${OP}
    3.17 -       echo 'Valid commands are: start, stop, status'
    3.18 +       echo 'Unknown command: ' ${OP} >&2
    3.19 +       echo 'Valid commands are: start, stop, status' >&2
    3.20         exit 1
    3.21  esac
     4.1 --- a/tools/examples/network-nat	Tue May 17 10:39:50 2005 +0000
     4.2 +++ b/tools/examples/network-nat	Tue May 17 10:52:08 2005 +0000
     4.3 @@ -32,7 +32,7 @@ netdev=${netdev:-eth0}
     4.4  # antispoofing not yet implemented
     4.5  antispoof=${antispoof:-no}
     4.6  
     4.7 -echo "network-nat $OP netdev=$netdev antispoof=$antispoof"
     4.8 +echo "*network-nat $OP netdev=$netdev antispoof=$antispoof" >&2
     4.9  
    4.10  
    4.11  op_start() {
    4.12 @@ -71,7 +71,7 @@ case ${OP} in
    4.13         ;;
    4.14  
    4.15      *)
    4.16 -       echo 'Unknown command: ' ${OP}
    4.17 -       echo 'Valid commands are: start, stop, status'
    4.18 +       echo 'Unknown command: ' ${OP} >&2
    4.19 +       echo 'Valid commands are: start, stop, status' >&2
    4.20         exit 1
    4.21  esac
     5.1 --- a/tools/examples/vif-bridge	Tue May 17 10:39:50 2005 +0000
     5.2 +++ b/tools/examples/vif-bridge	Tue May 17 10:52:08 2005 +0000
     5.3 @@ -34,7 +34,7 @@
     5.4  # Exit if anything goes wrong
     5.5  set -e 
     5.6  
     5.7 -echo "vif-bridge $*"
     5.8 +echo "*vif-bridge $*" >&2
     5.9  
    5.10  # Operation name.
    5.11  OP=$1
    5.12 @@ -63,8 +63,8 @@ case $OP in
    5.13          iptcmd='-D'
    5.14          ;;
    5.15      *)
    5.16 -        echo 'Invalid command: ' $OP
    5.17 -        echo 'Valid commands are: up, down'
    5.18 +        echo 'Invalid command: ' $OP >&2
    5.19 +        echo 'Valid commands are: up, down' >&2
    5.20          exit 1
    5.21          ;;
    5.22  esac
     6.1 --- a/tools/examples/vif-nat	Tue May 17 10:39:50 2005 +0000
     6.2 +++ b/tools/examples/vif-nat	Tue May 17 10:52:08 2005 +0000
     6.3 @@ -23,7 +23,7 @@
     6.4  # Exit if anything goes wrong
     6.5  set -e 
     6.6  
     6.7 -echo "vif-nat $*"
     6.8 +echo "*vif-nat $*" >&2
     6.9  
    6.10  # Operation name.
    6.11  OP=$1
    6.12 @@ -56,8 +56,8 @@ case $OP in
    6.13          ipcmd='d'
    6.14          ;;
    6.15      *)
    6.16 -        echo 'Invalid command: ' $OP
    6.17 -        echo 'Valid commands are: up, down'
    6.18 +        echo 'Invalid command: ' $OP >&2
    6.19 +        echo 'Valid commands are: up, down' >&2
    6.20          exit 1
    6.21          ;;
    6.22  esac
     7.1 --- a/tools/examples/vif-route	Tue May 17 10:39:50 2005 +0000
     7.2 +++ b/tools/examples/vif-route	Tue May 17 10:52:08 2005 +0000
     7.3 @@ -24,7 +24,7 @@
     7.4  # Exit if anything goes wrong
     7.5  set -e 
     7.6  
     7.7 -echo "vif-route $*"
     7.8 +echo "*vif-route $*" >&2
     7.9  
    7.10  # Operation name.
    7.11  OP=$1
    7.12 @@ -57,8 +57,8 @@ case $OP in
    7.13          ipcmd='d'
    7.14          ;;
    7.15      *)
    7.16 -        echo 'Invalid command: ' $OP
    7.17 -        echo 'Valid commands are: up, down'
    7.18 +        echo 'Invalid command: ' $OP >&2
    7.19 +        echo 'Valid commands are: up, down' >&2
    7.20          exit 1
    7.21          ;;
    7.22  esac
     8.1 --- a/tools/python/xen/util/process.py	Tue May 17 10:39:50 2005 +0000
     8.2 +++ b/tools/python/xen/util/process.py	Tue May 17 10:52:08 2005 +0000
     8.3 @@ -4,10 +4,11 @@
     8.4  
     8.5  import popen2
     8.6  import select
     8.7 +import string
     8.8  
     8.9  from xen.xend.XendLogging import log
    8.10  
    8.11 -def system(cmd):
    8.12 +def runscript(cmd):
    8.13      # split after first space, then grab last component of path
    8.14      cmdname = "[%s] " % cmd.split()[0].split('/')[-1]
    8.15      # run command and grab stdin, stdout and stderr
    8.16 @@ -18,14 +19,19 @@ def system(cmd):
    8.17      p = select.poll()
    8.18      p.register(cout)
    8.19      p.register(cerr)
    8.20 +    stdout = ""
    8.21      while True:
    8.22          r = p.poll()
    8.23          for (fd, event) in r:
    8.24              if event == select.POLLHUP:
    8.25 -                return
    8.26 +                return stdout
    8.27              if fd == cout.fileno():
    8.28 -                l = cout.readline()
    8.29 -                log.info(cmdname + l.rstrip())
    8.30 +                stdout = stdout + cout.readline()
    8.31              if fd == cerr.fileno():
    8.32                  l = cerr.readline()
    8.33 -                log.error(cmdname + l.rstrip())
    8.34 +                if l[0] == '-':
    8.35 +                    log.debug(cmdname + l[1:].rstrip())
    8.36 +                elif l[0] == '*':
    8.37 +                    log.info(cmdname + l[1:].rstrip())
    8.38 +                else:
    8.39 +                    log.error(cmdname + l.rstrip())
     9.1 --- a/tools/python/xen/xend/Blkctl.py	Tue May 17 10:39:50 2005 +0000
     9.2 +++ b/tools/python/xen/xend/Blkctl.py	Tue May 17 10:52:08 2005 +0000
     9.3 @@ -4,6 +4,7 @@ import os
     9.4  import os.path
     9.5  import sys
     9.6  import string
     9.7 +import xen.util.process
     9.8  
     9.9  from xen.xend import XendRoot
    9.10  
    9.11 @@ -38,8 +39,6 @@ def block(op, type, dets, script=None):
    9.12      script = os.path.join(SCRIPT_DIR, script)
    9.13      args = [op] + string.split(dets, ':')
    9.14      args = ' '.join(args)
    9.15 -    out = os.popen(script + ' ' + args)
    9.16 -
    9.17 -    output = _readline(out)
    9.18 -    out.close()
    9.19 -    return string.rstrip(output)
    9.20 +    ret = xen.util.process.runscript(script + ' ' + args)
    9.21 +    if len(ret):
    9.22 +        return ret.splitlines()[0]
    10.1 --- a/tools/python/xen/xend/Vifctl.py	Tue May 17 10:39:50 2005 +0000
    10.2 +++ b/tools/python/xen/xend/Vifctl.py	Tue May 17 10:52:08 2005 +0000
    10.3 @@ -36,7 +36,9 @@ def network(op, script=None, bridge=None
    10.4      else:
    10.5          args.append("antispoof=no")
    10.6      args = ' '.join(args)
    10.7 -    xen.util.process.system(script + ' ' + args)
    10.8 +    ret = xen.util.process.runscript(script + ' ' + args)
    10.9 +    if len(ret):
   10.10 +        return ret.splitlines()[0]
   10.11  
   10.12  def set_vif_name(vif_old, vif_new):
   10.13      if vif_old == vif_new:
   10.14 @@ -81,5 +83,6 @@ def vifctl(op, vif=None, script=None, do
   10.15          ips = ' '.join(ipaddr)
   10.16          args.append("ip='%s'" % ips)
   10.17      args = ' '.join(args)
   10.18 -    os.system(script + ' ' + args)
   10.19 -
   10.20 +    ret = xen.util.process.runscript(script + ' ' + args)
   10.21 +    if len(ret):
   10.22 +        return ret.splitlines()[0]