Commit 7836baff authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Abandon timelimit program in favor of timeout

The latter is part of gnu coreutils.
parent 87d1bf2e
......@@ -22,7 +22,7 @@ LOSETUP="losetup"
SFDISK="sfdisk"
QEMU_IMG="qemu-img"
INSTALL_MBR="install-mbr"
TIMELIMIT="timelimit"
TIMEOUT="timeout"
CURL="curl"
network_backend_support="@network_backend_support@"
......@@ -378,7 +378,7 @@ fi
: ${HELPER_KERNEL:="@HELPER_KERNEL@"}
: ${HELPER_INITRD:="@HELPER_INITRD@"}
: ${HELPER_PKG:="@HELPER_DIR@/snf-image-helper.deb"}
: ${HELPER_SOFT_TIMEOUT:=15}
: ${HELPER_SOFT_TIMEOUT:=20}
: ${HELPER_HARD_TIMEOUT:=5}
: ${HELPER_USER:="nobody"}
: ${HELPER_CACHE_FILE:="@HELPER_DIR@/cache.tar"}
......
......@@ -130,9 +130,9 @@ if test -z "$INSTALL_MBR" ; then
AC_MSG_ERROR([install-mbr not found in $PATH:/usr/sbin:/sbin])
fi
AC_PATH_PROG(TIMELIMIT, [timelimit], [], [$PATH:/usr/sbin:/sbin])
if test -z "$TIMELIMIT" ; then
AC_MSG_ERROR([timelimit not found in $PATH:/usr/sbin:/sbin])
AC_PATH_PROG(TIMEOUT, [timeout], [], [$PATH:/usr/sbin:/sbin])
if test -z "$TIMEOUT" ; then
AC_MSG_ERROR([timeout not found in $PATH:/usr/sbin:/sbin])
fi
if test "x$enable_network_backend" = "xyes" ; then
......
......@@ -152,7 +152,8 @@ add_cleanup rm "$snapshot"
"$QEMU_IMG" create -f qcow2 -b "$HELPER_IMG" "$snapshot"
echo "$(date +%Y:%m:%d-%H:%M:%S.%N) Starting helper VM..."
$TIMELIMIT -t "$HELPER_SOFT_TIMEOUT" -T "$HELPER_HARD_TIMEOUT" \
set +e
$TIMEOUT -k "$HELPER_HARD_TIMEOUT" "$HELPER_SOFT_TIMEOUT" \
kvm -runas "$HELPER_USER" -drive file="$snapshot" \
-drive file="$blockdev",format=raw,if=virtio,cache=none \
-boot c -serial stdio -serial "file:$(printf "%q" "$result_file")" \
......@@ -161,13 +162,24 @@ $TIMELIMIT -t "$HELPER_SOFT_TIMEOUT" -T "$HELPER_HARD_TIMEOUT" \
-kernel "$HELPER_KERNEL" -initrd "$HELPER_INITRD" \
-append "quiet ro root=/dev/sda1 console=ttyS0,9600n8 snf_image_activate_helper" \
2>&1 | sed 's|^|HELPER: |g'
echo "$(date +%Y:%m:%d-%H:%M:%S.%N) Helper VM finished."
if [ $? -ne 0 ]; then
if [ $? -gt 128 ]; then
log_error "Helper was terminated. Did not finish on time."
rc=$?
set -e
if [ $rc -ne 0 ]; then
if [ $rc -eq 124 ]; then
log_error "Helper VM was terminated. Did not finish on time."
if [ $rc -eq 137 ]; then # (128 + SIGKILL)
log_error "Helper VM was killed. Did not finish on time."
elif [ $rc -eq 141 ]; then # (128 + SIGPIPE)
log_error "Helper was killed by a SIGPIPE signal."
log_error "Maybe progress monitor has died unexpectedly."
elif [ $rc -eq 125 ]; then
log_error "timeout did not manage to run."
else
log_error "KVM returned an error (return code $rc)."
fi
exit 1
else
echo "$(date +%Y:%m:%d-%H:%M:%S.%N) Helper VM finished."
fi
# Do not report errors after this. If the result is not "SUCCESS" then the
......
......@@ -29,11 +29,13 @@
# HELPER_TIMOUT: Soft and hard timeout limits for helper instance.
# The helper instance will be terminated after a given time if it hasn't exited
# by itself.
#
# When HELPER_SOFT_TIMEOUT seconds have passed, a SIGTERM is sent.
# When HELPER_HARD_TIMEOUT seconds more have passed, a SIGKILL is sent.
# HELPER_SOFT_TIMEOUT="15"
# by itself. A TERM signal will be send if the instance is running after
# a HELPER_SOFT_TIMEOUT interval. A KILL signal will be sent, if the instance
# is still running after a HELPER_HARD_TIMEOUT interval since the initial
# signal was sent. The timeout values are integer numbers with an optional
# suffix: `s' for seconds (the default), `m' for minutes, `h' for hours or `d'
# for days.
# HELPER_SOFT_TIMEOUT="20"
# HELPER_HARD_TIMEOUT="5"
# HELPER_USER: For security reasons, it is recommended that the helper VM
......
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