[CRIU] [PATCH 15/15] zdtm: check that a process has the same set of VMS-s after restore

Andrey Vagin avagin at openvz.org
Mon Sep 23 06:33:38 EDT 2013


Some VMA-s can be merged on restore. For example, If a process maps
VMA1, VMA2 and then VMA3 between the previous ones.
|VMA1|VMA3|VMA2|
The VMA3 will be merged only with VMA1, but all three VMA-s will be
merged on restore, because they are mmaped in a correct order VMA1,
VMA3, VMA2.

Due to this issue, we have a small script for merging continuous VMA-s.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/maps.py | 16 ++++++++++++++++
 test/zdtm.sh | 25 ++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 test/maps.py

diff --git a/test/maps.py b/test/maps.py
new file mode 100644
index 0000000..1b7f96c
--- /dev/null
+++ b/test/maps.py
@@ -0,0 +1,16 @@
+import sys
+start = 0;
+end = 0;
+
+for l in sys.stdin:
+	l = l.split()[0]
+	s, e = l.split('-')
+	s = int("0x" + s, 0)
+	e = int("0x" + e, 0)
+	if end == s:
+		end = e;
+	else:
+		print "%x-%x" % (start, end)
+		start = s
+		end = e
+print "%x-%x" % (start, end)
diff --git a/test/zdtm.sh b/test/zdtm.sh
index 3343788..b5d8eac 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -336,6 +336,21 @@ save_fds()
 	ls -l /proc/$1/fd | sed 's/\(-> \(pipe\|socket\)\):.*/\1/' | awk '{ print $9,$10,$11; }' > $2
 }
 
+save_maps()
+{
+	cat /proc/$1/maps | python maps.py > $2
+}
+
+diff_maps()
+{
+	if ! diff -up $1 $2; then
+		echo ERROR: Sets of mappings differ:
+		echo $1
+		echo $2
+		return 1
+	fi
+}
+
 diff_fds()
 {
 	test -n "$PIDNS" && return 0
@@ -437,6 +452,7 @@ EOF
 		[ -n "$dump_only" ] && postdump=$POSTDUMP
 
 		save_fds $PID  $ddump/dump.fd
+		save_maps $PID  $ddump/dump.maps
 		setsid $CRIU_CPT dump $opts --file-locks --tcp-established $linkremap \
 			-x --evasive-devices -D $ddump -o dump.log -v4 -t $PID $args $ARGS $snapopt $postdump
 		retcode=$?
@@ -470,6 +486,10 @@ EOF
 		if [ -n "$dump_only" ]; then
 			save_fds $PID  $ddump/dump.fd.after
 			diff_fds $ddump/dump.fd $ddump/dump.fd.after || return 1
+
+			save_maps $PID  $ddump/dump.maps.after
+			diff_maps $ddump/dump.maps $ddump/dump.maps.after || return 1
+
 			if [[ $linkremap ]]; then
 				echo "remove ./$tdir/link_remap.*"
 				rm -f ./$tdir/link_remap.*
@@ -492,13 +512,16 @@ EOF
 			echo Restore
 			setsid $CRIU restore --file-locks --tcp-established -x -D $ddump -o restore.log -v4 -d $args || return 2
 
+			[ -n "$PIDNS" ] && PID=`cat $TPID`
 			for i in `seq 5`; do
 				save_fds $PID  $ddump/restore.fd
 				diff_fds $ddump/dump.fd $ddump/restore.fd && break
 				sleep 0.2
 			done
 			[ $i -eq 5 ] && return 2
-			[ -n "$PIDNS" ] && PID=`cat $TPID`
+
+			save_maps $PID $ddump/restore.maps
+			diff_maps $ddump/dump.maps $ddump/restore.maps || return 2
 		fi
 
 	done
-- 
1.8.3.1



More information about the CRIU mailing list