Index: root/xen-unstable.hg/tools/libxen/include/xen_vtpm.h =================================================================== --- root.orig/xen-unstable.hg/tools/libxen/include/xen_vtpm.h +++ root/xen-unstable.hg/tools/libxen/include/xen_vtpm.h @@ -172,7 +172,7 @@ xen_vtpm_create(xen_session *session, xe * Destroy the specified VTPM instance. */ extern bool -xen_vtpm_destroy(xen_session *session, xen_vtpm vtpm); +xen_vtpm_destroy(xen_session *session, int64_t *result, xen_vtpm vtpm); /** Index: root/xen-unstable.hg/tools/libxen/src/xen_vtpm.c =================================================================== --- root.orig/xen-unstable.hg/tools/libxen/src/xen_vtpm.c +++ root/xen-unstable.hg/tools/libxen/src/xen_vtpm.c @@ -132,7 +132,7 @@ xen_vtpm_create(xen_session *session, xe bool -xen_vtpm_destroy(xen_session *session, xen_vtpm vtpm) +xen_vtpm_destroy(xen_session *session, int64_t *result, xen_vtpm vtpm) { abstract_value param_values[] = { @@ -140,7 +140,10 @@ xen_vtpm_destroy(xen_session *session, x .u.string_val = vtpm } }; - xen_call_(session, "VTPM.destroy", param_values, 1, NULL, NULL); + abstract_type result_type = abstract_type_int; + + *result = 0; + XEN_CALL_("VTPM.destroy"); return session->ok; } Index: root/xen-unstable.hg/tools/python/xen/xend/XendAPI.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xend/XendAPI.py +++ root/xen-unstable.hg/tools/python/xen/xend/XendAPI.py @@ -1834,9 +1834,7 @@ class XendAPI(object): 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]]) + return xen_api_success(False) from xen.xend.server import tpmif tpmif.destroy_vtpmstate(dom.getName()) return xen_api_success(True) Index: root/xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex =================================================================== --- root.orig/xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex +++ root/xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex @@ -10880,7 +10880,7 @@ reference to the newly created object Destroy the specified VTPM instance. \noindent {\bf Signature:} -\begin{verbatim} void destroy (session_id s, VTPM ref self)\end{verbatim} +\begin{verbatim} int destroy (session_id s, VTPM ref self)\end{verbatim} \noindent{\bf Arguments:} @@ -10898,11 +10898,11 @@ Destroy the specified VTPM instance. \noindent {\bf Return Type:} {\tt -void +int } - +Success (1) or failure of the operation. \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} Index: root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py =================================================================== --- root.orig/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py +++ root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py @@ -112,22 +112,19 @@ if not re.search("PCR-00:",run["output"] saveLog(console.getHistory()) FAIL("1. Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"]) -try: - rc = session.xenapi.VTPM.destroy(vtpm_uuid) - #Should never get here +rc = session.xenapi.VTPM.destroy(vtpm_uuid) +if int(rc) != 0: + #Should not be able to destroy the VTPM with the VM running FAIL("Could destroy vTPM while VM is running") -except: - pass rc = session.xenapi.VM.suspend(vm_uuid) if rc: FAIL("Could not suspend VM") -try: - rc = session.xenapi.VTPM.destroy(vtpm_uuid) - #May not throw an exception in 'suspend' state -except: - pass +rc = session.xenapi.VTPM.destroy(vtpm_uuid) +if int(rc) != 0: + #Should not be able to destroy the VTPM with the VM running + print "Could destroy vTPM while VM is suspended?!" rc = session.xenapi.VM.resume(vm_uuid, False) if rc: