Commit 14807089 authored by Pavel Emelyanov's avatar Pavel Emelyanov

crtools: Fix -v option to conform to common sense

The -v option is declared as "optional argument" and thus
only -v=N or -vN are valid. Currently used -v N syntax no
longer works as expected, this will be treated as LOG_ERR
level (single -v) with dangling (unparsed) argument.

Sorry for that :( but it's better to this earlier.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 40ed1883
......@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
return -1;
while (1) {
static const char short_opts[] = "dsRf:t:p:hcD:o:n:vxVr:jl";
static const char short_opts[] = "dsRf:t:p:hcD:o:n:v::xVr:jl";
static struct option long_opts[] = {
{ "tree", required_argument, 0, 't' },
{ "pid", required_argument, 0, 'p' },
......@@ -170,20 +170,10 @@ int main(int argc, char *argv[])
return -1;
break;
case 'v':
if (optind < argc) {
char *opt = argv[optind];
if (isdigit(*opt)) {
log_level = -atoi(opt);
optind++;
} else {
if (log_level >= 0)
log_level++;
}
} else {
if (log_level >= 0)
log_level++;
}
if (optarg)
log_level = atoi(optarg);
else
log_level++;
break;
case 41:
pr_info("Will allow link remaps on FS\n");
......@@ -281,8 +271,6 @@ int main(int argc, char *argv[])
}
}
if (log_level < 0)
log_level = -log_level;
log_set_loglevel(log_level);
if (!log_inited) {
......@@ -402,11 +390,11 @@ usage:
" -o|--log-file FILE log file name (path is relative to --images-dir)\n"
" --log-pid enable per-process logging to separate FILE.pid files\n"
" -v [NUM] set logging level:\n"
" -v 0 - messages regardless of log level\n"
" -v 1, -v - errors, when we are in trouble\n"
" -v 2, -vv - warnings (default)\n"
" -v 3, -vvv - informative, everything is fine\n"
" -v 4, -vvvv - debug only\n"
" -v0 - messages regardless of log level\n"
" -v1, -v - errors, when we are in trouble\n"
" -v2, -vv - warnings (default)\n"
" -v3, -vvv - informative, everything is fine\n"
" -v4, -vvvv - debug only\n"
"\n"
"* Memory dumping options:\n"
" --track-mem turn on memory changes tracker in kernel\n"
......
......@@ -21,7 +21,7 @@ switch $current {
puts "FAIL: Timed out on ready"
exit -1
}
system ../../../criu dump -v 4 -D ./dump -o dump.log -j -t $pid
system ../../../criu dump -v4 -D ./dump -o dump.log -j -t $pi
system echo "$pid" > ./dump/pid.pid
exit 0
}
......@@ -37,7 +37,7 @@ switch $current {
exit -1
}
spawn ../../../criu restore -v 4 -D ./dump -o restore.log -j
spawn ../../../criu restore -v4 -D ./dump -o restore.log -j
#
# spawn doesn't wait for restore to complete, so
# add some sleep here. Still better would be to
......
......@@ -32,7 +32,7 @@ pid=${!}
echo Lanuched make in $pid background
sleep 2
${criu} dump --shell-job -D dump -o dump.log -v 4 -t ${pid} || {
${criu} dump --shell-job -D dump -o dump.log -v4 -t ${pid} || {
echo "Dump failed"
exit 1
}
......@@ -41,7 +41,7 @@ wait_tasks dump
echo "Dumped, restoring and waiting for completion"
${criu} restore --shell-job -D dump -o restore.log -v 4 || {
${criu} restore --shell-job -D dump -o restore.log -v4 || {
echo "Restore failed"
exit 1
}
......
......@@ -47,7 +47,7 @@ pid=${!}
echo "Started tar in $pid background"
sleep 3
${criu} dump --shell-job -D dump -o dump.log -v 4 -t ${pid} || {
${criu} dump --shell-job -D dump -o dump.log -v4 -t ${pid} || {
echo "Dump failed"
exit 1
}
......@@ -55,7 +55,7 @@ ${criu} dump --shell-job -D dump -o dump.log -v 4 -t ${pid} || {
wait_tasks dump
echo "Dump OK, restoring"
${criu} restore --shell-job -D dump -o restore.log -v 4 || {
${criu} restore --shell-job -D dump -o restore.log -v4 || {
echo "Restore failed"
exit 1
}
......
......@@ -10,14 +10,14 @@ mkdir data
pid=`jobs -p %1`
bg
$criu dump -j --tcp-established -D data/ -o dump.log -v 4 -t $pid || {
$criu dump -j --tcp-established -D data/ -o dump.log -v4 -t $pid || {
echo "Dump failed"
exit 1
}
wait_tasks dump
$criu restore -j --tcp-established -D data/ -d -o restore.log -v 4 || {
$criu restore -j --tcp-established -D data/ -d -o restore.log -v4 || {
echo "Restore failed"
exit 1
}
......
......@@ -37,11 +37,11 @@ launch_test
echo "Taking plain dump"
mkdir "$IMGDIR/dump-1/"
${CRIU} dump -D "$IMGDIR/dump-1/" -o dump.log -t ${PID} -v 4 || fail "Fail to dump"
${CRIU} dump -D "$IMGDIR/dump-1/" -o dump.log -t ${PID} -v4 || fail "Fail to dump"
sleep 1
echo "Restore to check it works"
${CRIU} restore -D "${IMGDIR}/dump-1/" -o restore.log -d -v 4 || fail "Fail to restore server"
${CRIU} restore -D "${IMGDIR}/dump-1/" -o restore.log -d -v4 || fail "Fail to restore server"
stop_test
......@@ -53,14 +53,14 @@ echo "Taking pre and plain dumps"
echo "Pre-dump"
mkdir "$IMGDIR/dump-2/"
mkdir "$IMGDIR/dump-2/pre/"
${CRIU} pre-dump -D "$IMGDIR/dump-2/pre/" -o dump.log -t ${PID} -v 4 || fail "Fail to pre-dump"
${CRIU} pre-dump -D "$IMGDIR/dump-2/pre/" -o dump.log -t ${PID} -v4 || fail "Fail to pre-dump"
echo "Plain dump"
mkdir "$IMGDIR/dump-2/plain/"
${CRIU} dump -D "$IMGDIR/dump-2/plain/" -o dump.log -t ${PID} -v 4 --prev-images-dir=../pre/ || fail "Fail to dump"
${CRIU} dump -D "$IMGDIR/dump-2/plain/" -o dump.log -t ${PID} -v4 --prev-images-dir=../pre/ || fail "Fail to dump"
sleep 1
echo "Restore"
${CRIU} restore -D "${IMGDIR}/dump-2/plain/" -o restore.log -d -v 4 || fail "Fail to restore server"
${CRIU} restore -D "${IMGDIR}/dump-2/plain/" -o restore.log -d -v4 || fail "Fail to restore server"
stop_test
......@@ -53,21 +53,21 @@ for SNAP in $(seq 1 $NRSNAP); do
fi
if [ $USEPS -eq 1 ]; then
${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --port ${PORT} -v 4 &
${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --port ${PORT} -v4 &
PS_PID=$!
ps_args="--page-server --address 127.0.0.1 --port=${PORT}"
else
ps_args=""
fi
${CRIU} $cmd -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v 4 $args $ps_args || fail "Fail to dump"
${CRIU} $cmd -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"
if [ $USEPS -eq 1 ]; then
wait $PS_PID
fi
done
echo "Restoring"
${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v 4 || fail "Fail to restore server"
${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to restore server"
cd ../zdtm/live/static/
make mem-touch.out
......
......@@ -50,21 +50,21 @@ for SNAP in $(seq 1 $NRSNAP); do
fi
if [ $USEPS -eq 1 ]; then
${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --port ${PORT} -v 4 &
${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --port ${PORT} -v4 &
PS_PID=$!
ps_args="--page-server --address 127.0.0.1 --port=${PORT}"
else
ps_args=""
fi
${CRIU} dump -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v 4 $args $ps_args || fail "Fail to dump"
${CRIU} dump -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"
if [ $USEPS -eq 1 ]; then
wait $PS_PID
fi
done
echo "Restoring"
${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v 4 || fail "Fail to restore server"
${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to restore server"
cd ../zdtm/live/static/
make mem-touch.out
......
......@@ -356,7 +356,7 @@ EOF
mkdir -p $ddump
if [ $PAGE_SERVER -eq 1 ]; then
$CRIU page-server -D $ddump -o page_server.log -v 4 --port $PS_PORT --daemon
$CRIU page-server -D $ddump -o page_server.log -v4 --port $PS_PORT --daemon
PS_PID=$!
opts="--page-server --address 127.0.0.1 --port $PS_PORT"
fi
......@@ -364,7 +364,7 @@ EOF
save_fds $PID $ddump/dump.fd
setsid $CRIU_CPT dump $opts --file-locks --tcp-established $linkremap \
-x --evasive-devices -D $ddump -o dump.log -v 4 -t $PID $args $ARGS || {
-x --evasive-devices -D $ddump -o dump.log -v4 -t $PID $args $ARGS || {
echo WARNING: process $tname is left running for your debugging needs
return 1
}
......@@ -397,7 +397,7 @@ EOF
done
echo Restore
setsid $CRIU restore --file-locks --tcp-established -x -D $ddump -o restore.log -v 4 -d $args || return 2
setsid $CRIU restore --file-locks --tcp-established -x -D $ddump -o restore.log -v4 -d $args || return 2
for i in `seq 5`; do
save_fds $PID $ddump/restore.fd
......
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