[CRIU] [PATCH] test: allocate port for page server dinamicaly
Andrey Vagin
avagin at openvz.org
Fri Nov 21 02:50:44 PST 2014
$ cat test/dump/static/write_read02/94/3/page_server.log
(00.000006) Starting page server on port 12345
(00.000030) Error (page-xfer.c:303): Can't bind page server: Address already in use
Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
crtools.c | 2 +-
test/zdtm.sh | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/crtools.c b/crtools.c
index 0ac667c..398552e 100644
--- a/crtools.c
+++ b/crtools.c
@@ -337,7 +337,7 @@ int main(int argc, char *argv[], char *envp[])
break;
case 1052:
opts.ps_port = htons(atoi(optarg));
- if (!opts.ps_port)
+ if (opts.ps_port < 0)
goto bad_arg;
break;
case 'j':
diff --git a/test/zdtm.sh b/test/zdtm.sh
index ac897ba..c22ee8f 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -322,7 +322,6 @@ ITERATIONS=1
EXCLUDE_PATTERN=""
CLEANUP=0
PAGE_SERVER=0
-PS_PORT=12345
COMPILE_ONLY=0
START_ONLY=0
BATCH_TEST=0
@@ -577,6 +576,7 @@ run_test()
local test=$1
local snappdir=
local ps_pid=
+ local ps_port=
[ -n "$EXCLUDE_PATTERN" ] && echo $test | grep "$EXCLUDE_PATTERN" && return 0
@@ -661,13 +661,15 @@ EOF
[ -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 $ps_args --daemon --pidfile $ddump/page-server.pid || return 1
+ $CRIU page-server -D $ddump -o page_server.log -v4 --port 0 $ps_args --daemon --pidfile $ddump/page-server.pid || return 1
ps_pid=`cat $ddump/page-server.pid`
ps -p "$ps_pid" -o cmd h | grep -q page-server || {
echo "Unable to determing PID of page-server"
return 1
}
- cpt_args="$cpt_args --page-server --address 127.0.0.1 --port $PS_PORT"
+ ps_port=`lsof -p $ps_pid | grep LISTEN | sed "s/.*:\([0-9]*\)\s(LISTEN).*/\1/"`
+ echo "The page server binds to $ps_port"
+ cpt_args="$cpt_args --page-server --address 127.0.0.1 --port $ps_port"
fi
if [ -n "$SNAPSHOT" ]; then
--
1.9.3
More information about the CRIU
mailing list