ia64/xen-unstable

changeset 8192:f23db2051785

Don't log every time around the big transaction writing the device details.
This transaction may be starved for a short while, and logging inside the while
loop won't help!

Use new xstransact.complete to tidy up one other transaction.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Fri Dec 02 15:35:22 2005 +0000 (2005-12-02)
parents 1caed7031f6b
children d581e11e247c
files tools/python/xen/xend/server/DevController.py
line diff
     1.1 --- a/tools/python/xen/xend/server/DevController.py	Fri Dec 02 15:33:38 2005 +0000
     1.2 +++ b/tools/python/xen/xend/server/DevController.py	Fri Dec 02 15:35:22 2005 +0000
     1.3 @@ -22,7 +22,7 @@ from xen.xend import sxp
     1.4  from xen.xend.XendError import VmError
     1.5  from xen.xend.XendLogging import log
     1.6  
     1.7 -from xen.xend.xenstore.xstransact import xstransact
     1.8 +from xen.xend.xenstore.xstransact import xstransact, complete
     1.9  from xen.xend.xenstore.xswatch import xswatch
    1.10  
    1.11  DEVICE_CREATE_TIMEOUT = 10
    1.12 @@ -85,6 +85,8 @@ class DevController:
    1.13          (backpath, frontpath) = self.addStoreEntries(config, devid, back,
    1.14                                                       front)
    1.15  
    1.16 +        import xen.xend.XendDomain
    1.17 +        count = 0
    1.18          while True:
    1.19              t = xstransact()
    1.20              try:
    1.21 @@ -97,16 +99,19 @@ class DevController:
    1.22                      
    1.23                      raise VmError("Device %s is already connected." % dev_str)
    1.24  
    1.25 -                log.debug('DevController: writing %s to %s.', str(front),
    1.26 -                          frontpath)
    1.27 -                log.debug('DevController: writing %s to %s.', str(back),
    1.28 -                          backpath)
    1.29 +                if count == 0:
    1.30 +                    log.debug('DevController: writing %s to %s.', str(front),
    1.31 +                              frontpath)
    1.32 +                    log.debug('DevController: writing %s to %s.', str(back),
    1.33 +                              backpath)
    1.34 +                elif count % 50 == 0:
    1.35 +                    log.debug(
    1.36 +                      'DevController: still waiting to write device entries.')
    1.37  
    1.38                  t.remove(frontpath)
    1.39                  t.remove(backpath)
    1.40  
    1.41                  t.mkdir(backpath)
    1.42 -                import xen.xend.XendDomain
    1.43                  t.set_permissions(backpath,
    1.44                                    {'dom': xen.xend.XendDomain.PRIV_DOMAIN },
    1.45                                    {'dom'  : self.vm.getDomid(),
    1.46 @@ -117,6 +122,8 @@ class DevController:
    1.47  
    1.48                  if t.commit():
    1.49                      return devid
    1.50 +
    1.51 +                count += 1
    1.52              except:
    1.53                  t.abort()
    1.54                  raise
    1.55 @@ -273,20 +280,17 @@ class DevController:
    1.56          the device configuration instead.
    1.57          """
    1.58          path = self.frontendMiscPath()
    1.59 -        while True:
    1.60 -            t = xstransact(path)
    1.61 -            try:
    1.62 -                result = t.read("nextDeviceID")
    1.63 -                if result:
    1.64 -                    result = int(result)
    1.65 -                else:
    1.66 -                    result = 0
    1.67 -                t.write("nextDeviceID", str(result + 1))
    1.68 -                if t.commit():
    1.69 -                    return result
    1.70 -            except:
    1.71 -                t.abort()
    1.72 -                raise
    1.73 +        return complete(path, self._allocateDeviceID)
    1.74 +
    1.75 +
    1.76 +    def _allocateDeviceID(self, t):
    1.77 +        result = t.read("nextDeviceID")
    1.78 +        if result:
    1.79 +            result = int(result)
    1.80 +        else:
    1.81 +            result = 0
    1.82 +        t.write("nextDeviceID", str(result + 1))
    1.83 +        return result
    1.84  
    1.85  
    1.86      def readBackend(self, devid, *args):