From 8802d98df30ee3af69cf0f78531efa70df0e8f56 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 7 Dec 2015 09:21:58 +0100 Subject: [run-virt] unmount dnbd3-fuse on exit --- .../data/opt/openslx/scripts/includes/setup_image_access.inc | 6 +++--- .../openslx/scripts/includes/vmchooser_runvirt_functions.inc | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc index c669a210..806423cc 100644 --- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc +++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc @@ -4,17 +4,17 @@ writelog "Now in setup_image_access.inc ..." -# Mount path for images mounted with dnbd3-fuse -dnbd3_fuse_mount_point="/tmp/virt/${USER}.fuse" - # Try to use dnbd3 to access the image unset vm_diskfile unset vm_revision +unset dnbd3_fuse_mount_point if ! which dnbd3-fuse; then writelog "Can't use dnbd3 as dnbd3-fuse binary is not in PATH" elif [ -z "$SLX_DNBD3_SERVERS" ] || [ "x$SLX_VM_DNBD3" != "xyes" ]; then writelog "Can't use dnbd3 as no servers are given in config, or SLX_VM_DNBD3 is not set to yes" else + # Mount path for images mounted with dnbd3-fuse + dnbd3_fuse_mount_point="/tmp/virt/${USER}.fuse" mkdir -p "${dnbd3_fuse_mount_point}" # try to unmount first fusermount -u "${dnbd3_fuse_mount_point}" diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc index a81b9309..267d89e4 100644 --- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc +++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc @@ -4,10 +4,11 @@ # function to write to stdout and logfile writelog() { + local DATE=$(date +%Y-%m-%d-%H-%M-%S) # write to stdout - echo -e "$(date +%Y%m%d%H%M%S) $1" + echo -e "$DATE: $@" # log into file - echo -e "$(date +%Y%m%d%H%M%S) $1" >> "${LOGFILE}" + echo -e "$DATE: $@" >> "${LOGFILE}" } # Clean exit will be called at the end of vmchooser-run_virt @@ -19,10 +20,10 @@ cleanexit() { # rm -rf -- ${RMDIRS} >/dev/null 2>&1 writelog "done" fi - # Disconnect dnbd3 device - if [ -n "$dnbd3" ]; then + # Ummount dnbd3-fuse + if [ -n "$dnbd3_fuse_mount_point" ] && [ -e "$dnbd3_fuse_mount_point/img" ]; then for timeout in 1 1 2; do - dnbd3-client -d "$dnbd3" -c -d "$dnbd3" -c && break + fusermount -u "$dnbd3_fuse_mount_point" && break writelog "dnbd3 still busy...." sleep "$timeout" done -- cgit v1.2.3-55-g7522