diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-02-26 14:34:50 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-02-26 14:34:50 +0000 |
commit | 6184985ce7187d09f08c558480c428b0118f405d (patch) | |
tree | 8d181ecdad72ea8a683c2d1b9dd50a4280b1eaed /tools/examples | |
parent | 2e85b907f1d2d8b09acca98442ae11dd37ae7e26 (diff) | |
download | xen-6184985ce7187d09f08c558480c428b0118f405d.tar.gz xen-6184985ce7187d09f08c558480c428b0118f405d.tar.bz2 xen-6184985ce7187d09f08c558480c428b0118f405d.zip |
vtpm: script function for identifying vTPM by its UUID
I am adding some functions for external tools to call the vTPM scripts.
It also contains a fix for the functions that previously used to be
called by domain name, but now are using the vTPM's uuid as parameter.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Diffstat (limited to 'tools/examples')
-rw-r--r-- | tools/examples/vtpm-common.sh | 25 | ||||
-rw-r--r-- | tools/examples/vtpm-delete | 13 |
2 files changed, 32 insertions, 6 deletions
diff --git a/tools/examples/vtpm-common.sh b/tools/examples/vtpm-common.sh index 7f8512e72f..93a40096ba 100644 --- a/tools/examples/vtpm-common.sh +++ b/tools/examples/vtpm-common.sh @@ -407,7 +407,7 @@ function vtpm_domid_from_name () { local id name ids ids=$(xenstore-list /local/domain) for id in $ids; do - name=$(xenstore_read /local/domain/$id/name) + name=$(xenstore-read /local/domain/$id/name) if [ "$name" == "$1" ]; then echo "$id" return @@ -416,16 +416,33 @@ function vtpm_domid_from_name () { echo "-1" } +#Determine the virtual TPM's instance number using the domain ID. +#1st parm: domain ID +function vtpm_uuid_by_domid() { + echo $(xenstore-read /local/domain/0/backend/vtpm/$1/0/uuid) +} + + +# Determine the vTPM's UUID by the name of the VM +function vtpm_uuid_from_vmname() { + local domid=$(vtpm_domid_from_name $1) + if [ "$domid" != "-1" ]; then + echo $(vtpm_uuid_by_domid $domid) + return + fi + echo "" +} #Add a virtual TPM instance number and its associated domain name #to the VTPMDB file and activate usage of this virtual TPM instance #by writing the instance number into the xenstore #1st parm: name of virtual machine -#2nd parm: instance of assoicate virtual TPM +#2nd parm: instance of associated virtual TPM function vtpm_add_and_activate() { local domid=$(vtpm_domid_from_name $1) - if [ "$domid" != "-1" ]; then - vtpmdb_add_instance $1 $2 + local vtpm_uuid=$(vtpm_uuid_from_vmname $1) + if [ "$vtpm_uuid" != "" -a "$domid" != "-1" ]; then + vtpmdb_add_instance $vtpm_uuid $2 xenstore-write backend/vtpm/$domid/0/instance $2 fi } diff --git a/tools/examples/vtpm-delete b/tools/examples/vtpm-delete index b54a093f02..b75b95bf0a 100644 --- a/tools/examples/vtpm-delete +++ b/tools/examples/vtpm-delete @@ -1,9 +1,18 @@ #!/bin/bash # This scripts must be called the following way: -# vtpm-delete <domain name> +# vtpm-delete <vtpm uuid> +# or +# vtpm-delete --vmname <vm name> dir=$(dirname "$0") . "$dir/vtpm-common.sh" -vtpm_delete_instance $1 +if [ "$1" == "--vmname" ]; then + vtpm_uuid=$(vtpm_uuid_from_vmname $2) + if [ "$vtpm_uuid" != "" ];then + vtpm_delete_instance $vtpm_uuid + fi +else + vtpm_delete_instance $1 +fi |