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 @@ -1006,6 +1006,8 @@ class XendAPI: def vm_clone(self, session, vm_ref): return xen_api_error(XEND_ERROR_UNSUPPORTED) def vm_destroy(self, session, vm_ref): + dom = XendDomain.instance().get_vm_by_uuid(vm_ref) + self.vtpm_destroy_by_vmname(dom.getName()) return do_vm_func("domain_delete", vm_ref) def vm_hard_reboot(self, session, vm_ref): return xen_api_error(XEND_ERROR_UNSUPPORTED) @@ -1390,6 +1392,12 @@ class XendAPI: else: return xen_api_error(XEND_ERROR_DOMAIN_INVALID) + # private class methods (unexported) + def vtpm_destroy_by_vmname(self, vmname): + # Destroy the vTPM's state if a VM is destroyed + from xen.xend.server.tpmif import destroy_vtpmstate + destroy_vtpmstate(vmname) + # Xen API: Class SR # ---------------------------------------------------------------- Index: root/xen-unstable.hg/tools/python/xen/xend/XendConstants.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xend/XendConstants.py +++ root/xen-unstable.hg/tools/python/xen/xend/XendConstants.py @@ -89,6 +89,12 @@ DEV_MIGRATE_STEP2 = 2 DEV_MIGRATE_STEP3 = 3 # +# VTPM-related constants +# + +VTPM_DELETE_SCRIPT = '/etc/xen/scripts/vtpm-delete' + +# # Xenstore Constants # Index: root/xen-unstable.hg/tools/python/xen/xend/server/tpmif.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xend/server/tpmif.py +++ root/xen-unstable.hg/tools/python/xen/xend/server/tpmif.py @@ -25,7 +25,7 @@ from xen.xend import sxp from xen.xend import XendRoot from xen.xend.XendLogging import log from xen.xend.XendError import XendError -from xen.xend.XendConstants import DEV_MIGRATE_TEST +from xen.xend.XendConstants import DEV_MIGRATE_TEST, VTPM_DELETE_SCRIPT from xen.xend.server.DevController import DevController import os @@ -33,6 +33,10 @@ import re xroot = XendRoot.instance() +def destroy_vtpmstate(name): + if os.path.exists(VTPM_DELETE_SCRIPT): + os.system(VTPM_DELETE_SCRIPT + " " + name) + class TPMifController(DevController): """TPM interface controller. Handles all TPM devices for a domain. """