aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKeir Fraser <keir@xensource.com>2007-10-11 09:41:16 +0100
committerKeir Fraser <keir@xensource.com>2007-10-11 09:41:16 +0100
commit1a55b4207e077f5dc1a840c921139a41610bc160 (patch)
tree2022afd23a1ae202702562f7b023d37e8fde6dfe /tools
parent09fa4973a1fe64316715d2c7c876eda503af0a3f (diff)
downloadxen-1a55b4207e077f5dc1a840c921139a41610bc160.tar.gz
xen-1a55b4207e077f5dc1a840c921139a41610bc160.tar.bz2
xen-1a55b4207e077f5dc1a840c921139a41610bc160.zip
[vTPM] 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. Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/libxen/include/xen/api/xen_vtpm.h19
-rw-r--r--tools/libxen/src/xen_vtpm.c41
-rw-r--r--tools/python/xen/xend/XendAPI.py16
-rw-r--r--tools/python/xen/xend/XendConfig.py1
-rw-r--r--tools/python/xen/xend/server/tpmif.py14
5 files changed, 89 insertions, 2 deletions
diff --git a/tools/libxen/include/xen/api/xen_vtpm.h b/tools/libxen/include/xen/api/xen_vtpm.h
index 920948d134..9b3b2ebd88 100644
--- a/tools/libxen/include/xen/api/xen_vtpm.h
+++ b/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
diff --git a/tools/libxen/src/xen_vtpm.c b/tools/libxen/src/xen_vtpm.c
index 5ed3692234..0ca7b41965 100644
--- a/tools/libxen/src/xen_vtpm.c
+++ b/tools/libxen/src/xen_vtpm.c
@@ -46,7 +46,10 @@ static const struct_member xen_vtpm_record_struct_members[] =
.offset = offsetof(xen_vtpm_record, vm) },
{ .key = "backend",
.type = &abstract_type_ref,
- .offset = offsetof(xen_vtpm_record, backend) }
+ .offset = offsetof(xen_vtpm_record, backend) },
+ { .key = "other_config",
+ .type = &abstract_type_string_string_map,
+ .offset = offsetof(xen_vtpm_record, other_config) }
};
const abstract_type xen_vtpm_record_abstract_type_ =
@@ -70,6 +73,7 @@ xen_vtpm_record_free(xen_vtpm_record *record)
free(record->uuid);
xen_vm_record_opt_free(record->vm);
xen_vm_record_opt_free(record->backend);
+ xen_string_string_map_free(record->other_config);
free(record);
}
@@ -194,3 +198,38 @@ xen_vtpm_get_uuid(xen_session *session, char **result, xen_vtpm vtpm)
XEN_CALL_("VTPM.get_uuid");
return session->ok;
}
+
+
+bool
+xen_vtpm_get_other_config(xen_session *session, xen_string_string_map **result,
+ xen_vtpm vtpm)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vtpm }
+ };
+
+ abstract_type result_type = abstract_type_string_string_map;
+
+ *result = NULL;
+ XEN_CALL_("VTPM.get_other_config");
+ return session->ok;
+}
+
+
+bool
+xen_vtpm_set_other_config(xen_session *session, xen_vtpm vtpm,
+ xen_string_string_map *other_config)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vtpm },
+ { .type = &abstract_type_string_string_map,
+ .u.set_val = (arbitrary_set *)other_config }
+ };
+
+ xen_call_(session, "VTPM.set_other_config", param_values, 2, NULL, NULL);
+ return session->ok;
+}
diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py
index 00bc9fdec5..9c119edb31 100644
--- a/tools/python/xen/xend/XendAPI.py
+++ b/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):
diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py
index 9e49c4a68e..aacf2c041d 100644
--- a/tools/python/xen/xend/XendConfig.py
+++ b/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)
diff --git a/tools/python/xen/xend/server/tpmif.py b/tools/python/xen/xend/server/tpmif.py
index db4b9f2c68..aee29febef 100644
--- a/tools/python/xen/xend/server/tpmif.py
+++ b/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):