summaryrefslogtreecommitdiffstats
path: root/core/modules/vbox-src
diff options
context:
space:
mode:
authorJonathan Bauer2018-04-18 11:33:31 +0200
committerJonathan Bauer2018-04-18 11:33:31 +0200
commit9504d2653999e7811a3f22e41f87aa30ef4e0dad (patch)
tree44c48692aa61e729efb015a54f76de1fdcf82621 /core/modules/vbox-src
parent[vbox-src] reload udev rules on vbox.service start (diff)
downloadmltk-9504d2653999e7811a3f22e41f87aa30ef4e0dad.tar.gz
mltk-9504d2653999e7811a3f22e41f87aa30ef4e0dad.tar.xz
mltk-9504d2653999e7811a3f22e41f87aa30ef4e0dad.zip
[vbox-src] cleanup snapshot file upon cleanexit
While VDI's "Immutable" type cleans up the snapshot file automatically, it doesn't do so until a restart of the VM. In our case, it will never happen and slowly fill up /tmp. Thus we remove it manually on cleanexit.
Diffstat (limited to 'core/modules/vbox-src')
-rwxr-xr-xcore/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc
index 296f55ae..48924458 100755
--- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc
+++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc
@@ -1,5 +1,9 @@
+delete_snapshot() {
+ rm -f "${VBOX_SNAPSHOT_DIR}/{${SNAPSHOT_UUID}}.vdi" || \
+ writelog "Could not cleanup snapshot file: ${VBOX_SNAPSHOT_DIR}/{${SNAPSHOT_UUID}}.vdi"
+}
prepare_snapshot() {
- SNAPSHOT_UUID="34f617be-192a-46b3-a8ae-bce1029e093f" # snapshot UUID is static
+ declare -rg SNAPSHOT_UUID="34f617be-192a-46b3-a8ae-bce1029e093f" # snapshot UUID is static
# get UUID of VBox image
HDD_UUID=$(${VBOX_BASE_DIR}/VBoxManage -q showvdiinfo ${VBOX_HDD_LINK} \
@@ -23,6 +27,7 @@ prepare_snapshot() {
dd if=${VBOX_HDD_LINK} of="${VBOX_SNAPSHOT_DIR}/{${SNAPSHOT_UUID}}.vdi" seek=424 \
skip=392 bs=1 count=16 conv=notrunc || \
writelog "Could not patch snapshot file"
+ add_cleanup delete_snapshot
elif isset VM_DISKFILE_RW; then
# Image is already RW - easy
VBOX_HDD_TYPE="Normal"