From 520560505cb22616440b6e5459fd9c79eec734a3 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 10 Jul 2019 14:49:10 +0200 Subject: [run-virt] improve signal traps handling --- .../openslx/vmchooser/run-virt-includes/setup_image_access.inc | 5 ++--- .../run-virt-includes/vmchooser_runvirt_functions.inc | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes') 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} -- cgit v1.2.3-55-g7522