ia64/xen-unstable

changeset 7678:0aeb37de0e4a

merge
author kaf24@firebug.cl.cam.ac.uk
date Tue Nov 08 11:44:48 2005 +0100 (2005-11-08)
parents 66dd96e90be4 055efdd6b7c5
children becf19225569
files
line diff
     1.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Mon Nov 07 20:40:31 2005 -0600
     1.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Tue Nov 08 11:44:48 2005 +0100
     1.3 @@ -209,9 +209,9 @@ def forkHelper(cmd, fd, inputHandler, cl
     1.4          raise XendError("%s failed" % string.join(cmd))
     1.5  
     1.6  
     1.7 -def slurp(file):
     1.8 +def slurp(infile):
     1.9      while 1:
    1.10 -        line = file.readline()
    1.11 +        line = infile.readline()
    1.12          if line == "":
    1.13              break
    1.14          else:
     2.1 --- a/tools/python/xen/xend/XendClient.py	Mon Nov 07 20:40:31 2005 -0600
     2.2 +++ b/tools/python/xen/xend/XendClient.py	Tue Nov 08 11:44:48 2005 +0100
     2.3 @@ -220,6 +220,10 @@ class Xend:
     2.4      def xend_domain(self, id):
     2.5          return self.xendGet(self.domainurl(id))
     2.6  
     2.7 +    def xend_domain_wait_for_devices(self, id):
     2.8 +        return self.xendPost(self.domainurl(id),
     2.9 +                             {'op'      : 'wait_for_devices' })
    2.10 +
    2.11      def xend_domain_unpause(self, id):
    2.12          return self.xendPost(self.domainurl(id),
    2.13                               {'op'      : 'unpause' })
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Nov 07 20:40:31 2005 -0600
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Nov 08 11:44:48 2005 +0100
     3.3 @@ -90,6 +90,8 @@ ZOMBIE_PREFIX = 'Zombie-'
     3.4  """Minimum time between domain restarts in seconds."""
     3.5  MINIMUM_RESTART_TIME = 20
     3.6  
     3.7 +RESTART_IN_PROGRESS = 'xend/restart_in_progress'
     3.8 +
     3.9  
    3.10  xc = xen.lowlevel.xc.new()
    3.11  xroot = XendRoot.instance()
    3.12 @@ -895,6 +897,14 @@ class XendDomainInfo:
    3.13          return self.getDeviceController(deviceClass).createDevice(devconfig)
    3.14  
    3.15  
    3.16 +    def waitForDevices_(self, deviceClass):
    3.17 +        return self.getDeviceController(deviceClass).waitForDevices()
    3.18 +
    3.19 +
    3.20 +    def waitForDevice(self, deviceClass, devid):
    3.21 +        return self.getDeviceController(deviceClass).waitForDevice(devid)
    3.22 +
    3.23 +
    3.24      def reconfigureDevice(self, deviceClass, devid, devconfig):
    3.25          return self.getDeviceController(deviceClass).reconfigureDevice(
    3.26              devid, devconfig)
    3.27 @@ -1230,6 +1240,15 @@ class XendDomainInfo:
    3.28              self.image.createDeviceModel()
    3.29  
    3.30  
    3.31 +    def waitForDevices(self):
    3.32 +        """Wait for this domain's configured devices to connect.
    3.33 +
    3.34 +        @raise: VmError if any device fails to initialise.
    3.35 +        """
    3.36 +        for c in controllerClasses:
    3.37 +            self.waitForDevices_(c)
    3.38 +
    3.39 +
    3.40      def device_create(self, dev_config):
    3.41          """Create a new device.
    3.42  
    3.43 @@ -1237,6 +1256,7 @@ class XendDomainInfo:
    3.44          """
    3.45          dev_type = sxp.name(dev_config)
    3.46          devid = self.createDevice(dev_type, dev_config)
    3.47 +        self.waitForDevice(dev_type, devid)
    3.48  #        self.config.append(['device', dev.getConfig()])
    3.49          return self.getDeviceController(dev_type).sxpr(devid)
    3.50  
    3.51 @@ -1269,14 +1289,14 @@ class XendDomainInfo:
    3.52  
    3.53          config = self.sxpr()
    3.54  
    3.55 -        if self.readVm('xend/restart_in_progress'):
    3.56 +        if self.readVm(RESTART_IN_PROGRESS):
    3.57              log.error('Xend failed during restart of domain %d.  '
    3.58                        'Refusing to restart to avoid loops.',
    3.59                        self.domid)
    3.60              self.destroy()
    3.61              return
    3.62  
    3.63 -        self.writeVm('xend/restart_in_progress', 'True')
    3.64 +        self.writeVm(RESTART_IN_PROGRESS, 'True')
    3.65  
    3.66          now = time.time()
    3.67          rst = self.readVm('xend/previous_restart_time')
    3.68 @@ -1298,26 +1318,28 @@ class XendDomainInfo:
    3.69                  self.preserveForRestart()
    3.70              else:
    3.71                  self.destroyDomain()
    3.72 -                
    3.73 +
    3.74 +            # new_dom's VM will be the same as this domain's VM, except where
    3.75 +            # the rename flag has instructed us to call preserveForRestart.
    3.76 +            # In that case, it is important that we remove the
    3.77 +            # RESTART_IN_PROGRESS node from the new domain, not the old one,
    3.78 +            # once the new one is available.
    3.79 +
    3.80 +            new_dom = None
    3.81              try:
    3.82                  xd = get_component('xen.xend.XendDomain')
    3.83                  new_dom = xd.domain_create(config)
    3.84 -                try:
    3.85 -                    new_dom.unpause()
    3.86 -                except:
    3.87 -                    new_dom.destroy()
    3.88 -                    raise
    3.89 +                new_dom.unpause()
    3.90 +                new_dom.removeVm(RESTART_IN_PROGRESS)
    3.91              except:
    3.92 -                log.exception('Failed to restart domain %d.', self.domid)
    3.93 -        finally:
    3.94 -            # new_dom's VM will be the same as this domain's VM, except where
    3.95 -            # the rename flag has instructed us to call preserveForRestart.
    3.96 -            # In that case, it is important that we use new_dom.removeVm, not
    3.97 -            # self.removeVm.
    3.98 -            new_dom.removeVm('xend/restart_in_progress')
    3.99 -            
   3.100 -        # self.configure_bootloader()
   3.101 -        #        self.exportToDB()
   3.102 +                if new_dom:
   3.103 +                    new_dom.removeVm(RESTART_IN_PROGRESS)
   3.104 +                    new_dom.destroy()
   3.105 +                else:
   3.106 +                    self.removeVm(RESTART_IN_PROGRESS)
   3.107 +                raise
   3.108 +        except:
   3.109 +            log.exception('Failed to restart domain %d.', self.domid)
   3.110  
   3.111  
   3.112      def preserveForRestart(self):
     4.1 --- a/tools/python/xen/xend/server/DevController.py	Mon Nov 07 20:40:31 2005 -0600
     4.2 +++ b/tools/python/xen/xend/server/DevController.py	Tue Nov 08 11:44:48 2005 +0100
     4.3 @@ -62,6 +62,18 @@ class DevController:
     4.4  
     4.5          self.writeDetails(config, devid, back, front)
     4.6  
     4.7 +        return devid
     4.8 +
     4.9 +
    4.10 +    def waitForDevices(self):
    4.11 +        log.debug("Waiting for devices %s.", self.deviceClass)
    4.12 +        
    4.13 +        return map(self.waitForDevice, self.deviceIDs())
    4.14 +
    4.15 +
    4.16 +    def waitForDevice(self, devid):
    4.17 +        log.debug("Waiting for %s.", devid)
    4.18 +        
    4.19          status, fn_ret = self.waitForBackend(devid)
    4.20          if status:
    4.21              self.destroyDevice(devid)
    4.22 @@ -74,7 +86,6 @@ class DevController:
    4.23              raise VmError( ("Device %s (%s) could not be connected. "
    4.24                              "Backend device not found!") 
    4.25                              % (devid, self.deviceClass))
    4.26 -        return devid
    4.27  
    4.28  
    4.29      def reconfigureDevice(self, devid, config):
    4.30 @@ -122,10 +133,11 @@ class DevController:
    4.31          specified device.  This would be suitable for giving to {@link
    4.32          #createDevice} in order to recreate that device."""
    4.33  
    4.34 -        backdomid = int(xstransact.Read(self.frontendPath(devid),
    4.35 -                                        "backend-id"))
    4.36 -
    4.37 -        return [self.deviceClass, ['backend', backdomid]]
    4.38 +        backdomid = xstransact.Read(self.frontendPath(devid), "backend-id")
    4.39 +        if backdomid is None:
    4.40 +            raise VmError("Device %s not connected" % devid)
    4.41 +        
    4.42 +        return [self.deviceClass, ['backend', int(backdomid)]]
    4.43  
    4.44  
    4.45      def sxprs(self):
    4.46 @@ -200,7 +212,10 @@ class DevController:
    4.47      def readBackend(self, devid, *args):
    4.48          frontpath = self.frontendPath(devid)
    4.49          backpath = xstransact.Read(frontpath, "backend")
    4.50 -        return xstransact.Read(backpath, *args)
    4.51 +        if backpath:
    4.52 +            return xstransact.Read(backpath, *args)
    4.53 +        else:
    4.54 +            raise VmError("Device %s not connected" % devid)
    4.55  
    4.56  
    4.57      def deviceIDs(self):
    4.58 @@ -242,6 +257,8 @@ class DevController:
    4.59          frontpath = self.frontendPath(devid)
    4.60          backpath  = self.backendPath(backdom, devid)
    4.61          
    4.62 +        xstransact.Remove(backpath, HOTPLUG_STATUS_NODE)
    4.63 +
    4.64          frontDetails.update({
    4.65              'backend' : backpath,
    4.66              'backend-id' : "%i" % backdom.getDomid()
    4.67 @@ -266,7 +283,10 @@ class DevController:
    4.68          ev = Event()
    4.69  
    4.70          def hotplugStatus():
    4.71 -            status = self.readBackend(devid, HOTPLUG_STATUS_NODE)
    4.72 +            try:
    4.73 +                status = self.readBackend(devid, HOTPLUG_STATUS_NODE)
    4.74 +            except VmError:
    4.75 +                status = "died"
    4.76              if status is not None:
    4.77                  watch.xs.unwatch(backpath, watch)
    4.78                  hotplugStatus.value = status
    4.79 @@ -276,14 +296,16 @@ class DevController:
    4.80          frontpath = self.frontendPath(devid)
    4.81          backpath = xstransact.Read(frontpath, "backend")
    4.82  
    4.83 -        watch = xswatch(backpath, hotplugStatus)
    4.84 +        if backpath:
    4.85 +            watch = xswatch(backpath, hotplugStatus)
    4.86  
    4.87 -        ev.wait(DEVICE_CREATE_TIMEOUT)
    4.88 -        if ev.isSet():
    4.89 -            return (0, hotplugStatus.value)
    4.90 +            ev.wait(DEVICE_CREATE_TIMEOUT)
    4.91 +            if ev.isSet():
    4.92 +                return (0, hotplugStatus.value)
    4.93 +            else:
    4.94 +                return (-1, hotplugStatus.value)
    4.95          else:
    4.96 -            return (-1, hotplugStatus.value)
    4.97 -
    4.98 +            return (-1, "missing")
    4.99  
   4.100  
   4.101      def backendPath(self, backdom, devid):
     5.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Mon Nov 07 20:40:31 2005 -0600
     5.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Tue Nov 08 11:44:48 2005 +0100
     5.3 @@ -13,13 +13,13 @@
     5.4  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     5.5  #============================================================================
     5.6  # Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
     5.7 +# Copyright (C) 2005 Xensource Ltd
     5.8  #============================================================================
     5.9  
    5.10  from xen.web import http
    5.11  
    5.12  from xen.xend import sxp
    5.13  from xen.xend import XendDomain
    5.14 -from xen.xend import PrettyPrint
    5.15  from xen.xend.Args import FormFn
    5.16  
    5.17  from xen.web.SrvDir import SrvDir
    5.18 @@ -33,7 +33,7 @@ class SrvDomain(SrvDir):
    5.19          self.dom = dom
    5.20          self.xd = XendDomain.instance()
    5.21  
    5.22 -    def op_configure(self, op, req):
    5.23 +    def op_configure(self, _, req):
    5.24          """Configure an existing domain.
    5.25          Configure is unusual in that it requires a domain id,
    5.26          not a domain name.
    5.27 @@ -43,11 +43,11 @@ class SrvDomain(SrvDir):
    5.28                       ['config', 'sxpr']])
    5.29          return fn(req.args, {'dom': self.dom.domid})
    5.30  
    5.31 -    def op_unpause(self, op, req):
    5.32 +    def op_unpause(self, _1, _2):
    5.33          val = self.xd.domain_unpause(self.dom.domid)
    5.34          return val
    5.35          
    5.36 -    def op_pause(self, op, req):
    5.37 +    def op_pause(self, _1, _2):
    5.38          val = self.xd.domain_pause(self.dom.domid)
    5.39          return val
    5.40  
    5.41 @@ -55,15 +55,19 @@ class SrvDomain(SrvDir):
    5.42          req.setResponseCode(http.ACCEPTED)
    5.43          req.setHeader("Location", "%s/.." % req.prePathURL())
    5.44  
    5.45 -    def op_shutdown(self, op, req):
    5.46 +    def op_shutdown(self, _, req):
    5.47          self.acceptCommand(req)
    5.48          return self.dom.shutdown(req.args['reason'][0])
    5.49  
    5.50 -    def op_sysrq(self, op, req):
    5.51 +    def op_sysrq(self, _, req):
    5.52          self.acceptCommand(req)
    5.53          return self.dom.send_sysrq(int(req.args['key'][0]))
    5.54  
    5.55 -    def op_destroy(self, op, req):
    5.56 +    def op_wait_for_devices(self, _, req):
    5.57 +        self.acceptCommand(req)
    5.58 +        return self.dom.waitForDevices()
    5.59 +
    5.60 +    def op_destroy(self, _, req):
    5.61          self.acceptCommand(req)
    5.62          return self.xd.domain_destroy(self.dom.domid)
    5.63  
    5.64 @@ -71,13 +75,13 @@ class SrvDomain(SrvDir):
    5.65          self.acceptCommand(req)
    5.66          return req.threadRequest(self.do_save, op, req)
    5.67  
    5.68 -    def do_save(self, op, req):
    5.69 +    def do_save(self, _, req):
    5.70          return self.xd.domain_save(self.dom.domid, req.args['file'][0])
    5.71  
    5.72      def op_migrate(self, op, req):
    5.73          return req.threadRequest(self.do_migrate, op, req)
    5.74      
    5.75 -    def do_migrate(self, op, req):
    5.76 +    def do_migrate(self, _, req):
    5.77          fn = FormFn(self.xd.domain_migrate,
    5.78                      [['dom',         'int'],
    5.79                       ['destination', 'str'],
    5.80 @@ -85,7 +89,7 @@ class SrvDomain(SrvDir):
    5.81                       ['resource',    'int']])
    5.82          return fn(req.args, {'dom': self.dom.domid})
    5.83  
    5.84 -    def op_pincpu(self, op, req):
    5.85 +    def op_pincpu(self, _, req):
    5.86          fn = FormFn(self.xd.domain_pincpu,
    5.87                      [['dom', 'int'],
    5.88                       ['vcpu', 'int'],
    5.89 @@ -93,7 +97,7 @@ class SrvDomain(SrvDir):
    5.90          val = fn(req.args, {'dom': self.dom.domid})
    5.91          return val
    5.92  
    5.93 -    def op_cpu_bvt_set(self, op, req):
    5.94 +    def op_cpu_bvt_set(self, _, req):
    5.95          fn = FormFn(self.xd.domain_cpu_bvt_set,
    5.96                      [['dom',       'int'],
    5.97                       ['mcuadv',    'int'],
    5.98 @@ -105,14 +109,14 @@ class SrvDomain(SrvDir):
    5.99          return val
   5.100      
   5.101      
   5.102 -    def op_cpu_sedf_get(self, op, req):
   5.103 +    def op_cpu_sedf_get(self, _, req):
   5.104          fn = FormFn(self.xd.domain_cpu_sedf_get,
   5.105                      [['dom', 'int']])
   5.106          val = fn(req.args, {'dom': self.dom.domid})
   5.107          return val
   5.108  
   5.109  
   5.110 -    def op_cpu_sedf_set(self, op, req):
   5.111 +    def op_cpu_sedf_set(self, _, req):
   5.112          fn = FormFn(self.xd.domain_cpu_sedf_set,
   5.113                      [['dom', 'int'],
   5.114                       ['period', 'int'],
   5.115 @@ -123,7 +127,7 @@ class SrvDomain(SrvDir):
   5.116          val = fn(req.args, {'dom': self.dom.domid})
   5.117          return val
   5.118  
   5.119 -    def op_maxmem_set(self, op, req):
   5.120 +    def op_maxmem_set(self, _, req):
   5.121          fn = FormFn(self.xd.domain_maxmem_set,
   5.122                      [['dom',    'int'],
   5.123                       ['memory', 'int']])
   5.124 @@ -135,35 +139,35 @@ class SrvDomain(SrvDir):
   5.125          return FormFn(fn, args)(req.args)
   5.126  
   5.127  
   5.128 -    def op_mem_target_set(self, op, req):
   5.129 +    def op_mem_target_set(self, _, req):
   5.130          return self.call(self.dom.setMemoryTarget,
   5.131                           [['target', 'int']],
   5.132                           req)
   5.133  
   5.134 -    def op_devices(self, op, req):
   5.135 +    def op_devices(self, _, req):
   5.136          return self.call(self.dom.getDeviceSxprs,
   5.137                           [['type', 'str']],
   5.138                           req)
   5.139  
   5.140 -    def op_device_create(self, op, req):
   5.141 +    def op_device_create(self, _, req):
   5.142          return self.call(self.dom.device_create,
   5.143                           [['config', 'sxpr']],
   5.144                           req)
   5.145  
   5.146 -    def op_device_destroy(self, op, req):
   5.147 +    def op_device_destroy(self, _, req):
   5.148          return self.call(self.dom.destroyDevice,
   5.149                           [['type', 'str'],
   5.150                            ['dev',  'str']],
   5.151                           req)
   5.152                  
   5.153 -    def op_device_configure(self, op, req):
   5.154 +    def op_device_configure(self, _, req):
   5.155          return self.call(self.dom.device_configure,
   5.156                           [['config', 'sxpr'],
   5.157                            ['dev',    'str']],
   5.158                           req)
   5.159  
   5.160  
   5.161 -    def op_vif_limit_set(self, op, req):
   5.162 +    def op_vif_limit_set(self, _, req):
   5.163          fn = FormFn(self.xd.domain_vif_limit_set,
   5.164                      [['dom',    'int'],
   5.165                       ['vif',    'int'],
   5.166 @@ -172,7 +176,7 @@ class SrvDomain(SrvDir):
   5.167          val = fn(req.args, {'dom': self.dom.domid})
   5.168          return val
   5.169  
   5.170 -    def op_set_vcpus(self, op, req):
   5.171 +    def op_set_vcpus(self, _, req):
   5.172          return self.call(self.dom.setVCpuCount,
   5.173                           [['vcpus', 'int']],
   5.174                           req)
     6.1 --- a/tools/python/xen/xend/server/params.py	Mon Nov 07 20:40:31 2005 -0600
     6.2 +++ b/tools/python/xen/xend/server/params.py	Tue Nov 08 11:44:48 2005 +0100
     6.3 @@ -44,8 +44,3 @@ XEND_DEBUG_LOG     = '/var/log/xend-debu
     6.4  XEND_USER          = 'root'
     6.5  XEND_DEBUG         = getenv("XEND_DEBUG",     0, conv=int)
     6.6  XEND_DAEMONIZE     = getenv("XEND_DAEMONIZE", not XEND_DEBUG, conv=int)
     6.7 -
     6.8 -XENSTORED_PID_FILE = '/var/run/xenstored.pid'
     6.9 -XENSTORED_RUN_DIR  = '/var/run/xenstored'
    6.10 -XENSTORED_LIB_DIR  = '/var/lib/xenstored'
    6.11 -XENSTORED_DEBUG    = getenv("XENSTORED_DEBUG", 0, conv=int)
     7.1 --- a/tools/python/xen/xm/create.py	Mon Nov 07 20:40:31 2005 -0600
     7.2 +++ b/tools/python/xen/xm/create.py	Tue Nov 08 11:44:48 2005 +0100
     7.3 @@ -815,6 +815,10 @@ def make_domain(opts, config):
     7.4  
     7.5      dom = sxp.child_value(dominfo, 'name')
     7.6  
     7.7 +    if server.xend_domain_wait_for_devices(dom) < 0:
     7.8 +        server.xend_domain_destroy(dom)
     7.9 +        err("Device creation failed for domain %s" % dom)
    7.10 +
    7.11      if not opts.vals.paused:
    7.12          if server.xend_domain_unpause(dom) < 0:
    7.13              server.xend_domain_destroy(dom)