ia64/xen-unstable

changeset 1581:f804ea4d2b51

bitkeeper revision 1.1011.1.8 (40dc1e19kas_BgjVEa6EgvJQgmzKIQ)

.
author kaf24@scramble.cl.cam.ac.uk
date Fri Jun 25 12:44:09 2004 +0000 (2004-06-25)
parents 710d42e7a3e1 e27e8d79cc6a
children e87e1ca75a41 9bf7f06d7614
files .hgtags tools/examples/Makefile tools/examples/init.d/xendomains tools/xenmgr/lib/XendBridge.py tools/xenmgr/lib/XendDomain.py tools/xenmgr/lib/XendDomainInfo.py tools/xenmgr/lib/XendRoot.py tools/xenmgr/lib/server/SrvConsoleServer.py tools/xenmgr/lib/server/SrvDomain.py tools/xenmgr/lib/server/blkif.py tools/xenmgr/lib/server/controller.py tools/xenmgr/lib/server/netif.py tools/xenmgr/lib/xm/create.py tools/xenmgr/lib/xm/main.py tools/xenmgr/lib/xm/opts.py tools/xenmgr/lib/xm/shutdown.py
line diff
     1.1 --- a/.hgtags	Thu Jun 24 21:00:39 2004 +0000
     1.2 +++ b/.hgtags	Fri Jun 25 12:44:09 2004 +0000
     1.3 @@ -1,5 +1,6 @@
     1.4  487b2ee37d1cecb5f3e7a546b05ad097a0226f2f beta1
     1.5  3d330e41f41ce1bc118c02346e18949ad5d67f6b latest-semistable
     1.6  30c521db4c71960b0cf1d9c9e1b658e77b535a3e latest-stable
     1.7 +7ae55a8c64e4eafacc6907232fa0f45a5c15becb semistable
     1.8  30c521db4c71960b0cf1d9c9e1b658e77b535a3e split-1.0
     1.9  3d330e41f41ce1bc118c02346e18949ad5d67f6b split-1.1
     2.1 --- a/tools/examples/Makefile	Thu Jun 24 21:00:39 2004 +0000
     2.2 +++ b/tools/examples/Makefile	Fri Jun 25 12:44:09 2004 +0000
     2.3 @@ -1,19 +1,20 @@
     2.4  
     2.5  INSTALL  = $(wildcard *.py)
     2.6  ETC	 = defaults democd netbsd xmdefaults
     2.7 +ETCDIR   = /etc/xen
     2.8  INITD    = init.d/xendomains init.d/xend
     2.9  
    2.10  all: 
    2.11  
    2.12  install: all
    2.13  	mkdir -p $(prefix)/usr/bin
    2.14 -	mkdir -p $(prefix)/etc/xc
    2.15 -	mkdir -p $(prefix)/etc/xc/auto
    2.16 +	mkdir -p $(prefix)$(ETCDIR)
    2.17 +	mkdir -p $(prefix)$(ETCDIR)/auto
    2.18  	mkdir -p $(prefix)/etc/init.d
    2.19  	install -m0755 $(INSTALL) $(prefix)/usr/bin
    2.20  	for i in $(ETC); \
    2.21 -	    do [ -a $(prefix)/etc/xc/$$i ] || \
    2.22 -	    install -m0644 $$i $(prefix)/etc/xc; \
    2.23 +	    do [ -a $(prefix)/$(ETCDIR)/$$i ] || \
    2.24 +	    install -m0644 $$i $(prefix)$(ETCDIR); \
    2.25  	done
    2.26  	install -m0755 $(INITD) $(prefix)/etc/init.d
    2.27  
     3.1 --- a/tools/examples/init.d/xendomains	Thu Jun 24 21:00:39 2004 +0000
     3.2 +++ b/tools/examples/init.d/xendomains	Fri Jun 25 12:44:09 2004 +0000
     3.3 @@ -19,6 +19,9 @@ RETVAL=0
     3.4  
     3.5  INITD=/etc/init.d/
     3.6  
     3.7 +AUTODIR=/etc/xen/auto
     3.8 +LOCKFILE=/var/lock/subsys/xendomains
     3.9 +
    3.10  if [ -e /lib/lsb ]; then
    3.11      # assume an LSB-compliant distro (Debian with LSB package,
    3.12      # recent-enough SuSE, others...)
    3.13 @@ -52,24 +55,23 @@ fi
    3.14  
    3.15  
    3.16  start() {
    3.17 -    if [ -f /var/lock/subsys/xendomains ]; then return; fi
    3.18 +    if [ -f $LOCKFILE ]; then return; fi
    3.19  
    3.20      echo -n $"Starting auto Xen domains:"
    3.21  
    3.22 -    # we expect config scripts for auto starting domains to be in
    3.23 -    # /etc/xc/auto/ - they could just be symlinks to files elsewhere
    3.24 -    if [ -d /etc/xc/auto ] &&
    3.25 -	    [ $(ls /etc/xc/auto/ | wc -l) -gt 0 ]; then
    3.26 +    # We expect config scripts for auto starting domains to be in
    3.27 +    # AUTODIR - they could just be symlinks to files elsewhere
    3.28 +    if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then
    3.29 +	touch $LOCKFILE
    3.30  	
    3.31 -       # create all domains with config files in /etc/xc/auto
    3.32 -	for dom in /etc/xc/auto/*; do
    3.33 -	    xc_dom_create.py -q -f $dom
    3.34 +       # Create all domains with config files in AUTODIR.
    3.35 +	for dom in  $AUTODIR/*; do
    3.36 +	    xm create --quiet --defaults $dom
    3.37  	    if [ $? -ne 0 ]; then
    3.38  		RETVAL=$?
    3.39  	    fi
    3.40  	done
    3.41  
    3.42 -	touch /var/lock/subsys/xendomains
    3.43      fi
    3.44  
    3.45      on_fn_exit
    3.46 @@ -78,40 +80,24 @@ start() {
    3.47  stop()
    3.48  {
    3.49      # NB. this shuts down ALL Xen domains (politely), not just the ones in
    3.50 -    # /etc/xc/auto/*
    3.51 +    # AUTODIR/*
    3.52      # This is because it's easier to do ;-) but arguably if this script is run
    3.53      # on system shutdown then it's also the right thing to do.
    3.54      
    3.55      echo -n $"Shutting down all Xen domains:"
    3.56  
    3.57 -    if [ -d /var/run/xendomains ] &&
    3.58 -	    [ $(ls /var/run/xendomains/ | wc -l) -gt 0 ]; then
    3.59 -	
    3.60 -	cd /var/run/xendomains/
    3.61 -
    3.62 -	for pid in *; do
    3.63 -	   
    3.64 -	    kill -s SIGTERM $(cat $pid)
    3.65 +    xm shutdown --all --wait --norestart
    3.66  
    3.67 -	done
    3.68 -
    3.69 -    fi
    3.70 -
    3.71 -    sleep 3 # avoid races
    3.72 -
    3.73 -    xc_dom_control.py shutdown all -w # shut down all domains, politely and wait
    3.74 -                                      # for all to exit
    3.75 -    
    3.76      RETVAL=$?
    3.77  
    3.78 -    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xendomains
    3.79 +    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
    3.80  
    3.81      on_fn_exit
    3.82  }
    3.83  
    3.84  # This does NOT necessarily restart all running domains: instead it
    3.85  # stops all running domains and then boots all the domains specified in
    3.86 -# /etc/xc/auto.  If other domains have been started manually then they will
    3.87 +# AUTODIR.  If other domains have been started manually then they will
    3.88  # not get restarted.
    3.89  # Commented out to avoid confusion!
    3.90  #
    3.91 @@ -149,7 +135,7 @@ case "$1" in
    3.92  #	;;
    3.93  
    3.94      status)
    3.95 -	xc_dom_control.py list
    3.96 +	xm list
    3.97  	;;
    3.98  
    3.99      *)
     4.1 --- a/tools/xenmgr/lib/XendBridge.py	Thu Jun 24 21:00:39 2004 +0000
     4.2 +++ b/tools/xenmgr/lib/XendBridge.py	Fri Jun 25 12:44:09 2004 +0000
     4.3 @@ -12,6 +12,7 @@ os.defpath = os.defpath + ':/sbin:/usr/s
     4.4  CMD_IFCONFIG = 'ifconfig'
     4.5  CMD_ROUTE    = 'route'
     4.6  CMD_BRCTL    = 'brctl'
     4.7 +CMD_IPTABLES = "iptables"
     4.8  
     4.9  DEFAULT_BRIDGE = 'nbe-br'
    4.10  DEFAULT_INTERFACE = 'eth0'
    4.11 @@ -61,6 +62,16 @@ def vif_bridge_rem(dom, vif, bridge=None
    4.12      d = { 'bridge': bridge, 'vif': vif_dev(dom, vif) }
    4.13      cmd(CMD_BRCTL, 'delif %(bridge)s %(vif)s' % d)
    4.14  
    4.15 +def vif_restrict_addr(dom, vif, addr, delete=0):
    4.16 +    d = { 'vif': vif_dev(dom, vif), 'addr': addr}
    4.17 +    if delete:
    4.18 +        d['flag'] = '-D'
    4.19 +    else:
    4.20 +        d['flag'] = '-A'
    4.21 +    cmd(CMD_IPTABLES, '-P FORWARD DROP')
    4.22 +    cmd(CMD_IPTABLES, '%(flag)s FORWARD -m physdev --physdev-in %(vif)s -s %(addr)s -j ACCEPT' % d)
    4.23 +    cmd(CMD_IPTABLES, '%(flag)s FORWARD -m physdev --physdev-out %(vif)s -d %(addr)s -j ACCEPT' % d)
    4.24 +
    4.25  def bridge_create(bridge=None, **kwd):
    4.26      """Create a bridge.
    4.27      Defaults hello time to 0, forward delay to 0 and stp off.
     5.1 --- a/tools/xenmgr/lib/XendDomain.py	Thu Jun 24 21:00:39 2004 +0000
     5.2 +++ b/tools/xenmgr/lib/XendDomain.py	Fri Jun 25 12:44:09 2004 +0000
     5.3 @@ -42,8 +42,13 @@ class XendDomain:
     5.4          if xroot.get_rebooted():
     5.5              print 'XendDomain> rebooted: removing all domain info'
     5.6              self.rm_all()
     5.7 +        eserver.subscribe('xend.virq', self.onVirq)
     5.8          self.initial_refresh()
     5.9  
    5.10 +    def onVirq(self, event, val):
    5.11 +        print 'XendDomain> virq', val
    5.12 +        self.reap()
    5.13 +
    5.14      def rm_all(self):
    5.15          """Remove all domain info. Used after reboot.
    5.16          """
    5.17 @@ -136,13 +141,33 @@ class XendDomain:
    5.18  
    5.19      def _delete_domain(self, id, notify=1):
    5.20          if id in self.domain:
    5.21 -            self.domain[id].died()
    5.22              if notify: eserver.inject('xend.domain.died', id)
    5.23              del self.domain[id]
    5.24          if id in self.domain_db:
    5.25              del self.domain_db[id]
    5.26              self.db.delete(id)
    5.27  
    5.28 +    def reap(self):
    5.29 +        print 'reap>'
    5.30 +        domlist = xc.domain_getinfo()
    5.31 +        casualties = []
    5.32 +        for d in domlist:
    5.33 +            print 'dom', d
    5.34 +            dead = 0
    5.35 +            dead = dead or (d['crashed'] or d['shutdown'])
    5.36 +            dead = dead or (d['dying'] and
    5.37 +                            not(d['running'] or d['paused'] or d['blocked']))
    5.38 +            if dead:
    5.39 +                casualties.append(d)
    5.40 +        for d in casualties:
    5.41 +            id = str(d['dom'])
    5.42 +            print 'died> id=', id, d
    5.43 +            dominfo = self.domain.get(id)
    5.44 +            if not dominfo: continue
    5.45 +            dominfo.died()
    5.46 +            self.domain_destroy(id, refresh=0)
    5.47 +        print 'reap<'
    5.48 +
    5.49      def refresh(self):
    5.50          """Refresh domain list from Xen.
    5.51          """
    5.52 @@ -169,6 +194,7 @@ class XendDomain:
    5.53                  d.update(dominfo)
    5.54              else:
    5.55                  self._delete_domain(d.id)
    5.56 +        self.reap()
    5.57  
    5.58      def refresh_domain(self, id):
    5.59          dom = int(id)
    5.60 @@ -232,7 +258,7 @@ class XendDomain:
    5.61          self.refresh()
    5.62          return val
    5.63      
    5.64 -    def domain_destroy(self, id):
    5.65 +    def domain_destroy(self, id, refresh=1):
    5.66          """Terminate domain immediately.
    5.67          """
    5.68          dom = int(id)
    5.69 @@ -240,7 +266,7 @@ class XendDomain:
    5.70              return 0
    5.71          eserver.inject('xend.domain.destroy', id)
    5.72          val = xc.domain_destroy(dom=dom)
    5.73 -        self.refresh()
    5.74 +        if refresh: self.refresh()
    5.75          return val       
    5.76  
    5.77      def domain_migrate(self, id, dst):
     6.1 --- a/tools/xenmgr/lib/XendDomainInfo.py	Thu Jun 24 21:00:39 2004 +0000
     6.2 +++ b/tools/xenmgr/lib/XendDomainInfo.py	Fri Jun 25 12:44:09 2004 +0000
     6.3 @@ -364,6 +364,7 @@ class XendDomainInfo:
     6.4          """Update with  info from xc.domain_getinfo().
     6.5          """
     6.6          self.info = info
     6.7 +        self.memory = self.info['mem_kb'] / 1024
     6.8  
     6.9      def __str__(self):
    6.10          s = "domain"
     7.1 --- a/tools/xenmgr/lib/XendRoot.py	Thu Jun 24 21:00:39 2004 +0000
     7.2 +++ b/tools/xenmgr/lib/XendRoot.py	Fri Jun 25 12:44:09 2004 +0000
     7.3 @@ -30,13 +30,13 @@ def last_reboot():
     7.4  class XendRoot:
     7.5      """Root of the management classes."""
     7.6  
     7.7 -    lastboot_default = "/etc/xen/xend/lastboot"
     7.8 +    lastboot_default = "/var/xen/lastboot"
     7.9  
    7.10      """Default path to the root of the database."""
    7.11 -    dbroot_default = "/etc/xen/xend/xenmgr-db"
    7.12 +    dbroot_default = "/var/xen/xend-db"
    7.13  
    7.14      """Default path to the config file."""
    7.15 -    config_default = "/etc/xen/xenmgr-config.sxp"
    7.16 +    config_default = "/etc/xen/xend-config.sxp"
    7.17  
    7.18      """Environment variable used to override config_default."""
    7.19      config_var     = "XEND_CONFIG"
     8.1 --- a/tools/xenmgr/lib/server/SrvConsoleServer.py	Thu Jun 24 21:00:39 2004 +0000
     8.2 +++ b/tools/xenmgr/lib/server/SrvConsoleServer.py	Fri Jun 25 12:44:09 2004 +0000
     8.3 @@ -417,6 +417,7 @@ class VirqClient:
     8.4  
     8.5      def virqReceived(self, virq):
     8.6          print 'VirqClient.virqReceived>', virq
     8.7 +        eserver.inject('xend.virq', virq)
     8.8  
     8.9      def lostChannel(self, channel):
    8.10          print 'VirqClient.lostChannel>', channel
     9.1 --- a/tools/xenmgr/lib/server/SrvDomain.py	Thu Jun 24 21:00:39 2004 +0000
     9.2 +++ b/tools/xenmgr/lib/server/SrvDomain.py	Fri Jun 25 12:44:09 2004 +0000
     9.3 @@ -40,14 +40,14 @@ class SrvDomain(SrvDir):
     9.4      def op_save(self, op, req):
     9.5          fn = FormFn(self.xd.domain_save,
     9.6                      [['dom', 'int'],
     9.7 -                     ['dst', 'str']])
     9.8 +                     ['file', 'str']])
     9.9          val = fn(req.args, {'dom': self.dom.id})
    9.10          return val
    9.11  
    9.12      def op_restore(self, op, req):
    9.13          fn = FormFn(self.xd.domain_restore,
    9.14                      [['dom', 'int'],
    9.15 -                     ['src', 'str']])
    9.16 +                     ['file', 'str']])
    9.17          val = fn(req.args, {'dom': self.dom.id})
    9.18          return val
    9.19          
    10.1 --- a/tools/xenmgr/lib/server/blkif.py	Thu Jun 24 21:00:39 2004 +0000
    10.2 +++ b/tools/xenmgr/lib/server/blkif.py	Fri Jun 25 12:44:09 2004 +0000
    10.3 @@ -1,5 +1,8 @@
    10.4  from twisted.internet import defer
    10.5  
    10.6 +from xenmgr import sxp
    10.7 +from xenmgr import PrettyPrint
    10.8 +
    10.9  import channel
   10.10  import controller
   10.11  from messages import *
   10.12 @@ -140,11 +143,12 @@ class BlkDev(controller.Dev):
   10.13          return 'w' not in self.mode
   10.14  
   10.15      def sxpr(self):
   10.16 -        print 'BlkDev>sxpr>', vars(self)
   10.17 -        val = ['blkif', ['vdev', self.vdev], ['mode', self.mode] ]
   10.18 +        val = ['blkdev', ['vdev', self.vdev], ['mode', self.mode] ]
   10.19          return val
   10.20  
   10.21      def destroy(self):
   10.22 +        print 'BlkDev>destroy>', self.vdev
   10.23 +        PrettyPrint.prettyprint(self.sxpr())
   10.24          self.controller.send_be_vbd_destroy(self.vdev)
   10.25          
   10.26  class BlkifController(controller.Controller):
   10.27 @@ -166,9 +170,18 @@ class BlkifController(controller.Control
   10.28                  self.recv_fe_interface_connect,
   10.29              }
   10.30          self.attached = 1
   10.31 +        self.evtchn = None
   10.32          self.registerChannel()
   10.33          #print 'BlkifController<', 'dom=', self.dom, 'idx=', self.idx
   10.34  
   10.35 +    def sxpr(self):
   10.36 +        val = ['blkif', ['dom', self.dom]]
   10.37 +        if self.evtchn:
   10.38 +            val.append(['evtchn',
   10.39 +                        self.evtchn['port1'],
   10.40 +                        self.evtchn['port2']])
   10.41 +        return val
   10.42 +
   10.43      def lostChannel(self):
   10.44          print 'BlkifController>lostChannel>', 'dom=', self.dom
   10.45          #self.destroyDevices()
   10.46 @@ -201,7 +214,9 @@ class BlkifController(controller.Control
   10.47          return d
   10.48  
   10.49      def destroy(self):
   10.50 +        print 'BlkifController>destroy> dom=', self.dom
   10.51          self.destroyDevices()
   10.52 +        self.send_be_destroy()
   10.53  
   10.54      def destroyDevices(self):
   10.55          for dev in self.getDevices():
   10.56 @@ -229,7 +244,8 @@ class BlkifController(controller.Control
   10.57          return self.attached
   10.58  
   10.59      def reattached(self):
   10.60 -        """All devices have been reattached after the back-end control domain has changed.
   10.61 +        """All devices have been reattached after the back-end control
   10.62 +        domain has changed.
   10.63          """
   10.64          msg = packMsg('blkif_fe_interface_status_changed_t',
   10.65                        { 'handle' : 0,
   10.66 @@ -246,6 +262,8 @@ class BlkifController(controller.Control
   10.67      def recv_fe_interface_connect(self, msg, req):
   10.68          val = unpackMsg('blkif_fe_interface_connect_t', msg)
   10.69          self.evtchn = channel.eventChannel(0, self.dom)
   10.70 +        print 'recv_fe_interface_connect>'
   10.71 +        PrettyPrint.prettyprint(self.sxpr())
   10.72          msg = packMsg('blkif_be_connect_t',
   10.73                        { 'domid'        : self.dom,
   10.74                          'blkif_handle' : val['handle'],
   10.75 @@ -272,6 +290,13 @@ class BlkifController(controller.Control
   10.76                          'blkif_handle' : 0 })
   10.77          self.factory.writeRequest(msg)
   10.78  
   10.79 +    def send_be_destroy(self):
   10.80 +        print '>BlkifController>send_be_destroy>', 'dom=', self.dom
   10.81 +        msg = packMsg('blkif_be_destroy_t',
   10.82 +                      { 'domid'        : self.dom,
   10.83 +                        'blkif_handle' : 0 })
   10.84 +        self.factory.writeRequest(msg)
   10.85 +
   10.86      def send_be_vbd_create(self, vdev):
   10.87          dev = self.devices[vdev]
   10.88          msg = packMsg('blkif_be_vbd_create_t',
   10.89 @@ -293,6 +318,8 @@ class BlkifController(controller.Control
   10.90          self.factory.writeRequest(msg)
   10.91  
   10.92      def send_be_vbd_destroy(self, vdev):
   10.93 +        print '>BlkifController>send_be_vbd_destroy>', 'dom=', self.dom, 'vdev=', vdev
   10.94 +        PrettyPrint.prettyprint(self.sxpr())
   10.95          dev = self.devices[vdev]
   10.96          msg = packMsg('blkif_be_vbd_destroy_t',
   10.97                        { 'domid'                : self.dom,
    11.1 --- a/tools/xenmgr/lib/server/controller.py	Thu Jun 24 21:00:39 2004 +0000
    11.2 +++ b/tools/xenmgr/lib/server/controller.py	Fri Jun 25 12:44:09 2004 +0000
    11.3 @@ -132,7 +132,7 @@ class Controller(CtrlMsgRcvr):
    11.4  
    11.5      def close(self):
    11.6          self.deregisterChannel()
    11.7 -        self.lostChannel(self)
    11.8 +        self.lostChannel()
    11.9  
   11.10      def lostChannel(self):
   11.11          self.factory.instanceClosed(self)
    12.1 --- a/tools/xenmgr/lib/server/netif.py	Thu Jun 24 21:00:39 2004 +0000
    12.2 +++ b/tools/xenmgr/lib/server/netif.py	Fri Jun 25 12:44:09 2004 +0000
    12.3 @@ -2,6 +2,8 @@ import random
    12.4  
    12.5  from twisted.internet import defer
    12.6  
    12.7 +from xenmgr import sxp
    12.8 +from xenmgr import PrettyPrint
    12.9  from xenmgr import XendBridge
   12.10  
   12.11  import channel
   12.12 @@ -117,9 +119,13 @@ class NetDev(controller.Dev):
   12.13      def sxpr(self):
   12.14          vif = str(self.vif)
   12.15          mac = ':'.join(map(lambda x: "%x" % x, self.mac))
   12.16 -        val = ['netif', ['vif', vif], ['mac', mac]]
   12.17 +        val = ['netdev', ['vif', vif], ['mac', mac]]
   12.18          if self.bridge:
   12.19 -            val += ['bridge', self.bridge]
   12.20 +            val.append(['bridge', self.bridge])
   12.21 +        if self.evtchn:
   12.22 +            val.append(['evtchn',
   12.23 +                        self.evtchn['port1'],
   12.24 +                        self.evtchn['port2']])
   12.25          return val
   12.26  
   12.27      def bridge_add(self, bridge):
   12.28 @@ -131,6 +137,8 @@ class NetDev(controller.Dev):
   12.29          self.bridge = None
   12.30  
   12.31      def destroy(self):
   12.32 +        print 'NetDev>destroy>', 'vif=', self.vif
   12.33 +        PrettyPrint.prettyprint(self.sxpr())
   12.34          self.bridge_rem()
   12.35          self.controller.send_be_destroy(self.vif)
   12.36          
   12.37 @@ -155,7 +163,10 @@ class NetifController(controller.Control
   12.38          self.registerChannel()
   12.39          #print 'NetifController<', 'dom=', self.dom, 'idx=', self.idx
   12.40  
   12.41 -
   12.42 +    def sxpr(self):
   12.43 +        val = ['netif', ['dom', self.dom]]
   12.44 +        return val
   12.45 +    
   12.46      def randomMAC(self):
   12.47          # VIFs get a random MAC address with a "special" vendor id.
   12.48          # 
   12.49 @@ -194,6 +205,7 @@ class NetifController(controller.Control
   12.50          return dev
   12.51  
   12.52      def destroy(self):
   12.53 +        print 'NetifController>destroy>', 'dom=', self.dom
   12.54          self.destroyDevices()
   12.55          
   12.56      def destroyDevices(self):
   12.57 @@ -270,7 +282,8 @@ class NetifController(controller.Control
   12.58          self.factory.writeRequest(msg)
   12.59  
   12.60      def send_be_destroy(self, vif):
   12.61 -        print 'send_be_destroy>', 'dom=', self.dom, 'vif=', vif
   12.62 +        print 'NetifController>send_be_destroy>', 'dom=', self.dom, 'vif=', vif
   12.63 +        PrettyPrint.prettyprint(self.sxpr())
   12.64          dev = self.devices[vif]
   12.65          del self.devices[vif]
   12.66          msg = packMsg('netif_be_destroy_t',
    13.1 --- a/tools/xenmgr/lib/xm/create.py	Thu Jun 24 21:00:39 2004 +0000
    13.2 +++ b/tools/xenmgr/lib/xm/create.py	Fri Jun 25 12:44:09 2004 +0000
    13.3 @@ -24,7 +24,7 @@ gopts.opt('quiet', short='q',
    13.4           use="Quiet.")
    13.5  
    13.6  gopts.opt('path', val='PATH',
    13.7 -         fn=set_value, default='.:/etc/xc',
    13.8 +         fn=set_value, default='.:/etc/xen',
    13.9           use="Search path for default scripts.")
   13.10  
   13.11  gopts.opt('defaults', short='f', val='FILE',
   13.12 @@ -220,12 +220,13 @@ def configure_vifs(config_devs, opts):
   13.13              config_vif.append(['bridge', bridge])
   13.14          config_devs.append(['device', config_vif])
   13.15  
   13.16 -##     if vfr_ipaddr:
   13.17 -##         config_vfr = ['vfr']
   13.18 -##         idx = 0 # No way of saying which IP is for which vif?
   13.19 -##         for ip in vfr_ipaddr:
   13.20 -##             config_vfr.append(['vif', ['id', idx], ['ip', ip]])
   13.21 -##         config.append(config_vfr)
   13.22 +def configure_vfr(config, opts):
   13.23 +     if not opts.ipaddr: return
   13.24 +     config_vfr = ['vfr']
   13.25 +     idx = 0 # No way of saying which IP is for which vif?
   13.26 +     for ip in opts.ipaddr:
   13.27 +         config_vfr.append(['vif', ['id', idx], ['ip', ip]])
   13.28 +     config.append(config_vfr)
   13.29  
   13.30  
   13.31  def make_config(opts):
    14.1 --- a/tools/xenmgr/lib/xm/main.py	Thu Jun 24 21:00:39 2004 +0000
    14.2 +++ b/tools/xenmgr/lib/xm/main.py	Fri Jun 25 12:44:09 2004 +0000
    14.3 @@ -4,6 +4,7 @@
    14.4  import os
    14.5  import os.path
    14.6  import sys
    14.7 +from getopt import getopt
    14.8  
    14.9  from xenmgr import PrettyPrint
   14.10  from xenmgr import sxp
   14.11 @@ -127,7 +128,7 @@ class ProgHelp(Prog):
   14.12              name = args[1]
   14.13              p = self.xm.getprog(name)
   14.14              if p:
   14.15 -                p.help(args)
   14.16 +                p.help(args[1:])
   14.17              else:
   14.18                  print '%s: Unknown command: %s' % (self.name, name)
   14.19          else:
   14.20 @@ -159,22 +160,13 @@ class ProgSave(Prog):
   14.21      info = """Save domain state (and config) to file."""
   14.22  
   14.23      def help(self, args):
   14.24 -        print self.name, "DOM FILE [CONFIG]"
   14.25 -        print """\nSave domain with id DOM to FILE.
   14.26 -        Optionally save config to CONFIG."""
   14.27 +        print args[0], "DOM FILE"
   14.28 +        print """\nSave domain with id DOM to FILE."""
   14.29          
   14.30      def main(self, args):
   14.31 -        if len(args) < 3: self.err("%s: Missing arguments" % self.name)
   14.32 +        if len(args) < 3: self.err("%s: Missing arguments" % args[0])
   14.33          dom = args[1]
   14.34          savefile = os.path.abspath(args[2])
   14.35 -        configfile = None
   14.36 -        if len(args) == 4:
   14.37 -            configfile = os.path.abspath(args[3])
   14.38 -        if configfile:
   14.39 -            out = file(configfile, 'w')
   14.40 -            config = server.xend_domain(dom)
   14.41 -            PrettyPrint.prettyprint(config, out=out)
   14.42 -            out.close()
   14.43          server.xend_domain_save(dom, savefile)
   14.44  
   14.45  xm.prog(ProgSave)
   14.46 @@ -185,13 +177,16 @@ class ProgRestore(Prog):
   14.47      info = """Create a domain from a saved state."""
   14.48  
   14.49      def help(self, args):
   14.50 -        print self.name, "FILE CONFIG"
   14.51 +        print args[0], "FILE [CONFIG]"
   14.52          print "\nRestore a domain from FILE using configuration CONFIG."
   14.53      
   14.54      def main(self, help, args):
   14.55 -        if len(args) < 3: self.err("%s: Missing arguments" % self.name)
   14.56 +        if len(args) < 2: self.err("%s: Missing arguments" % args[0])
   14.57          savefile =  os.path.abspath(args[1])
   14.58 -        configfile = os.path.abspath(args[2])
   14.59 +        if len(args) >= 3:
   14.60 +            configfile = os.path.abspath(args[2])
   14.61 +        else:
   14.62 +            configfile = None
   14.63          info = server.xend_domain_restore(savefile, configfile)
   14.64          PrettyPrint.prettyprint(info)
   14.65  
   14.66 @@ -202,20 +197,41 @@ class ProgList(Prog):
   14.67      name = "list"
   14.68      info = """List info about domains."""
   14.69  
   14.70 +    short_options = 'l'
   14.71 +    long_options = ['long']
   14.72 +
   14.73      def help(self, args):
   14.74          if help:
   14.75 -            print self.name, '[DOM...]'
   14.76 +            print args[0], '[options] [DOM...]'
   14.77              print """\nGet information about domains.
   14.78 -            Either all domains or the domains given."""
   14.79 +            Either all domains or the domains given.
   14.80 +
   14.81 +            -l, --long   Get more detailed information.
   14.82 +            """
   14.83              return
   14.84          
   14.85      def main(self, args):
   14.86 -        n = len(args)
   14.87 -        if n == 1:
   14.88 -            doms = server.xend_domains()
   14.89 +        use_long = 0
   14.90 +        (options, params) = getopt(args[1:],
   14.91 +                                   self.short_options,
   14.92 +                                   self.long_options)
   14.93 +        n = len(params)
   14.94 +        for (k, v) in options:
   14.95 +            if k in ['-l', '--long']:
   14.96 +                use_long = 1
   14.97 +                
   14.98 +        if n == 0:
   14.99 +            doms = map(int, server.xend_domains())
  14.100 +            doms.sort()
  14.101          else:
  14.102 -            doms = map(int, args[1:])
  14.103 -        doms.sort()
  14.104 +            doms = map(int, params)
  14.105 +            
  14.106 +        if use_long:
  14.107 +            self.long_list(doms)
  14.108 +        else:
  14.109 +            self.brief_list(doms)
  14.110 +
  14.111 +    def brief_list(self, doms):
  14.112          print 'Dom  Name             Mem(MB)  CPU  State  Time(s)'
  14.113          for dom in doms:
  14.114              info = server.xend_domain(dom)
  14.115 @@ -228,6 +244,12 @@ class ProgList(Prog):
  14.116              d['cpu_time'] = float(sxp.child_value(info, 'cpu_time', '0'))
  14.117              print ("%(dom)-4d %(name)-16s %(mem)7d  %(cpu)3d  %(state)5s  %(cpu_time)7.1f" % d)
  14.118  
  14.119 +    def long_list(self, doms):
  14.120 +        for dom in doms:
  14.121 +            info = server.xend_domain(dom)
  14.122 +            print '\nDomain %d' % dom
  14.123 +            PrettyPrint.prettyprint(info)
  14.124 +
  14.125  xm.prog(ProgList)
  14.126  
  14.127  class ProgDestroy(Prog):
  14.128 @@ -236,11 +258,11 @@ class ProgDestroy(Prog):
  14.129      info = """Terminate a domain immediately."""
  14.130  
  14.131      def help(self, args):
  14.132 -        print self.name, 'DOM'
  14.133 +        print args[0], 'DOM'
  14.134          print '\nTerminate domain DOM immediately.'
  14.135  
  14.136      def main(self, args):
  14.137 -        if len(args) < 2: self.err("%s: Missing domain" % self.name)
  14.138 +        if len(args) < 2: self.err("%s: Missing domain" % args[0])
  14.139          dom = args[1]
  14.140          server.xend_domain_destroy(dom)
  14.141  
  14.142 @@ -252,8 +274,7 @@ class ProgShutdown(Prog):
  14.143      info = """Shutdown a domain."""
  14.144  
  14.145      def help(self, args):
  14.146 -        print self.name, 'DOM'
  14.147 -        print '\nSignal domain DOM to shutdown.'
  14.148 +        shutdown.main([args[0], '-h'])
  14.149      
  14.150      def main(self, args):
  14.151          shutdown.main(args)
  14.152 @@ -266,11 +287,11 @@ class ProgPause(Prog):
  14.153      info = """Pause execution of a domain."""
  14.154  
  14.155      def help(self, args):
  14.156 -        print self.name, 'DOM'
  14.157 +        print args[0], 'DOM'
  14.158          print '\nPause execution of domain DOM.'
  14.159  
  14.160      def main(self, args):
  14.161 -        if len(args) < 2: self.err("%s: Missing domain" % self.name)
  14.162 +        if len(args) < 2: self.err("%s: Missing domain" % args[0])
  14.163          dom = args[1]
  14.164          server.xend_domain_pause(dom)
  14.165  
  14.166 @@ -282,11 +303,11 @@ class ProgUnpause(Prog):
  14.167      info = """Unpause a paused domain."""
  14.168  
  14.169      def help(self, args):
  14.170 -        print self.name, 'DOM'
  14.171 +        print args[0], 'DOM'
  14.172          print '\nUnpause execution of domain DOM.'
  14.173  
  14.174      def main(self, args):
  14.175 -        if len(args) < 2: self.err("%s: Missing domain" % self.name)
  14.176 +        if len(args) < 2: self.err("%s: Missing domain" % args[0])
  14.177          dom = args[1]
  14.178          server.xend_domain_unpause(dom)
  14.179  
  14.180 @@ -298,11 +319,11 @@ class ProgPincpu(Prog):
  14.181      info = """Pin a domain to a cpu. """
  14.182  
  14.183      def help(self, args):
  14.184 -        print self.name,'DOM CPU'
  14.185 +        print args[0],'DOM CPU'
  14.186          print '\nPin domain DOM to cpu CPU.'
  14.187  
  14.188      def main(self, args):
  14.189 -        if len(args) != 3: self.err("%s: Invalid argument(s)" % self.name)
  14.190 +        if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
  14.191          v = map(int, args[1:3])
  14.192          server.xend_domain_pincpu(*v)
  14.193  
  14.194 @@ -314,11 +335,11 @@ class ProgBvt(Prog):
  14.195      info = """Set BVT scheduler parameters."""
  14.196      
  14.197      def help(self, args):
  14.198 -        print self.name, "DOM MCUADV WARP WARPL WARPU"
  14.199 +        print args[0], "DOM MCUADV WARP WARPL WARPU"
  14.200          print '\nSet Borrowed Virtual Time scheduler parameters.'
  14.201  
  14.202      def main(self, args):
  14.203 -        if len(args) != 6: self.err("%s: Invalid argument(s)" % self.name)
  14.204 +        if len(args) != 6: self.err("%s: Invalid argument(s)" % args[0])
  14.205          v = map(int, args[1:6])
  14.206          server.xend_domain_cpu_bvt_set(*v)
  14.207  
  14.208 @@ -330,11 +351,11 @@ class ProgBvtslice(Prog):
  14.209      info = """Set the BVT scheduler slice."""
  14.210  
  14.211      def help(self, args):
  14.212 -        print self.name, 'SLICE'
  14.213 +        print args[0], 'SLICE'
  14.214          print '\nSet Borrowed Virtual Time scheduler slice.'
  14.215  
  14.216      def main(self, args):
  14.217 -        if len(args) < 2: self.err('%s: Missing slice' % self.name)
  14.218 +        if len(args) < 2: self.err('%s: Missing slice' % args[0])
  14.219          server.xend_node_cpu_bvt_slice_set(slice)
  14.220  
  14.221  xm.prog(ProgBvtslice)
  14.222 @@ -345,11 +366,11 @@ class ProgAtropos(Prog):
  14.223      info = """Set atropos parameters."""
  14.224  
  14.225      def help(self, args):
  14.226 -        print self.name, "DOM PERIOD SLICE LATENCY XTRATIME"
  14.227 +        print args[0], "DOM PERIOD SLICE LATENCY XTRATIME"
  14.228          print "\nSet atropos parameters."
  14.229  
  14.230      def main(self, args):
  14.231 -        if len(args) != 5: self.err("%s: Invalid argument(s)" % self.name)
  14.232 +        if len(args) != 5: self.err("%s: Invalid argument(s)" % args[0])
  14.233          v = map(int, args[1:5])
  14.234          server.xend_domain_cpu_atropos_set(*v)
  14.235  
  14.236 @@ -361,11 +382,11 @@ class ProgRrobin(Prog):
  14.237      info = """Set round robin slice."""
  14.238  
  14.239      def help(self, args):
  14.240 -        print self.name, "SLICE"
  14.241 +        print args[0], "SLICE"
  14.242          print "\nSet round robin scheduler slice."
  14.243  
  14.244      def main(self, args):
  14.245 -        if len(args) != 2: self.err("%s: Invalid argument(s)" % self.name)
  14.246 +        if len(args) != 2: self.err("%s: Invalid argument(s)" % args[0])
  14.247          rrslice = int(args[1])
  14.248          server.xend_node_rrobin_set(rrslice)
  14.249  
  14.250 @@ -407,11 +428,11 @@ class ProgConsole(Prog):
  14.251      info = """Open a console to a domain."""
  14.252      
  14.253      def help(self, args):
  14.254 -        print self.name, "DOM"
  14.255 +        print "console DOM"
  14.256          print "\nOpen a console to domain DOM."
  14.257  
  14.258      def main(self, args):
  14.259 -        if len(args) < 2: self.err("%s: Missing domain" % self.name)
  14.260 +        if len(args) < 2: self.err("%s: Missing domain" % args[0])
  14.261          dom = args[1]
  14.262          info = server.xend_domain(dom)
  14.263          console = sxp.child(info, "console")
    15.1 --- a/tools/xenmgr/lib/xm/opts.py	Thu Jun 24 21:00:39 2004 +0000
    15.2 +++ b/tools/xenmgr/lib/xm/opts.py	Fri Jun 25 12:44:09 2004 +0000
    15.3 @@ -273,7 +273,7 @@ class Opts:
    15.4                  self.load(p)
    15.5                  break
    15.6          else:
    15.7 -            self.err("Cannot open defaults file %s" % self.defaults)
    15.8 +            self.err("Cannot open defaults file %s" % self.vals.defaults)
    15.9  
   15.10      def load(self, defaults, help=0):
   15.11          """Load a defaults file. Local variables in the file
    16.1 --- a/tools/xenmgr/lib/xm/shutdown.py	Thu Jun 24 21:00:39 2004 +0000
    16.2 +++ b/tools/xenmgr/lib/xm/shutdown.py	Fri Jun 25 12:44:09 2004 +0000
    16.3 @@ -24,6 +24,10 @@ gopts.opt('wait', short='w',
    16.4           fn=set_true, default=0,
    16.5           use='Wait for shutdown to complete.')
    16.6  
    16.7 +gopts.opt('norestart', short='n',
    16.8 +          fn=set_true, default=0,
    16.9 +          use='Prevent domain restart.')
   16.10 +
   16.11  def shutdown(opts, doms, wait):
   16.12      def domains():
   16.13          return [ int(a) for a in server.xend_domains() ]