ia64/xen-unstable

changeset 6950:3dec22f380be

Added allocateDeviceID, which uses the store to keep track of per-domain,
per-device-class device IDs on behalf of the DevController subclasses.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Sun Sep 18 18:18:52 2005 +0100 (2005-09-18)
parents b67ef34cf91b
children f7a09745ca56
files tools/python/xen/xend/server/DevController.py
line diff
     1.1 --- a/tools/python/xen/xend/server/DevController.py	Sun Sep 18 16:00:24 2005 +0100
     1.2 +++ b/tools/python/xen/xend/server/DevController.py	Sun Sep 18 18:18:52 2005 +0100
     1.3 @@ -117,6 +117,31 @@ class DevController:
     1.4          return self.vm.getDomain()
     1.5  
     1.6  
     1.7 +    def allocateDeviceID(self):
     1.8 +        """Allocate a device ID, allocating them consecutively on a
     1.9 +        per-domain, per-device-class basis, and using the store to record the
    1.10 +        next available ID.
    1.11 +
    1.12 +        This method is available to our subclasses, though it is not
    1.13 +        compulsory to use it; subclasses may prefer to allocate IDs based upon
    1.14 +        the device configuration instead.
    1.15 +        """
    1.16 +        path = self.frontendMiscPath()
    1.17 +        t = xstransact(path)
    1.18 +        try:
    1.19 +            result = t.read("nextDeviceID")
    1.20 +            if result:
    1.21 +                result = int(result)
    1.22 +            else:
    1.23 +                result = 1
    1.24 +            t.write("nextDeviceID", str(result + 1))
    1.25 +            t.commit()
    1.26 +            return result
    1.27 +        except:
    1.28 +            t.abort()
    1.29 +            raise
    1.30 +
    1.31 +
    1.32      ## private:
    1.33  
    1.34      def writeDetails(self, config, devid, backDetails, frontDetails):
    1.35 @@ -170,6 +195,9 @@ class DevController:
    1.36  
    1.37  
    1.38      def frontendPath(self, devid):
    1.39 -        return "%s/device/%s/%d" % (self.vm.getPath(),
    1.40 -                                    self.deviceClass,
    1.41 +        return "%s/device/%s/%d" % (self.vm.getPath(), self.deviceClass,
    1.42                                      devid)
    1.43 +
    1.44 +
    1.45 +    def frontendMiscPath(self):
    1.46 +        return "%s/device-misc/%s" % (self.vm.getPath(), self.deviceClass)