From: Stefan Berger Subject: [PATCH] [Xen-API] Destroy the state of a vTPM if a VM is destroyed Date: Tue, 14 Nov 2006 15:04:08 -0500 Message-ID: <1163534648.16202.8.camel@lt2.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-r4gRxcR5N/MKSF72rzZ3" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Xen-devel List-Id: xen-devel@lists.xenproject.org --=-r4gRxcR5N/MKSF72rzZ3 Content-Type: text/plain Content-Transfer-Encoding: 7bit Explicitly destroy the state of a vTPM - using an external bash script - if its VM is destroyed . Signed-off-by: Stefan Berger --=-r4gRxcR5N/MKSF72rzZ3 Content-Disposition: attachment; filename=xenapi-vtpm-destroy.diff Content-Type: text/x-patch; name=xenapi-vtpm-destroy.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit 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. """ --=-r4gRxcR5N/MKSF72rzZ3 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-r4gRxcR5N/MKSF72rzZ3--