ia64/xen-unstable

changeset 1913:e59c333c2ba0

bitkeeper revision 1.1108.1.25 (4105269f4bH3Ihj0IYW6E935SmTCsw)

Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/hp.bk
author kaf24@scramble.cl.cam.ac.uk
date Mon Jul 26 15:43:27 2004 +0000 (2004-07-26)
parents 408ce4535108 61e2ad7d06bd
children ed42e6d6556e 9ae151a45505
files linux-2.4.26-xen-sparse/arch/xen/defconfig-xen0 tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py tools/python/xen/xm/main.py tools/xfrd/Makefile
line diff
     1.1 --- a/linux-2.4.26-xen-sparse/arch/xen/defconfig-xen0	Mon Jul 26 15:10:26 2004 +0000
     1.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/defconfig-xen0	Mon Jul 26 15:43:27 2004 +0000
     1.3 @@ -905,12 +905,29 @@ CONFIG_LOG_BUF_SHIFT=0
     1.4  #
     1.5  # Cryptographic options
     1.6  #
     1.7 -# CONFIG_CRYPTO is not set
     1.8 +CONFIG_CRYPTO=y
     1.9 +CONFIG_CRYPTO_HMAC=y
    1.10 +CONFIG_CRYPTO_NULL=m
    1.11 +CONFIG_CRYPTO_MD4=m
    1.12 +CONFIG_CRYPTO_MD5=m
    1.13 +CONFIG_CRYPTO_SHA1=m
    1.14 +CONFIG_CRYPTO_SHA256=m
    1.15 +CONFIG_CRYPTO_SHA512=m
    1.16 +CONFIG_CRYPTO_DES=m
    1.17 +CONFIG_CRYPTO_BLOWFISH=m
    1.18 +CONFIG_CRYPTO_TWOFISH=m
    1.19 +CONFIG_CRYPTO_SERPENT=m
    1.20 +CONFIG_CRYPTO_AES=m
    1.21 +CONFIG_CRYPTO_CAST5=m
    1.22 +CONFIG_CRYPTO_CAST6=m
    1.23 +CONFIG_CRYPTO_ARC4=m
    1.24 +CONFIG_CRYPTO_DEFLATE=m
    1.25 +# CONFIG_CRYPTO_TEST is not set
    1.26  
    1.27  #
    1.28  # Library routines
    1.29  #
    1.30  # CONFIG_CRC32 is not set
    1.31  CONFIG_ZLIB_INFLATE=y
    1.32 -# CONFIG_ZLIB_DEFLATE is not set
    1.33 +CONFIG_ZLIB_DEFLATE=m
    1.34  # CONFIG_FW_LOADER is not set
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Mon Jul 26 15:10:26 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Mon Jul 26 15:43:27 2004 +0000
     2.3 @@ -130,9 +130,11 @@ class XendDomain:
     2.4      def initial_refresh(self):
     2.5          """Refresh initial domain info from domain_db.
     2.6          """
     2.7 -        #for d in self.domain_db.values(): print 'db dom=', d
     2.8 +            
     2.9 +        def cb_all_ok(val):
    2.10 +            self.refresh()
    2.11 +
    2.12          domlist = xc.domain_getinfo()
    2.13 -        #for d in domlist: print 'xc dom=', d
    2.14          doms = {}
    2.15          for d in domlist:
    2.16              domid = str(d['dom'])
    2.17 @@ -140,22 +142,13 @@ class XendDomain:
    2.18          dlist = []
    2.19          for config in self.domain_db.values():
    2.20              domid = str(sxp.child_value(config, 'id'))
    2.21 -            #print "dom=", domid, "config=", config
    2.22              if domid in doms:
    2.23 -                #print "dom=", domid, "new"
    2.24 -                deferred = self._new_domain(config, doms[domid])
    2.25 -                dlist.append(deferred)
    2.26 +                d_dom = self._new_domain(config, doms[domid])
    2.27 +                dlist.append(d_dom)
    2.28              else:
    2.29 -                #print "dom=", domid, "del"
    2.30                  self._delete_domain(domid)
    2.31 -        deferred = defer.DeferredList(dlist, fireOnOneErrback=1)
    2.32 -        def cbok(val):
    2.33 -            #print "doms:"
    2.34 -            #for d in self.domain.values(): print 'dom', d
    2.35 -            self.refresh()
    2.36 -            #print "XendDomain>initial_refresh> doms:"
    2.37 -            #for d in self.domain.values(): print 'dom', d
    2.38 -        deferred.addCallback(cbok)
    2.39 +        d_all = defer.DeferredList(dlist, fireOnOneErrback=1)
    2.40 +        d_all.addCallback(cb_all_ok)
    2.41  
    2.42      def sync(self):
    2.43          """Sync domain db to disk.
    2.44 @@ -179,10 +172,13 @@ class XendDomain:
    2.45          @param info:      domain info from xen
    2.46          @return: deferred
    2.47          """
    2.48 +        def cbok(dominfo):
    2.49 +            self.domain[dominfo.id] = dominfo
    2.50 +            if dominfo.restart_pending():
    2.51 +                self.domain_restart_add(dominfo)
    2.52 +        
    2.53          deferred = XendDomainInfo.vm_recreate(savedinfo, info)
    2.54 -        def fn(dominfo):
    2.55 -            self.domain[dominfo.id] = dominfo
    2.56 -        deferred.addCallback(fn)
    2.57 +        deferred.addCallback(cbok)
    2.58          return deferred
    2.59  
    2.60      def _add_domain(self, id, info, notify=1):
    2.61 @@ -250,9 +246,9 @@ class XendDomain:
    2.62              if id not in self.domain:
    2.63                  savedinfo = None
    2.64                  deferred = XendDomainInfo.vm_recreate(savedinfo, d)
    2.65 -                def fn(dominfo):
    2.66 +                def cbok(dominfo):
    2.67                      self._add_domain(dominfo.id, dominfo)
    2.68 -                deferred.addCallback(fn)
    2.69 +                deferred.addCallback(cbok)
    2.70          # Remove entries for domains that no longer exist.
    2.71          for d in self.domain.values():
    2.72              info = doms.get(d.id)
    2.73 @@ -313,11 +309,11 @@ class XendDomain:
    2.74          @param config: configuration
    2.75          @return: deferred
    2.76          """
    2.77 -        deferred = XendDomainInfo.vm_create(config)
    2.78 -        def fn(dominfo):
    2.79 +        def cbok(dominfo):
    2.80              self._add_domain(dominfo.id, dominfo)
    2.81              return dominfo
    2.82 -        deferred.addCallback(fn)
    2.83 +        deferred = XendDomainInfo.vm_create(config)
    2.84 +        deferred.addCallback(cbok)
    2.85          return deferred
    2.86  
    2.87      def domain_restart(self, dominfo):
    2.88 @@ -326,11 +322,12 @@ class XendDomain:
    2.89          @param dominfo: domain object
    2.90          @return: deferred
    2.91          """
    2.92 -        deferred = dominfo.restart()
    2.93 -        def fn(dominfo):
    2.94 +        def cbok(dominfo):
    2.95              self._add_domain(dominfo.id, dominfo)
    2.96              return dominfo
    2.97 -        deferred.addCallback(fn)
    2.98 +        log.info("Restarting domain: id=%s name=%s", dominfo.id, dominfo.name)
    2.99 +        deferred = dominfo.restart()
   2.100 +        deferred.addCallback(cbok)
   2.101          return deferred        
   2.102  
   2.103      def domain_configure(self, id, config):
   2.104 @@ -348,11 +345,11 @@ class XendDomain:
   2.105              raise XendError("Invalid domain: " + str(id))
   2.106          if dominfo.config:
   2.107              raise XendError("Domain already configured: " + str(id))
   2.108 -        def fn(dominfo):
   2.109 +        def cbok(dominfo):
   2.110              self._add_domain(dominfo.id, dominfo)
   2.111              return dominfo
   2.112          deferred = dominfo.construct(config)
   2.113 -        deferred.addCallback(fn)
   2.114 +        deferred.addCallback(cbok)
   2.115          return deferred
   2.116      
   2.117      def domain_restore(self, src, progress=0):
   2.118 @@ -363,11 +360,11 @@ class XendDomain:
   2.119          @return: deferred
   2.120          """
   2.121          
   2.122 -        def fn(dominfo):
   2.123 +        def cbok(dominfo):
   2.124              self._add_domain(dominfo.id, dominfo)
   2.125              return dominfo
   2.126          deferred = XendDomainInfo.vm_restore(src, progress=progress)
   2.127 -        deferred.addCallback(fn)
   2.128 +        deferred.addCallback(cbok)
   2.129          return deferred
   2.130      
   2.131      def domain_get(self, id):
   2.132 @@ -439,9 +436,12 @@ class XendDomain:
   2.133          restart = (force and reason == 'reboot') or dominfo.restart_needed(reason)
   2.134          if restart:
   2.135              dominfo.restarting()
   2.136 -            self.restarts[id] = dominfo
   2.137 -            log.info('Scheduling restart for domain: id=%s name=%s', id, dominfo.name)
   2.138 -            self.domain_restarts_schedule()
   2.139 +            self.domain_restart_add(dominfo)
   2.140 +
   2.141 +    def domain_restart_add(self, dominfo):
   2.142 +        self.restarts[dominfo.id] = dominfo
   2.143 +        log.info('Scheduling restart for domain: id=%s name=%s', dominfo.id, dominfo.name)
   2.144 +        self.domain_restarts_schedule()
   2.145              
   2.146      def domain_restart_cancel(self, id):
   2.147          """Cancel any restart scheduled for a domain.
   2.148 @@ -450,6 +450,7 @@ class XendDomain:
   2.149          """
   2.150          dominfo = self.restarts.get(id)
   2.151          if dominfo:
   2.152 +            log.info('Cancelling restart for domain: id=%s name=%s', dominfo.id, dominfo.name)
   2.153              dominfo.restart_cancel()
   2.154              del self.restarts[id]
   2.155  
   2.156 @@ -465,18 +466,18 @@ class XendDomain:
   2.157              # Remove it from the restarts.
   2.158              del self.restarts[id]
   2.159              try:
   2.160 -                log.info('domain_restarts> restart: id=%s config=%s', id, str(dominfo.config))
   2.161                  def cbok(dominfo):
   2.162 -                    log.info('Restarted domain %s as %s', id, dominfo.id)
   2.163 +                    log.info('Restarted domain id=%s as %s', id, dominfo.id)
   2.164                      self.domain_unpause(dominfo.id)
   2.165                  def cberr(err):
   2.166 -                    log.exception("Delayed exception restarting domain")
   2.167 +                    log.exception("Delayed exception restarting domain: id=%s", id)
   2.168                  deferred = self.domain_restart(dominfo)
   2.169                  deferred.addCallback(cbok)
   2.170                  deferred.addErrback(cberr)
   2.171              except:
   2.172 -                log.exception("Exception restarting domain")
   2.173 +                log.exception("Exception restarting domain: id=%s", id)
   2.174          if len(self.restarts):
   2.175 +            # Run again later if any restarts remain.
   2.176              self.refresh_schedule(delay=5)
   2.177          
   2.178      def final_domain_destroy(self, id):
   2.179 @@ -487,7 +488,7 @@ class XendDomain:
   2.180          dom = int(id)
   2.181          if dom <= 0:
   2.182              return 0
   2.183 -        log.info('Destroying domain %s', str(id))
   2.184 +        log.info('Destroying domain: id=%s', str(id))
   2.185          eserver.inject('xend.domain.destroy', id)
   2.186          dominfo = self.domain.get(id)
   2.187          if dominfo:
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Jul 26 15:10:26 2004 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Jul 26 15:43:27 2004 +0000
     3.3 @@ -65,6 +65,9 @@ restart_modes = [
     3.4  STATE_RESTART_PENDING = 'pending'
     3.5  STATE_RESTART_BOOTING = 'booting'
     3.6  
     3.7 +STATE_VM_OK         = "ok"
     3.8 +STATE_VM_TERMINATED = "terminated"
     3.9 +
    3.10  def shutdown_reason(code):
    3.11      """Get a shutdown reason from a code.
    3.12  
    3.13 @@ -273,7 +276,11 @@ def vm_recreate(savedinfo, info):
    3.14      vm.memory = info['mem_kb']/1024
    3.15      start_time = sxp.child_value(savedinfo, 'start_time')
    3.16      if start_time is not None:
    3.17 -        vm.startTime = float(start_time)
    3.18 +        vm.start_time = float(start_time)
    3.19 +    vm.restart_state = sxp.child_value(savedinfo, 'restart_state')
    3.20 +    restart_time = sxp.child_value(savedinfo, 'restart_time')
    3.21 +    if restart_time is not None:
    3.22 +        vm.restart_time = float(restart_time)
    3.23      config = sxp.child_value(savedinfo, 'config')
    3.24      if config:
    3.25          d = vm.construct(config)
    3.26 @@ -339,15 +346,16 @@ def _vm_configure2(val, vm):
    3.27  class XendDomainInfo:
    3.28      """Virtual machine object."""
    3.29  
    3.30 -    STATE_OK = "ok"
    3.31 -    STATE_TERMINATED = "terminated"
    3.32 +    """Minimum time between domain restarts in seconds.
    3.33 +    """
    3.34 +    MINIMUM_RESTART_TIME = 10
    3.35  
    3.36      def __init__(self):
    3.37          self.recreate = 0
    3.38          self.config = None
    3.39          self.id = None
    3.40          self.dom = None
    3.41 -        self.startTime = None
    3.42 +        self.start_time = None
    3.43          self.name = None
    3.44          self.memory = None
    3.45          self.image = None
    3.46 @@ -361,11 +369,12 @@ class XendDomainInfo:
    3.47          self.blkif_backend = 0
    3.48          self.netif_backend = 0
    3.49          #todo: state: running, suspended
    3.50 -        self.state = self.STATE_OK
    3.51 +        self.state = STATE_VM_OK
    3.52          #todo: set to migrate info if migrating
    3.53          self.migrate = None
    3.54          self.restart_mode = RESTART_ONREBOOT
    3.55          self.restart_state = None
    3.56 +        self.restart_time = None
    3.57          self.console_port = None
    3.58  
    3.59      def setdom(self, dom):
    3.60 @@ -412,13 +421,17 @@ class XendDomainInfo:
    3.61              sxpr.append(['cpu', self.info['cpu']])
    3.62              sxpr.append(['cpu_time', self.info['cpu_time']/1e9])    
    3.63              
    3.64 -        if self.startTime:
    3.65 -            upTime =  time.time() - self.startTime  
    3.66 -            sxpr.append(['up_time', str(upTime) ])
    3.67 -            sxpr.append(['start_time', str(self.startTime) ])
    3.68 +        if self.start_time:
    3.69 +            up_time =  time.time() - self.start_time  
    3.70 +            sxpr.append(['up_time', str(up_time) ])
    3.71 +            sxpr.append(['start_time', str(self.start_time) ])
    3.72  
    3.73          if self.console:
    3.74              sxpr.append(self.console.sxpr())
    3.75 +        if self.restart_state:
    3.76 +            sxpr.append(['restart_state', self.restart_state])
    3.77 +        if self.restart_time:
    3.78 +            sxpr.append(['restart_time', str(self.restart_time)])
    3.79          if self.config:
    3.80              sxpr.append(['config', self.config])
    3.81          return sxpr
    3.82 @@ -540,8 +553,11 @@ class XendDomainInfo:
    3.83          devices have been released.
    3.84          """
    3.85          if self.dom is None: return 0
    3.86 -        if self.restart_state == STATE_RESTART_PENDING and self.console:
    3.87 -            self.console.deregisterChannel()
    3.88 +        if self.console:
    3.89 +            if self.restart_pending():
    3.90 +                self.console.deregisterChannel()
    3.91 +            else:
    3.92 +                self.console.close()
    3.93          chan = xend.getDomChannel(self.dom)
    3.94          if chan:
    3.95              log.debug("Closing channel to domain %d", self.dom)
    3.96 @@ -551,13 +567,13 @@ class XendDomainInfo:
    3.97      def cleanup(self):
    3.98          """Cleanup vm resources: release devices.
    3.99          """
   3.100 -        self.state = self.STATE_TERMINATED
   3.101 +        self.state = STATE_VM_TERMINATED
   3.102          self.release_devices()
   3.103  
   3.104      def is_terminated(self):
   3.105          """Check if a domain has been terminated.
   3.106          """
   3.107 -        return self.state == self.STATE_TERMINATED
   3.108 +        return self.state == STATE_VM_TERMINATED
   3.109  
   3.110      def release_devices(self):
   3.111          """Release all vm devices.
   3.112 @@ -617,8 +633,8 @@ class XendDomainInfo:
   3.113          log.debug('init_domain> Created domain=%d name=%s memory=%d', dom, name, memory)
   3.114          self.setdom(dom)
   3.115  
   3.116 -        if self.startTime is None:
   3.117 -            self.startTime = time.time()
   3.118 +        if self.start_time is None:
   3.119 +            self.start_time = time.time()
   3.120  
   3.121      def build_domain(self, ostype, kernel, ramdisk, cmdline, vifs_n):
   3.122          """Build the domain boot image.
   3.123 @@ -628,7 +644,6 @@ class XendDomainInfo:
   3.124              log.warning('kernel cmdline too long, domain %d', self.dom)
   3.125          dom = self.dom
   3.126          buildfn = getattr(xc, '%s_build' % ostype)
   3.127 -        #print 'build_domain>', ostype, dom, kernel, cmdline, ramdisk
   3.128          flags = 0
   3.129          if self.netif_backend: flags |= SIF_NET_BE_DOMAIN
   3.130          if self.blkif_backend: flags |= SIF_BLK_BE_DOMAIN
   3.131 @@ -753,8 +768,31 @@ class XendDomainInfo:
   3.132      def restarting(self):
   3.133          self.restart_state = STATE_RESTART_PENDING
   3.134  
   3.135 +    def restart_pending(self):
   3.136 +        return self.restart_state == STATE_RESTART_PENDING
   3.137 +
   3.138 +    def restart_check(self):
   3.139 +        """Check if domain restart is OK.
   3.140 +        To prevent restart loops, raise an error it is
   3.141 +        less than MINIMUM_RESTART_TIME seconds since the last restart.
   3.142 +        """
   3.143 +        tnow = time.time()
   3.144 +        if self.restart_time is not None:
   3.145 +            tdelta = tnow - self.restart_time
   3.146 +            if tdelta < self.MINIMUM_RESTART_TIME:
   3.147 +                msg = 'VM %d restarting too fast' % self.dom
   3.148 +                log.error(msg)
   3.149 +                raise VmError(msg)
   3.150 +        self.restart_time = tnow
   3.151 +
   3.152      def restart(self):
   3.153 +        """Restart the domain after it has exited.
   3.154 +        Reuses the domain id and console port.
   3.155 +
   3.156 +        @return: deferred
   3.157 +        """
   3.158          try:
   3.159 +            self.restart_check()
   3.160              self.restart_state = STATE_RESTART_BOOTING
   3.161              d = self.construct(self.config)
   3.162          finally:
     4.1 --- a/tools/python/xen/xm/create.py	Mon Jul 26 15:10:26 2004 +0000
     4.2 +++ b/tools/python/xen/xm/create.py	Mon Jul 26 15:43:27 2004 +0000
     4.3 @@ -431,11 +431,11 @@ def main(argv):
     4.4              (var, val) = arg.strip().split('=', 1)
     4.5              gopts.setvar(var.strip(), val.strip())
     4.6      if opts.vals.config:
     4.7 -        pass
     4.8 +        config = opts.vals.config
     4.9      else:
    4.10          opts.load_defaults()
    4.11 -    preprocess(opts, opts.vals)
    4.12 -    config = make_config(opts.vals)
    4.13 +        preprocess(opts, opts.vals)
    4.14 +        config = make_config(opts.vals)
    4.15      if opts.vals.dryrun:
    4.16          PrettyPrint.prettyprint(config)
    4.17      else:
     5.1 --- a/tools/python/xen/xm/main.py	Mon Jul 26 15:10:26 2004 +0000
     5.2 +++ b/tools/python/xen/xm/main.py	Mon Jul 26 15:43:27 2004 +0000
     5.3 @@ -469,14 +469,19 @@ class ProgConsoles(Prog):
     5.4  
     5.5      def main(self, args):
     5.6          l = server.xend_consoles()
     5.7 -        print "Dom Port  Id"
     5.8 +        print "Dom Port  Id Connection"
     5.9          for x in l:
    5.10              info = server.xend_console(x)
    5.11              d = {}
    5.12 -            d['dom'] = sxp.child(info, 'dst', ['dst', '?', '?'])[1]
    5.13 -            d['port'] = sxp.child_value(info, 'port', '?')
    5.14 +            d['dom'] = sxp.child(info, 'domain', '?')[1]
    5.15 +            d['port'] = sxp.child_value(info, 'console_port', '?')
    5.16              d['id'] = sxp.child_value(info, 'id', '?')
    5.17 -            print "%(dom)3s %(port)4s %(id)3s" % d
    5.18 +            connected = sxp.child(info, 'connected')
    5.19 +            if connected:
    5.20 +                d['conn'] = '%s:%s' % (connected[1], connected[2])
    5.21 +            else:
    5.22 +                d['conn'] = ''
    5.23 +            print "%(dom)3s %(port)4s %(id)3s %(conn)s" % d
    5.24  
    5.25  xm.prog(ProgConsoles)
    5.26  
    5.27 @@ -496,7 +501,7 @@ class ProgConsole(Prog):
    5.28          console = sxp.child(info, "console")
    5.29          if not console:
    5.30              self.err("No console information")
    5.31 -        port = sxp.child_value(console, "port")
    5.32 +        port = sxp.child_value(console, "console_port")
    5.33          from xen.util import console_client
    5.34          console_client.connect("localhost", int(port))
    5.35  
     6.1 --- a/tools/xfrd/Makefile	Mon Jul 26 15:10:26 2004 +0000
     6.2 +++ b/tools/xfrd/Makefile	Mon Jul 26 15:43:27 2004 +0000
     6.3 @@ -69,7 +69,7 @@ XFRD_LIBS += $(CURL_LIBS)
     6.4  all: xfrd
     6.5  
     6.6  xfrd: $(XFRD_PROG_OBJ)
     6.7 -	$(CC) -shared -o $@ $^ $(XFRD_LIBS)
     6.8 +	$(CC) -o $@ $^ $(XFRD_LIBS)
     6.9  
    6.10  .PHONY: install
    6.11  install: xfrd