# HG changeset patch
# User emellor@ewan
# Node ID 3dec22f380be168b6308265d6a50619b8d04566d
# Parent b67ef34cf91bf1387c013715e9bb5c033caac715
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@xxxxxxxxxxxxx>
diff -r b67ef34cf91b -r 3dec22f380be
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py Sun Sep 18 15:00:24 2005
+++ b/tools/python/xen/xend/server/DevController.py Sun Sep 18 17:18:52 2005
@@ -117,6 +117,31 @@
return self.vm.getDomain()
+ def allocateDeviceID(self):
+ """Allocate a device ID, allocating them consecutively on a
+ per-domain, per-device-class basis, and using the store to record the
+ next available ID.
+
+ This method is available to our subclasses, though it is not
+ compulsory to use it; subclasses may prefer to allocate IDs based upon
+ the device configuration instead.
+ """
+ path = self.frontendMiscPath()
+ t = xstransact(path)
+ try:
+ result = t.read("nextDeviceID")
+ if result:
+ result = int(result)
+ else:
+ result = 1
+ t.write("nextDeviceID", str(result + 1))
+ t.commit()
+ return result
+ except:
+ t.abort()
+ raise
+
+
## private:
def writeDetails(self, config, devid, backDetails, frontDetails):
@@ -170,6 +195,9 @@
def frontendPath(self, devid):
- return "%s/device/%s/%d" % (self.vm.getPath(),
- self.deviceClass,
+ return "%s/device/%s/%d" % (self.vm.getPath(), self.deviceClass,
devid)
+
+
+ def frontendMiscPath(self):
+ return "%s/device-misc/%s" % (self.vm.getPath(), self.deviceClass)
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|