[CRIU] [PATCH] zdtm: Use "post-dump" script for "-d" and "-s" option, v4

Andrey Vagin avagin at openvz.org
Tue Jul 16 06:43:35 EDT 2013


From: Cyrill Gorcunov <gorcunov at openvz.org>

https://bugzilla.openvz.org/show_bug.cgi?id=2583

v2:
 - Use special opcode 32 to distinguish error cases
 - Use --scripts for snapshot testings

v3:
 - test for both 32 and 0 for error code

v4: restore from the last snapshot

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/post-dump.sh |  9 +++++++++
 test/zdtm.sh      | 32 ++++++++++++++++++++++++--------
 2 files changed, 33 insertions(+), 8 deletions(-)
 create mode 100755 test/post-dump.sh

diff --git a/test/post-dump.sh b/test/post-dump.sh
new file mode 100755
index 0000000..8cc6fed
--- /dev/null
+++ b/test/post-dump.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+[ $CRTOOLS_SCRIPT_ACTION == post-dump ] && {
+	#
+	# Special code to inform CRIU that
+	# it should turn off repair mode
+	# on sockets.
+        exit 32
+}
diff --git a/test/zdtm.sh b/test/zdtm.sh
index 9749b90..186236d 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -153,6 +153,8 @@ sk-netlink
 CRIU=$(readlink -f `dirname $0`/../criu)
 CRIU_CPT=$CRIU
 TMP_TREE=""
+SCRIPTDIR=`dirname $CRIU`/test
+POSTDUMP="--action-script $SCRIPTDIR/post-dump.sh"
 
 test -x $CRIU || {
 	echo "$CRIU is unavailable"
@@ -369,12 +371,15 @@ EOF
 	fi
 
 	for i in `seq $ITERATIONS`; do
-
+		local dump_only=
+		local postdump=
 		ddump=dump/$tname/$PID/$i
 		DUMP_PATH=`pwd`/$ddump
 		echo Dump $PID
 		mkdir -p $ddump
 
+		[ -n "$DUMP_ONLY" ] && dump_only=1
+
 		if [ $PAGE_SERVER -eq 1 ]; then
 			$CRIU page-server -D $ddump -o page_server.log -v4 --port $PS_PORT --daemon
 			PS_PID=$!
@@ -383,16 +388,28 @@ EOF
 
 		if [ -n "$SNAPSHOT" ]; then
 			snapopt=""
-			[ "$i" -ne "$ITERATIONS" ] && snapopt="$snapopt -R --track-mem"
+			[ "$i" -ne "$ITERATIONS" ] && {
+				snapopt="$snapopt -R --track-mem"
+				dump_only=1
+			}
 			[ -n "$snappdir" ] && snapopt="$snapopt --prev-images-dir=$snappdir"
 		fi
 
+		[ -n "$dump_only" ] && postdump=$POSTDUMP
+
 		save_fds $PID  $ddump/dump.fd
 		setsid $CRIU_CPT dump $opts --file-locks --tcp-established $linkremap \
-			-x --evasive-devices -D $ddump -o dump.log -v4 -t $PID $args $ARGS $snapopt || {
-			echo WARNING: process $tname is left running for your debugging needs
+			-x --evasive-devices -D $ddump -o dump.log -v4 -t $PID $args $ARGS $snapopt $postdump
+		retcode=$?
+
+		#
+		# Here we may have two cases: either checkpoint is failed
+		# with some error code, or checkpoint is complete but return
+		# code is non-zero because of post dump action.
+		if [ "$retcode" -ne 0 ] && [[ "$retcode" -ne 32 || -z "$dump_only" ]]; then
+			echo WARNING: $tname returned $retcode and left running for debug needs
 			return 1
-		}
+		fi
 
 		if [ -n "$SNAPSHOT" ]; then
 			snappdir=../`basename $ddump`
@@ -403,10 +420,9 @@ EOF
 			wait $PS_PID
 		fi
 
-		if expr " $ARGS" : ' -s' > /dev/null; then
+		if [ -n "$dump_only" ]; then
 			save_fds $PID  $ddump/dump.fd.after
 			diff_fds $ddump/dump.fd $ddump/dump.fd.after || return 1
-			killall -CONT $tname
 			if [[ $linkremap ]]; then
 				echo "remove ./$tdir/link_remap.*"
 				rm -f ./$tdir/link_remap.*
@@ -499,7 +515,7 @@ cd `dirname $0` || exit 1
 
 while :; do
 	if [ "$1" = "-d" ]; then
-		ARGS="-s"
+		DUMP_ONLY=1
 		shift
 		continue
 	fi
-- 
1.8.3.1



More information about the CRIU mailing list