ia64/xen-unstable

changeset 16088:51f521303df7

[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>
author Keir Fraser <keir@xensource.com>
date Thu Oct 11 09:41:16 2007 +0100 (2007-10-11)
parents 960a05895a4a
children ab5b615867ee
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen/api/xen_vtpm.h tools/libxen/src/xen_vtpm.c tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendConfig.py tools/python/xen/xend/server/tpmif.py
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Thu Oct 11 08:14:11 2007 +0100
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Thu Oct 11 09:41:16 2007 +0100
     1.3 @@ -13563,6 +13563,7 @@ Quals & Field & Type & Description \\
     1.4  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
     1.5  $\mathit{RO}_\mathit{ins}$ &  {\tt VM} & VM ref & the virtual machine \\
     1.6  $\mathit{RO}_\mathit{ins}$ &  {\tt backend} & VM ref & the domain where the backend is located \\
     1.7 +$\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
     1.8  \hline
     1.9  \end{longtable}
    1.10  \subsection{RPCs associated with class: VTPM}
    1.11 @@ -13662,6 +13663,72 @@ value of the field
    1.12  \vspace{0.3cm}
    1.13  \vspace{0.3cm}
    1.14  \vspace{0.3cm}
    1.15 +\subsubsection{RPC name:~get\_other\_config}
    1.16 +
    1.17 +{\bf Overview:}
    1.18 +Get the other\_config field of the given VTPM.
    1.19 +
    1.20 + \noindent {\bf Signature:}
    1.21 +\begin{verbatim} ((string -> string) Map) get_other_config (session_id s, VTPM ref self)\end{verbatim}
    1.22 +
    1.23 +
    1.24 +\noindent{\bf Arguments:}
    1.25 +
    1.26 +
    1.27 +\vspace{0.3cm}
    1.28 +\begin{tabular}{|c|c|p{7cm}|}
    1.29 + \hline
    1.30 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.31 +{\tt VTPM ref } & self & reference to the object \\ \hline
    1.32 +
    1.33 +\end{tabular}
    1.34 +
    1.35 +\vspace{0.3cm}
    1.36 +
    1.37 + \noindent {\bf Return Type:}
    1.38 +{\tt
    1.39 +(string $\rightarrow$ string) Map
    1.40 +}
    1.41 +
    1.42 +
    1.43 +value of the field
    1.44 +\vspace{0.3cm}
    1.45 +\vspace{0.3cm}
    1.46 +\vspace{0.3cm}
    1.47 +\subsubsection{RPC name:~set\_other\_config}
    1.48 +
    1.49 +{\bf Overview:}
    1.50 +Set the other\_config field of the given VTPM.
    1.51 +
    1.52 + \noindent {\bf Signature:}
    1.53 +\begin{verbatim} void set_other_config (session_id s, VTPM ref self, (string -> string) Map value)\end{verbatim}
    1.54 +
    1.55 +
    1.56 +\noindent{\bf Arguments:}
    1.57 +
    1.58 +
    1.59 +\vspace{0.3cm}
    1.60 +\begin{tabular}{|c|c|p{7cm}|}
    1.61 + \hline
    1.62 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.63 +{\tt VTPM ref } & self & reference to the object \\ \hline
    1.64 +
    1.65 +{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline
    1.66 +
    1.67 +\end{tabular}
    1.68 +
    1.69 +\vspace{0.3cm}
    1.70 +
    1.71 + \noindent {\bf Return Type:}
    1.72 +{\tt
    1.73 +void
    1.74 +}
    1.75 +
    1.76 +
    1.77 +
    1.78 +\vspace{0.3cm}
    1.79 +\vspace{0.3cm}
    1.80 +\vspace{0.3cm}
    1.81  \subsubsection{RPC name:~get\_runtime\_properties}
    1.82  
    1.83  {\bf Overview:}
     2.1 --- a/tools/libxen/include/xen/api/xen_vtpm.h	Thu Oct 11 08:14:11 2007 +0100
     2.2 +++ b/tools/libxen/include/xen/api/xen_vtpm.h	Thu Oct 11 09:41:16 2007 +0100
     2.3 @@ -66,6 +66,7 @@ typedef struct xen_vtpm_record
     2.4      char *uuid;
     2.5      struct xen_vm_record_opt *vm;
     2.6      struct xen_vm_record_opt *backend;
     2.7 +    xen_string_string_map *other_config;
     2.8  } xen_vtpm_record;
     2.9  
    2.10  /**
    2.11 @@ -196,4 +197,22 @@ extern bool
    2.12  xen_vtpm_get_backend(xen_session *session, xen_vm *result, xen_vtpm vtpm);
    2.13  
    2.14  
    2.15 +/**
    2.16 + * Get the other_config field of the given VTPM.
    2.17 + */
    2.18 +extern bool
    2.19 +xen_vtpm_get_other_config(xen_session *session,
    2.20 +                          xen_string_string_map **result,
    2.21 +                          xen_vtpm vtpm);
    2.22 +
    2.23 +
    2.24 +/**
    2.25 + * Set the other_config field of the given VTPM.
    2.26 + */
    2.27 +extern bool
    2.28 +xen_vtpm_set_other_config(xen_session *session,
    2.29 +                          xen_vtpm vtpm,
    2.30 +                          xen_string_string_map *other_config);
    2.31 +
    2.32 +
    2.33  #endif
     3.1 --- a/tools/libxen/src/xen_vtpm.c	Thu Oct 11 08:14:11 2007 +0100
     3.2 +++ b/tools/libxen/src/xen_vtpm.c	Thu Oct 11 09:41:16 2007 +0100
     3.3 @@ -46,7 +46,10 @@ static const struct_member xen_vtpm_reco
     3.4            .offset = offsetof(xen_vtpm_record, vm) },
     3.5          { .key = "backend",
     3.6            .type = &abstract_type_ref,
     3.7 -          .offset = offsetof(xen_vtpm_record, backend) }
     3.8 +          .offset = offsetof(xen_vtpm_record, backend) },
     3.9 +        { .key = "other_config",
    3.10 +          .type = &abstract_type_string_string_map,
    3.11 +          .offset = offsetof(xen_vtpm_record, other_config) }
    3.12      };
    3.13  
    3.14  const abstract_type xen_vtpm_record_abstract_type_ =
    3.15 @@ -70,6 +73,7 @@ xen_vtpm_record_free(xen_vtpm_record *re
    3.16      free(record->uuid);
    3.17      xen_vm_record_opt_free(record->vm);
    3.18      xen_vm_record_opt_free(record->backend);
    3.19 +    xen_string_string_map_free(record->other_config);
    3.20      free(record);
    3.21  }
    3.22  
    3.23 @@ -194,3 +198,38 @@ xen_vtpm_get_uuid(xen_session *session, 
    3.24      XEN_CALL_("VTPM.get_uuid");
    3.25      return session->ok;
    3.26  }
    3.27 +
    3.28 +
    3.29 +bool
    3.30 +xen_vtpm_get_other_config(xen_session *session, xen_string_string_map **result,
    3.31 +                          xen_vtpm vtpm)
    3.32 +{
    3.33 +    abstract_value param_values[] =
    3.34 +        {
    3.35 +            { .type = &abstract_type_string,
    3.36 +              .u.string_val = vtpm }
    3.37 +        };
    3.38 +
    3.39 +    abstract_type result_type = abstract_type_string_string_map;
    3.40 +
    3.41 +    *result = NULL;
    3.42 +    XEN_CALL_("VTPM.get_other_config");
    3.43 +    return session->ok;
    3.44 +}
    3.45 +
    3.46 +
    3.47 +bool
    3.48 +xen_vtpm_set_other_config(xen_session *session, xen_vtpm vtpm,
    3.49 +                          xen_string_string_map *other_config)
    3.50 +{
    3.51 +    abstract_value param_values[] =
    3.52 +        {
    3.53 +            { .type = &abstract_type_string,
    3.54 +              .u.string_val = vtpm },
    3.55 +            { .type = &abstract_type_string_string_map,
    3.56 +              .u.set_val = (arbitrary_set *)other_config }
    3.57 +        };
    3.58 +
    3.59 +    xen_call_(session, "VTPM.set_other_config", param_values, 2, NULL, NULL);
    3.60 +    return session->ok;
    3.61 +}
     4.1 --- a/tools/python/xen/xend/XendAPI.py	Thu Oct 11 08:14:11 2007 +0100
     4.2 +++ b/tools/python/xen/xend/XendAPI.py	Thu Oct 11 09:41:16 2007 +0100
     4.3 @@ -2270,7 +2270,7 @@ class XendAPI(object):
     4.4      # Xen API: Class VTPM
     4.5      # ----------------------------------------------------------------
     4.6  
     4.7 -    VTPM_attr_rw = [ ]
     4.8 +    VTPM_attr_rw = ['other_config']
     4.9      VTPM_attr_ro = ['VM',
    4.10                      'backend',
    4.11                      'runtime_properties' ]
    4.12 @@ -2279,6 +2279,20 @@ class XendAPI(object):
    4.13  
    4.14      VTPM_methods = [('destroy', None)]
    4.15      VTPM_funcs = [('create', 'VTPM')]
    4.16 +
    4.17 +    def VTPM_get_other_config(self, session, vtpm_ref):
    4.18 +        xendom = XendDomain.instance()
    4.19 +        return xen_api_success(xendom.get_dev_property_by_uuid('vtpm',
    4.20 +                                                               vtpm_ref,
    4.21 +                                                               'other_config'))
    4.22 +
    4.23 +    def VTPM_set_other_config(self, session, vtpm_ref, other_config):
    4.24 +        xendom = XendDomain.instance()
    4.25 +        xendom.set_dev_property_by_uuid('vtpm',
    4.26 +                                        vtpm_ref,
    4.27 +                                        'other_config',
    4.28 +                                        other_config)
    4.29 +        return xen_api_success_void()
    4.30      
    4.31      # object methods
    4.32      def VTPM_get_record(self, session, vtpm_ref):
     5.1 --- a/tools/python/xen/xend/XendConfig.py	Thu Oct 11 08:14:11 2007 +0100
     5.2 +++ b/tools/python/xen/xend/XendConfig.py	Thu Oct 11 09:41:16 2007 +0100
     5.3 @@ -1226,6 +1226,7 @@ class XendConfig(dict):
     5.4                  if not dev_uuid:
     5.5                      dev_uuid = uuid.createString()
     5.6                  dev_info['uuid'] = dev_uuid
     5.7 +                dev_info['other_config'] = cfg_xenapi.get('other_config', {})
     5.8                  target['devices'][dev_uuid] = (dev_type, dev_info)
     5.9                  target['vtpm_refs'].append(dev_uuid)
    5.10  
     6.1 --- a/tools/python/xen/xend/server/tpmif.py	Thu Oct 11 08:14:11 2007 +0100
     6.2 +++ b/tools/python/xen/xend/server/tpmif.py	Thu Oct 11 09:41:16 2007 +0100
     6.3 @@ -64,6 +64,13 @@ class TPMifController(DevController):
     6.4          if uuid:
     6.5              back['uuid'] = uuid
     6.6  
     6.7 +            data = self.vm.info['devices'].get(uuid)
     6.8 +            if data:
     6.9 +                other = data[1].get('other_config')
    6.10 +                if type(other) == dict:
    6.11 +                    for key, item in other.items():
    6.12 +                        back['oc_' + key] = item
    6.13 +
    6.14          front = { 'handle' : "%i" % devid }
    6.15  
    6.16          return (devid, back, front)
    6.17 @@ -84,6 +91,13 @@ class TPMifController(DevController):
    6.18          if type:
    6.19              result['type'] = type
    6.20  
    6.21 +        if uuid:
    6.22 +            data = self.vm.info['devices'].get(uuid)
    6.23 +            if data:
    6.24 +                other = data[1].get('other_config')
    6.25 +                if other:
    6.26 +                    result['other_config'] = other
    6.27 +
    6.28          return result
    6.29  
    6.30      def migrate(self, deviceConfig, network, dst, step, domName):