summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser
diff options
context:
space:
mode:
authorJonathan Bauer2019-07-10 14:49:10 +0200
committerJonathan Bauer2019-07-10 14:49:10 +0200
commit520560505cb22616440b6e5459fd9c79eec734a3 (patch)
tree6745247c711250be5d4c286ab89f8a7894317d02 /core/modules/run-virt/data/opt/openslx/vmchooser
parent[vmware-common] Actually pass some file to grep... (diff)
downloadmltk-520560505cb22616440b6e5459fd9c79eec734a3.tar.gz
mltk-520560505cb22616440b6e5459fd9c79eec734a3.tar.xz
mltk-520560505cb22616440b6e5459fd9c79eec734a3.zip
[run-virt] improve signal traps handling
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser')
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc5
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc10
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt7
3 files changed, 11 insertions, 11 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc
index b10623be..fad51c5d 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc
@@ -13,7 +13,6 @@
# indicate to the virt plugin that it doesn't need to
# handle creating a temporary CoW layer itself.
-
# Helper to cleanup the image mounted with dnbd3-fuse
cleanup_dnbd3() {
if ! isset DNBD3_MOUNT_POINT; then
@@ -21,7 +20,8 @@ cleanup_dnbd3() {
return 1
fi
# try to umount it now
- for timeout in 1 1 1 FAIL; do
+ for timeout in 1 1 1 2 2 3 FAIL; do
+ fs_path_ismountpoint "${DNBD3_MOUNT_POINT}" || break
fusermount -u "${DNBD3_MOUNT_POINT}" && break
writelog "dnbd3 still busy...."
[ "$timeout" = "FAIL" ] && break
@@ -86,7 +86,6 @@ setup_image_access() {
writelog "Setting up virtual hard disk access for virtualizer/emulator ..."
unset VM_DISKFILE_RO VM_DISKFILE_RW
declare -g VM_DISKFILE_RO VM_DISKFILE_RW
-
run_hooks "image-access"
if [ -n "$VM_DISKFILE_RW" ]; then
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
index aaace562..f049642d 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
@@ -120,6 +120,7 @@ add_cleanup() {
# EXIT_REASON should contain a user-friendly message to print to the user.
# it can be prefixed with err.\S+, which will serve as a translation identifier
cleanexit() {
+ trap "" SIGHUP SIGINT SIGTERM EXIT
writelog "Cleanexit '$1' triggered by '${BASH_SOURCE[1]}:${FUNCNAME[1]}'"
sleep 1
while isset CLEANUP_TASKS; do
@@ -134,6 +135,9 @@ cleanexit() {
fi
done
+ # kill potential remaining background jobs
+ kill $(jobs -p)
+
# If we're not in debug mode, remove all temporary files
if notempty SLX_DEBUG && isset TMPDIR; then
rm -rf -- "${TMPDIR}"
@@ -174,12 +178,6 @@ cleanexit() {
ERR_TEXT="Unbekannter Fehler"
fi
- # first send the logfile (in case the user does not close the error before using magic keys e.g.)
- # for any other error types besides 'user'. Do no slxlog if we run wrapped (from /opt/openslx/scripts/vmchooser-run_virt)
- if [ "x${EXIT_TYPE}" != "xuser" ]; then
- writelog "Critical error happened in '${BASH_SOURCE[1]}:${FUNCNAME[1]}'"
- fi
-
# finally display the error
error_user "${ERR_TITLE}" "
${ERR_TEXT}
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt b/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
index f545145b..aef4ba79 100755
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
@@ -31,6 +31,7 @@ readonly SELF
# Useless without this
. /opt/openslx/config
+. /opt/openslx/bin/slx-tools
# Global variables needed for the core functionality
declare -rg VMCHOOSER_DIR="/opt/openslx/vmchooser"
@@ -86,7 +87,10 @@ main() {
exit 1
fi
- trap 'trap "" SIGINT SIGTERM; cleanexit' SIGINT SIGTERM
+ trap 'cleanexit $?' EXIT
+ trap 'cleanexit 129' SIGHUP
+ trap 'cleanexit 130' SIGINT
+ trap 'cleanexit 143' SIGTERM
# Starting sourcing the includes files. Note that the critical ones should use
# the '--exit' option of safesource to trigger cleanexit in case of a corrupted/bad
@@ -173,7 +177,6 @@ main() {
cleanexit 0
}
-
# Detach
main &
RUNVIRT_PID="$!"