Skip to contentSkip to conversation

Add set/get_other_config to Xen-API

PATCH New Stefan Berger 1 participant 1 message Oct 10, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add set/get_other_config to Xen-API

Add get_- and set_other_config methods to the vTPM class. Write the parameters into the xenstore while the domain is running prefixing it with 'oc_'.
Also I add the methods to the c-library as well as the documentation.

---
 xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex       |   67 ++++++++++++++++
 xen-unstable.hg/tools/libxen/include/xen/api/xen_vtpm.h |   19 ++++
 xen-unstable.hg/tools/libxen/src/xen_vtpm.c             |   41 +++++++++
 xen-unstable.hg/tools/python/xen/xend/XendAPI.py        |   16 +++
 xen-unstable.hg/tools/python/xen/xend/XendConfig.py     |    1 
 xen-unstable.hg/tools/python/xen/xend/server/tpmif.py   |   14 +++
 6 files changed, 156 insertions(+), 2 deletions(-)
xen-unstable.hg/tools/python/xen/xend/XendAPI.py +15 -1
Index: root/xen-unstable.hg/tools/python/xen/xend/XendAPI.py
===================================================================
@@ -2270,7 +2270,7 @@ class XendAPI(object):
     # Xen API: Class VTPM
     # ----------------------------------------------------------------
 
-    VTPM_attr_rw = [ ]
+    VTPM_attr_rw = ['other_config']
     VTPM_attr_ro = ['VM',
                     'backend',
                     'runtime_properties' ]
@@ -2279,6 +2279,20 @@ class XendAPI(object):
 
     VTPM_methods = [('destroy', None)]
     VTPM_funcs = [('create', 'VTPM')]
+
+    def VTPM_get_other_config(self, session, vtpm_ref):
+        xendom = XendDomain.instance()
+        return xen_api_success(xendom.get_dev_property_by_uuid('vtpm',
+                                                               vtpm_ref,
+                                                               'other_config'))
+
+    def VTPM_set_other_config(self, session, vtpm_ref, other_config):
+        xendom = XendDomain.instance()
+        xendom.set_dev_property_by_uuid('vtpm',
+                                        vtpm_ref,
+                                        'other_config',
+                                        other_config)
+        return xen_api_success_void()
     
     # object methods
     def VTPM_get_record(self, session, vtpm_ref):
xen-unstable.hg/tools/python/xen/xend/XendConfig.py +1 -0
Index: root/xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
@@ -1226,6 +1226,7 @@ class XendConfig(dict):
                 if not dev_uuid:
                     dev_uuid = uuid.createString()
                 dev_info['uuid'] = dev_uuid
+                dev_info['other_config'] = cfg_xenapi.get('other_config', {})
                 target['devices'][dev_uuid] = (dev_type, dev_info)
                 target['vtpm_refs'].append(dev_uuid)
 
xen-unstable.hg/tools/python/xen/xend/server/tpmif.py +14 -0
Index: root/xen-unstable.hg/tools/python/xen/xend/server/tpmif.py
===================================================================
@@ -64,6 +64,13 @@ class TPMifController(DevController):
         if uuid:
             back['uuid'] = uuid
 
+            data = self.vm.info['devices'].get(uuid)
+            if data:
+                other = data[1].get('other_config')
+                if type(other) == dict:
+                    for key, item in other.items():
+                        back['oc_' + key] = item
+
         front = { 'handle' : "%i" % devid }
 
         return (devid, back, front)
@@ -84,6 +91,13 @@ class TPMifController(DevController):
         if type:
             result['type'] = type
 
+        if uuid:
+            data = self.vm.info['devices'].get(uuid)
+            if data:
+                other = data[1].get('other_config')
+                if other:
+                    result['other_config'] = other
+
         return result
 
     def migrate(self, deviceConfig, network, dst, step, domName):
xen-unstable.hg/tools/libxen/src/xen_vtpm.c +40 -1

56 lines not on this page · raw message

xen-unstable.hg/tools/libxen/include/xen/api/xen_vtpm.h +19 -0
Index: root/xen-unstable.hg/tools/libxen/include/xen/api/xen_vtpm.h
===================================================================
@@ -66,6 +66,7 @@ typedef struct xen_vtpm_record
     char *uuid;
     struct xen_vm_record_opt *vm;
     struct xen_vm_record_opt *backend;
+    xen_string_string_map *other_config;
 } xen_vtpm_record;
 
 /**
@@ -196,4 +197,22 @@ extern bool
 xen_vtpm_get_backend(xen_session *session, xen_vm *result, xen_vtpm vtpm);
 
 
+/**
+ * Get the other_config field of the given VTPM.
+ */
+extern bool
+xen_vtpm_get_other_config(xen_session *session,
+                          xen_string_string_map **result,
+                          xen_vtpm vtpm);
+
+
+/**
+ * Set the other_config field of the given VTPM.
+ */
+extern bool
+xen_vtpm_set_other_config(xen_session *session,
+                          xen_vtpm vtpm,
+                          xen_string_string_map *other_config);
+
+
 #endif
xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex +67 -0

79 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel