ia64/xen-unstable

changeset 8760:bf176086255b

Update the TPM hotplug scripts to determine the reason of a
device creation (create/resume).

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Feb 04 10:58:28 2006 +0100 (2006-02-04)
parents 6f7c5439a6c4
children c5fd98fcb127
files tools/examples/vtpm tools/examples/vtpm-common.sh
line diff
     1.1 --- a/tools/examples/vtpm	Fri Feb 03 20:30:54 2006 +0100
     1.2 +++ b/tools/examples/vtpm	Sat Feb 04 10:58:28 2006 +0100
     1.3 @@ -5,18 +5,18 @@ dir=$(dirname "$0")
     1.4  
     1.5  
     1.6  case "$command" in
     1.7 -    online | offline)
     1.8 -        exit 0
     1.9 -        ;;
    1.10 -esac
    1.11 -
    1.12 -case "$command" in
    1.13    add)
    1.14      vtpm_create_instance
    1.15    ;;
    1.16 +  online)
    1.17 +    vtpm_create_instance
    1.18 +  ;;
    1.19    remove)
    1.20      vtpm_remove_instance
    1.21    ;;
    1.22 +  offline)
    1.23 +    vtpm_remove_instance
    1.24 +  ;;
    1.25  esac
    1.26  
    1.27  log debug "Successful vTPM operation '$command'."
     2.1 --- a/tools/examples/vtpm-common.sh	Fri Feb 03 20:30:54 2006 +0100
     2.2 +++ b/tools/examples/vtpm-common.sh	Sat Feb 04 10:58:28 2006 +0100
     2.3 @@ -219,6 +219,17 @@ function remove_entry () {
     2.4  }
     2.5  
     2.6  
     2.7 +# Find the reason for the creation of this device:
     2.8 +# Set global REASON variable to 'resume' or 'create'
     2.9 +function get_create_reason () {
    2.10 +	local resume=$(xenstore-read $XENBUS_PATH/resume)
    2.11 +	if [ "$resume" == "True" ]; then
    2.12 +		REASON="resume"
    2.13 +	else
    2.14 +		REASON="create"
    2.15 +	fi
    2.16 +}
    2.17 +
    2.18  #Create a vTPM instance
    2.19  # If no entry in the TPM database is found, the instance is
    2.20  # created and an entry added to the database.
    2.21 @@ -226,6 +237,7 @@ function vtpm_create_instance () {
    2.22  	local domname=$(xenstore_read "$XENBUS_PATH"/domain)
    2.23  	local res
    2.24  	set +e
    2.25 +	get_create_reason
    2.26  	find_instance $domname
    2.27  	res=$?
    2.28  	if [ $res -eq 0 ]; then
    2.29 @@ -243,7 +255,7 @@ function vtpm_create_instance () {
    2.30  		add_instance $domname $instance
    2.31  		if [ "$REASON" == "create" ]; then
    2.32  			vtpm_create $instance
    2.33 -		elif [ "$REASON" == "hibernate" ]; then
    2.34 +		elif [ "$REASON" == "resume" ]; then
    2.35  			vtpm_resume $instance $domname
    2.36  		else
    2.37  			#default case for 'now'
    2.38 @@ -252,11 +264,12 @@ function vtpm_create_instance () {
    2.39  	fi
    2.40  	if [ "$REASON" == "create" ]; then
    2.41  		vtpm_reset $instance
    2.42 -	elif [ "$REASON" == "hibernate" ]; then
    2.43 +	elif [ "$REASON" == "resume" ]; then
    2.44  		vtpm_setup $instance
    2.45  	else
    2.46  		#default case for 'now'
    2.47 -		vtpm_reset $instance
    2.48 +		#vtpm_reset $instance
    2.49 +		true
    2.50  	fi
    2.51  	xenstore_write $XENBUS_PATH/instance $instance
    2.52  	set -e
    2.53 @@ -273,7 +286,7 @@ function vtpm_remove_instance () {
    2.54  		#Something is really wrong with the DB
    2.55  		log err "vTPM DB file $VTPMDB has no entry for '$domname'"
    2.56  	else
    2.57 -		if [ "$REASON" == "hibernate" ]; then
    2.58 +		if [ "$REASON" == "suspend" ]; then
    2.59  			vtpm_suspend $instance
    2.60  		fi
    2.61  	fi