alignment of vtpm support in xenapi, documentation and libxen
PATCH 1/1 alignment of vtpm support in xenapi, documentation and libxen
This patch aligns vTPM support in the Xen-API, documentation and lib-xen (after the recent changes).
xen-unstable.hg/tools/python/xen/xend/XendAPI.py +20 -30
@@ -1675,8 +1675,7 @@ class XendAPI(object): VTPM_attr_rw = [ ] VTPM_attr_ro = ['VM', - 'backend', - 'instance'] + 'backend'] VTPM_attr_inst = VTPM_attr_rw
@@ -1693,27 +1692,14 @@ class XendAPI(object): return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref]) valid_vtpm_keys = self.VTPM_attr_ro + self.VTPM_attr_rw + \ self.Base_attr_ro + self.Base_attr_rw + return_cfg = {} for k in cfg.keys(): - if k not in valid_vtpm_keys: - del cfg[k] + if k in valid_vtpm_keys: + return_cfg[k] = cfg[k] - return xen_api_success(cfg) + return xen_api_success(return_cfg) # Class Functions - def VTPM_get_instance(self, session, vtpm_ref): - xendom = XendDomain.instance() - vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) - if not vm: - return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref]) - cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref) - if not cfg: - return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref]) - if cfg.has_key('instance'): - instance = cfg['instance'] - else: - instance = -1 - return xen_api_success(instance) - def VTPM_get_backend(self, session, vtpm_ref): xendom = XendDomain.instance() vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
@@ -1722,11 +1708,9 @@ class XendAPI(object): cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref) if not cfg: return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref]) - if cfg.has_key('backend'): - backend = cfg['backend'] - else: - backend = "Domain-0" - return xen_api_success(backend) + if not cfg.has_key('backend'): + return xen_api_error(['VTPM backend not set']) + return xen_api_success(cfg['backend']) def VTPM_get_VM(self, session, vtpm_ref): xendom = XendDomain.instance()
@@ -1735,12 +1719,18 @@ class XendAPI(object): def VTPM_destroy(self, session, vtpm_ref): xendom = XendDomain.instance() - vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) - if not vm: - return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref]) - - vm.destroy_vtpm(vtpm_ref) - return xen_api_success_void() + dom = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) + if dom: + if dom.state != XEN_API_VM_POWER_STATE_HALTED: + vm_ref = dom.get_dev_property('vtpm', vtpm_ref, 'VM') + return xen_api_error(['VM_BAD_POWER_STATE', vm_ref, + XendDomain.POWER_STATE_NAMES[XEN_API_VM_POWER_STATE_HALTED], + XendDomain.POWER_STATE_NAMES[dom.state]]) + from xen.xend.server import tpmif + tpmif.destroy_vtpmstate(dom.getName()) + return xen_api_success(True) + else: + return xen_api_error(['VM_HANDLE_INVALID', vtpm_struct['VM']]) # class methods def VTPM_create(self, session, vtpm_struct):
xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py +4 -1
@@ -2125,7 +2125,10 @@ class XendDomainInfo: config['mode'] = 'RW' if dev_class == 'vtpm': - config['driver'] = 'paravirtualised' # TODO + if not config.has_type('type'): + config['type'] = 'paravirtualised' # TODO + if not config.has_key('backend'): + config['backend'] = "00000000-0000-0000-0000-000000000000" return config
xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py +104 -17
170 lines not on this page · raw message
xen-unstable.hg/tools/python/scripts/xapi.py +0 -8
@@ -678,14 +678,6 @@ def xapi_vtpm_create(args, async = False print "Creating vTPM with cfg = %s" % cfg vtpm_uuid = execute(server, 'VTPM.create', (session, cfg)) print "Done. (%s)" % vtpm_uuid - vtpm_id = execute(server, 'VTPM.get_instance', (session, vtpm_uuid)) - print "Has instance number '%s'" % vtpm_id - vtpm_be = execute(server, 'VTPM.get_backend', (session, vtpm_uuid)) - print "Has backend in '%s'" % vtpm_be - driver = execute(server, 'VTPM.get_driver', (session, vtpm_uuid)) - print "Has driver type '%s'" % driver - vtpm_rec = execute(server, 'VTPM.get_record', (session, vtpm_uuid)) - print "Has vtpm record '%s'" % vtpm_rec def xapi_pif_list(args, async = False):
xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex +0 -32
@@ -9231,38 +9231,6 @@ value of the field \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} -\subsubsection{RPC name:~get\_instance} - -{\bf Overview:} -Get the instance field of the given VTPM. - - \noindent {\bf Signature:} -\begin{verbatim} int get_instance (session_id s, VTPM ref self)\end{verbatim} - - -\noindent{\bf Arguments:} - - -\vspace{0.3cm} -\begin{tabular}{|c|c|p{7cm}|} - \hline -{\bf type} & {\bf name} & {\bf description} \\ \hline -{\tt VTPM ref } & self & reference to the object \\ \hline - -\end{tabular} - -\vspace{0.3cm} - - \noindent {\bf Return Type:} -{\tt -int -} - - -value of the field -\vspace{0.3cm} -\vspace{0.3cm} -\vspace{0.3cm} \subsubsection{RPC name:~create} {\bf Overview:}
xen-unstable.hg/tools/libxen/include/xen_vtpm.h +0 -8
@@ -196,12 +196,4 @@ xen_vtpm_get_vm(xen_session *session, xeextern bool xen_vtpm_get_backend (xen_session *session,xen_vm *result,xen_vtpm vtpm); - -/** -* Get the instance field of the given VTPM. -*/ -extern bool -xen_vtpm_get_instance (xen_session *session,int64_t *result,xen_vtpm vtpm); - -#endif
xen-unstable.hg/tools/libxen/src/xen_vtpm.c +0 -19
@@ -47,9 +47,6 @@ static const struct_member xen_vtpm_reco { .key = "backend", .type = &abstract_type_ref, .offset = offsetof(xen_vtpm_record, backend) }, - { .key = "instance", - .type = &abstract_type_int, - .offset = offsetof(xen_vtpm_record, instance) } }; const abstract_type xen_vtpm_record_abstract_type_ =
@@ -183,22 +180,6 @@ xen_vtpm_get_backend(xen_session *sessiobool -xen_vtpm_get_instance (xen_session *session,int64_t *result,xen_vtpm vtpm) -{ -abstract_value param_values[] = - { - { .type = &abstract_type_string, - .u.string_val = vtpm } - }; - -abstract_type result_type = abstract_type_int; - -XEN_CALL_ ("VTPM.get_instance" ); -return session->ok; -} - - -bool xen_vtpm_get_uuid (xen_session *session,char **result,xen_vtpm vtpm) { *result = session->ok ?xen_strdup_ ((char *)vtpm) :NULL ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines · Stefan Berger
This patch aligns vTPM support in the Xen-API, documentation and lib-xen (after the recent changes).
Signed-off-by Stefan Berger <[email protected]>
What's the intention here? You've removed the get_instance calls, but not the instance field from the documentation. Assuming that that's just a mistake, and you meant to remove the instance field, we're left with a VTPM class that has nothing other than a reference to a VM and a reference to a backend domain. What are the semantics of that object now?
Ewan.
Ewan Mellor <[email protected]> wrote on 01/30/2007 10:12:10 AM:
Quoted 3 lines · Stefan Berger
Quoted 2 lines
This patch aligns vTPM support in the Xen-API, documentation and
lib-xen
Quoted 5 lines
Quoted 3 lines
(after the recent changes).
Signed-off-by Stefan Berger <[email protected]>What's the intention here? You've removed the
get_instancecalls, but
not the
Quoted 1 line
instance field from the documentation. Assuming that that's just a
mistake,
Quoted 1 line
and you meant to remove the instance field, we're left with a VTPM class
that
Quoted 2 lines
has nothing other than a reference to a VM and a reference to a backend domain. What are the semantics of that object now?
The instance will remain to be assigned by the hotplug scripts. In the old-style of VM configuration file one could still pass it as parameter, but its ignored. I rather not have it passed in as a parameter by the Xen-API, either. From what I can see a getter for it is not useful, either, since I want the instance number to be hidden from management software.
The instance field should then also be removed from the documentation - I forgot that.
Stefan
Quoted 2 lines
Ewan.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 19 lines · Stefan Berger
Ewan Mellor <[email protected]> wrote on 01/30/2007 10:12:10 AM:
Quoted 3 lines · Stefan Berger
Quoted 2 lines
This patch aligns vTPM support in the Xen-API, documentation and
lib-xen
Quoted 5 lines
Quoted 3 lines
(after the recent changes).
Signed-off-by Stefan Berger <[email protected]>What's the intention here? You've removed the
get_instancecalls, butnot the
Quoted 1 line
instance field from the documentation. Assuming that that's just a
mistake,
Quoted 1 line
and you meant to remove the instance field, we're left with a VTPM class
that
Quoted 2 lines
has nothing other than a reference to a VM and a reference to a backend domain. What are the semantics of that object now?
Quoted 6 lines
The instance will remain to be assigned by the hotplug scripts. In the old-style of VM configuration file one could still pass it as parameter, but its ignored. I rather not have it passed in as a parameter by the Xen-API, either. From what I can see a getter for it is not useful, either, since I want the instance number to be hidden from management software.
What we're left with seems like a pretty expensive way of saying "VTPM_backend = N". Is there really nothing else that's configurable? We could just put this into VM.other_config if that's the only thing that you need, which would make configuring a VTPM a lot easier.
Ewan.
Ewan Mellor <[email protected]> wrote on 01/30/2007 10:32:40 AM:
Quoted 6 lines · Stefan Berger
Quoted 5 lines
Ewan Mellor <[email protected]> wrote on 01/30/2007 10:12:10 AM:
Quoted 2 lines · Stefan Berger
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
This patch aligns vTPM support in the Xen-API, documentation and
lib-xen
Quoted 5 lines
Quoted 3 lines
(after the recent changes).
Signed-off-by Stefan Berger <[email protected]>What's the intention here? You've removed the
get_instancecalls,
but
Quoted 4 lines
Quoted 4 lines
not the
Quoted 1 line
instance field from the documentation. Assuming that that's just a
mistake,
Quoted 1 line
and you meant to remove the instance field, we're left with a VTPM
class
Quoted 2 lines
Quoted 2 lines
that
Quoted 1 line
has nothing other than a reference to a VM and a reference to a
backend
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
domain. What are the semantics of that object now?
The instance will remain to be assigned by the hotplug scripts. In the old-style of VM configuration file one could still pass it as
parameter,
Quoted 6 lines
Quoted 4 lines
but its ignored. I rather not have it passed in as a parameter by the Xen-API, either. From what I can see a getter for it is not useful, either, since I want the instance number to be hidden from management software.
What we're left with seems like a pretty expensive way of saying
"VTPM_backend
Quoted 1 line
= N". Is there really nothing else that's configurable? We could just
put
Quoted 1 line
this into VM.other_config if that's the only thing that you need, which
would
Quoted 1 line
make configuring a VTPM a lot easier.
I would like to treat the vTPM as a device like VIF and VBDs with create and destroy methods exported to management software so that a TPM device can be added to a VM similar to other devices and possibly removed when the VM is not running.
Stefan
Quoted 2 lines
Ewan.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 38 lines · Stefan Berger
Ewan Mellor <[email protected]> wrote on 01/30/2007 10:32:40 AM:
Quoted 6 lines · Stefan Berger
Quoted 5 lines
Ewan Mellor <[email protected]> wrote on 01/30/2007 10:12:10 AM:
Quoted 2 lines · Stefan Berger
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
This patch aligns vTPM support in the Xen-API, documentation and
lib-xen
Quoted 5 lines
Quoted 3 lines
(after the recent changes).
Signed-off-by Stefan Berger <[email protected]>What's the intention here? You've removed the
get_instancecalls,but
Quoted 4 lines
Quoted 4 lines
not the
Quoted 1 line
instance field from the documentation. Assuming that that's just a
mistake,
Quoted 1 line
and you meant to remove the instance field, we're left with a VTPM
class
Quoted 2 lines
Quoted 2 lines
that
Quoted 1 line
has nothing other than a reference to a VM and a reference to a
backend
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
domain. What are the semantics of that object now?
The instance will remain to be assigned by the hotplug scripts. In the old-style of VM configuration file one could still pass it as
parameter,
Quoted 6 lines
Quoted 4 lines
but its ignored. I rather not have it passed in as a parameter by the Xen-API, either. From what I can see a getter for it is not useful, either, since I want the instance number to be hidden from management software.
What we're left with seems like a pretty expensive way of saying
"
VTPM_backendQuoted 1 line
= N". Is there really nothing else that's configurable? We could just
put
Quoted 8 lines
Quoted 1 line
this into VM.other_config if that's the only thing that you need, which
would
Quoted 1 line
make configuring a VTPM a lot easier.
I would like to treat the vTPM as a device like VIF and VBDs with create and destroy methods exported to management software so that a TPM device can be added to a VM similar to other devices and possibly removed when the VM is not running.
Well you'll certainly be able to remove it, whichever way it's modelled. I'm not sure that treating the VTPM as a device is worth the cost, but if you prefer it that way, that's fine by me.
I'll just remove that instance field from the docs, and leave it at that.
Ewan.
Ewan Mellor <[email protected]> wrote on 01/30/2007 11:13:35 AM:
Quoted 11 lines · Stefan Berger
Quoted 10 lines
Ewan Mellor <[email protected]> wrote on 01/30/2007 10:32:40 AM:
Quoted 7 lines · Stefan Berger
Quoted 6 lines
Ewan Mellor <[email protected]> wrote on 01/30/2007 10:12:10 AM:
Quoted 3 lines · Stefan Berger
Quoted 2 lines
This patch aligns vTPM support in the Xen-API, documentation
and
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib-xen
Quoted 5 lines
Quoted 3 lines
(after the recent changes).
Signed-off-by Stefan Berger <[email protected]>What's the intention here? You've removed the
get_instance
calls,
Quoted 3 lines
Quoted 3 lines
but
Quoted 2 lines
Quoted 2 lines
not the
Quoted 1 line
instance field from the documentation. Assuming that that's
just a
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
mistake,
Quoted 1 line
and you meant to remove the instance field, we're left with a
VTPM
Quoted 7 lines
Quoted 7 lines
class
Quoted 2 lines
Quoted 2 lines
that
Quoted 1 line
has nothing other than a reference to a VM and a reference to a
backend
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
domain. What are the semantics of that object now?
The instance will remain to be assigned by the hotplug scripts. In
the
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
old-style of VM configuration file one could still pass it as
parameter,
Quoted 1 line
Quoted 1 line
but its ignored. I rather not have it passed in as a parameter by
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Xen-API, either. From what I can see a getter for it is not
useful,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
either, since I want the instance number to be hidden from
management
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
software.
What we're left with seems like a pretty expensive way of saying
"
VTPM_backendQuoted 1 line
= N". Is there really nothing else that's configurable? We could
just
Quoted 2 lines
Quoted 2 lines
put
Quoted 1 line
this into VM.other_config if that's the only thing that you need,
which
Quoted 4 lines
Quoted 4 lines
would
Quoted 1 line
make configuring a VTPM a lot easier.
I would like to treat the vTPM as a device like VIF and VBDs with
create
Quoted 1 line
Quoted 1 line
and destroy methods exported to management software so that a TPM
device
Quoted 1 line
Quoted 1 line
can be added to a VM similar to other devices and possibly removed
when
Quoted 3 lines
Quoted 1 line
the VM is not running.
Well you'll certainly be able to remove it, whichever way it's modelled.
I'm
Quoted 1 line
not sure that treating the VTPM as a device is worth the cost, but if
you
Quoted 3 lines
prefer it that way, that's fine by me.
I'll just remove that instance field from the docs, and leave it at
that.
Quoted 1 line
Thank you. I noticed there's an error in the patch to XendDomainInfo. If you replace the has_type() part with has_key() then test 9 passes. Sorry for that.
Stefan
Quoted 1 line
Ewan.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 3 lines · Stefan Berger
I noticed there's an error in the patch to XendDomainInfo. If you replace the
has_type()part withhas_key()then test 9 passes. Sorry for that.
Fixed, thanks.
Ewan.