VTPM mini-os: vtpm hotplug fixes
PATCH 8/12 VTPM mini-os: vtpm hotplug fixes
This patch provides several bug fixes to the vtpm hotplug scripts that run in dom0. Previously there were many different cases that would cause them to either crash or hang. Mishandled lock files and improperly used ipc were the culprits.
With this patch the hotplug code uses the vtpmmgrtalk program (included in the last patch) to talk to the vtpm manager and determine if it is running and ready to receive commands.
With this patch and the previous vtpm_manager patch the tradition vtpm implementation in xen is very stable and usable.
Signed off by: Matthew Fioravante <[email protected]>
tools/hotplug/Linux/vtpm +4 -8
@@ -1,22 +1,18 @@ #!/bin/bash +export PATH=$PATH:/usr/sbin:/sbin + dir=$(dirname "$0") . "$dir/vtpm-hotplug-common.sh" -vtpm_fatal_error=0 - case "$command" in add) vtpm_create_instance + success ;; remove) vtpm_remove_instance + success ;; esac -if [ $vtpm_fatal_error -eq 0 ]; then - log debug "Successful vTPM operation '$command'." - success -else - fatal "Error while executing vTPM operation '$command'." -fi
tools/hotplug/Linux/vtpm-common.sh +11 -14
@@ -98,7 +98,7 @@ avail=0 else instances=$(cat $VTPMDB | \ - awk \ + gawk \ '{ \ if (1 != index($1,"#")) { \ printf("%s ",$2); \
@@ -120,7 +120,7 @@ function vtpmdb_get_free_instancenum () { local ctr instances don found instances=$(cat $VTPMDB | \ - awk \ + gawk \ '{ \ if (1 != index($1,"#")) { \ printf("%s ",$2); \
@@ -174,7 +174,7 @@ inst=$2 res=$(cat $VTPMDB | \ - awk -vvmname=$vmname \ + gawk -vvmname=$vmname \ -vinst=$inst \ '{ \ if ( 1 == index($1,"#")) {\
@@ -209,7 +209,7 @@ VTPMDB_TMP="$VTPMDB".tmp $(cat $VTPMDB | \ - awk -vvmname=$vmname \ + gawk -vvmname=$vmname \ '{ \ if ( $1 != vmname ) { \ print $0; \
@@ -276,12 +276,10 @@ vtpm_create $instance - if [ $vtpm_fatal_error -eq 0 ]; then - if [ "$uuid" != "" ]; then - vtpmdb_add_instance $uuid $instance - else - vtpmdb_add_instance $domname $instance - fi + if [ "$uuid" != "" ]; then + vtpmdb_add_instance $uuid $instance + else + vtpmdb_add_instance $domname $instance fi else if [ "$reason" == "resume" ]; then
@@ -290,7 +288,6 @@ vtpm_start $instance fi fi - release_lock vtpmdb xenstore_write $XENBUS_PATH/instance $instance
@@ -322,8 +319,8 @@ if [ "$instance" != "0" ]; then vtpm_suspend $instance fi - release_lock vtpmdb + }
@@ -350,13 +347,13 @@ function vtpm_isLocalAddress() { local addr res addr=$(ping $1 -c 1 | \ - awk '{ print substr($3,2,length($3)-2); exit }') + gawk '{ print substr($3,2,length($3)-2); exit }') if [ "$addr" == "" ]; then echo "-1" return fi res=$(ifconfig | grep "inet addr" | \ - awk -vaddr=$addr \ + gawk -vaddr=$addr \ '{ \ if ( addr == substr($2, 6)) {\ print "1"; \
tools/hotplug/Linux/vtpm-delete +2 -0
@@ -5,6 +5,8 @@ # or # vtpm-delete --vmname <vm name> +export PATH=$PATH:/usr/sbin:/sbin + dir=$(dirname "$0") . "$dir/vtpm-common.sh"
tools/hotplug/Linux/vtpm-impl +21 -29
72 lines not on this page · raw message
tools/python/xen/xend/server/tpmif.py +16 -0
@@ -44,6 +44,22 @@ DevController.__init__(self, vm) + def createDevice(self, config): + #Disable hotplug scripts if backend is not dom0 + import xen.xend.XendDomain + xd = xen.xend.XendDomain.instance() + backdom_name = config.get('backend') + if backdom_name is None: + backdom = xen.xend.XendDomain.DOM0_ID + else: + bd = xd.domain_lookup_nr(backdom_name) + backdom = bd.getDomid() + + if backdom != xen.xend.XendDomain.DOM0_ID: + self.hotplug = False + + return DevController.createDevice(self, config) + def getDeviceDetails(self, config): """@see DevController.getDeviceDetails"""
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel