[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC v2 4/7] libxl: add DeviceFunction classes to IDL



Add a DeviceFunction base class, and Device{Add,Remove,Destroy}Function
classes to idl.py. These classes will allow the device functions to be
generated later in gentypes.py.

The base class, DeviceFunction, extends CtxFunction and adds a domid
parameter to the function's parameter list. When creating a DeviceFunction,
the device parameter must be specified, and extra parameters can be specified
if necessary.

Rather than indicating specific device actions in the DeviceFunction
class, child classes are created for each device function type. Right
now, DeviceAddFunction does not extend the base class. DeviceRemoveFunction
adds the option of specifying 'custom_remove' parameter when custom remove
functions are needed. DeviceDestroyFunction is a child of DeviceRemoveFunction
to inherit the custom_remove attribute.

Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
---
 tools/libs/light/idl.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tools/libs/light/idl.py b/tools/libs/light/idl.py
index a8a4768efc..570b168079 100644
--- a/tools/libs/light/idl.py
+++ b/tools/libs/light/idl.py
@@ -379,6 +379,29 @@ class CtxFunction(Function):
 
         Function.__init__(self, name, params, return_type)
 
+class DeviceFunction(CtxFunction):
+    """ A function that modifies a domain's devices. """
+    def __init__(self, name=None, device_param=None, extra_params=None,
+                 return_type=None):
+        self.device_param = device_param
+
+        params = [ ("domid", uint32), device_param ] + extra_params
+
+        CtxFunction.__init__(self, name, params, return_type)
+
+class DeviceAddFunction(DeviceFunction):
+    pass
+
+class DeviceRemoveFunction(DeviceFunction):
+    def __init__(self, name=None, device_param=None, extra_params=None,
+                 return_type=None, custom_remove=None):
+        self.custom_remove = custom_remove
+
+        DeviceFunction.__init__(self, name, device_param, extra_params, 
return_type)
+
+class DeviceDestroyFunction(DeviceRemoveFunction):
+    pass
+
 def parse(f):
     print("Parsing %s" % f, file=sys.stderr)
 
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.