Skip to contentSkip to conversation

vtpm Mini-Os domain: vtpm hotplug stability fixes

PATCH In review Matthew Fioravante 1 participant 1 message Aug 25, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 2/7 vtpm Mini-Os domain: vtpm hotplug stability fixes

The following patch provides stability fixes for the vtpm hotplug system.

There were several cases where the hotplug system would get in a bad state and would hang because of a stale lockfile that never got cleaned up. The pipes that talk to the manager could also get left in a bad state.

The hotplug scripts as they are now only work correctly if one file lock is set. If 2 or more file locks are created and the script exits on an error, the trap cleanup will only release the last lock.

This patch also adds a binary called vtpmmgrtalk which talks to the manager using the console fifos. It uses non-blocking IO to open the fifos so it can quit immediatly with an error if the manager is not listening on the other side. The hotplug scripts now use this program to talk to the manager.

tools/vtpm_manager/vtpmmgrtalk/Makefile new file +17 -0
diff -r 7c44921abfde -r 5793f5c2d67d tools/vtpm_manager/vtpmmgrtalk/Makefile
@@ -0,0 +1,17 @@
+XEN_ROOT = ../../..
+TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin
+
+BIN=vtpmmgrtalk
+OBJS=vtpmmgrtalk.o
+CFLAGS=-Wall -O2
+
+all: ${BIN}
+
+${BIN}: ${OBJS}
+	gcc -o $@ $<
+
+install: all
+	install -m 0755 ${BIN} ${TOOLS_INSTALL_DIR}
+
+clean: 
+	-rm ${BIN} ${OBJS}
tools/vtpm_manager/vtpmmgrtalk/vtpmmgrtalk.c new file +94 -0

94 lines not on this page · raw message

tools/vtpm_manager/Makefile +1 -1
diff -r 7c44921abfde -r 5793f5c2d67d tools/vtpm_manager/Makefile
@@ -3,7 +3,7 @@
 # Base definitions and rules
 include $(XEN_ROOT)/tools/vtpm_manager/Rules.mk
 
-SUBDIRS		= crypto tcs util manager migration
+SUBDIRS		= crypto tcs util manager migration vtpmmgrtalk
 OPENSSL_HEADER	= /usr/include/openssl/crypto.h
 
 .PHONY: all clean install
tools/hotplug/Linux/vtpm +4 -8
diff -r 5793f5c2d67d -r c54dd4a9e114 tools/hotplug/Linux/vtpm
@@ -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
diff -r 5793f5c2d67d -r c54dd4a9e114 tools/hotplug/Linux/vtpm-common.sh
@@ -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
 
-	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
diff -r 5793f5c2d67d -r c54dd4a9e114 tools/hotplug/Linux/vtpm-delete
@@ -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

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel