Commit 4c52aaf4 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: check that a process has the same set of VMS-s after restore

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: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e1e10347
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)
...@@ -336,6 +336,21 @@ save_fds() ...@@ -336,6 +336,21 @@ save_fds()
ls -l /proc/$1/fd | sed 's/\(-> \(pipe\|socket\)\):.*/\1/' | awk '{ print $9,$10,$11; }' > $2 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() diff_fds()
{ {
test -n "$PIDNS" && return 0 test -n "$PIDNS" && return 0
...@@ -437,6 +452,7 @@ EOF ...@@ -437,6 +452,7 @@ EOF
[ -n "$dump_only" ] && postdump=$POSTDUMP [ -n "$dump_only" ] && postdump=$POSTDUMP
save_fds $PID $ddump/dump.fd save_fds $PID $ddump/dump.fd
save_maps $PID $ddump/dump.maps
setsid $CRIU_CPT dump $opts --file-locks --tcp-established $linkremap \ 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 -x --evasive-devices -D $ddump -o dump.log -v4 -t $PID $args $ARGS $snapopt $postdump
retcode=$? retcode=$?
...@@ -470,6 +486,10 @@ EOF ...@@ -470,6 +486,10 @@ EOF
if [ -n "$dump_only" ]; then if [ -n "$dump_only" ]; then
save_fds $PID $ddump/dump.fd.after save_fds $PID $ddump/dump.fd.after
diff_fds $ddump/dump.fd $ddump/dump.fd.after || return 1 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 if [[ $linkremap ]]; then
echo "remove ./$tdir/link_remap.*" echo "remove ./$tdir/link_remap.*"
rm -f ./$tdir/link_remap.* rm -f ./$tdir/link_remap.*
...@@ -492,13 +512,16 @@ EOF ...@@ -492,13 +512,16 @@ EOF
echo Restore echo Restore
setsid $CRIU restore --file-locks --tcp-established -x -D $ddump -o restore.log -v4 -d $args || return 2 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 for i in `seq 5`; do
save_fds $PID $ddump/restore.fd save_fds $PID $ddump/restore.fd
diff_fds $ddump/dump.fd $ddump/restore.fd && break diff_fds $ddump/dump.fd $ddump/restore.fd && break
sleep 0.2 sleep 0.2
done done
[ $i -eq 5 ] && return 2 [ $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 fi
done done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment