diff options
author | Simon Rettberg | 2020-03-10 16:52:51 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-03-10 16:52:51 +0100 |
commit | 92bd64aa85367ec602f714a404629d0818c17ca0 (patch) | |
tree | ba82fc46903588320646665de96f25064101464a | |
parent | [inc/chroot] Add tmpfs layer for upperdir (diff) | |
download | mltk-92bd64aa85367ec602f714a404629d0818c17ca0.tar.gz mltk-92bd64aa85367ec602f714a404629d0818c17ca0.tar.xz mltk-92bd64aa85367ec602f714a404629d0818c17ca0.zip |
[run-virt] Add pre-exec and post-exec hooks
-rw-r--r-- | core/modules/run-virt/README | 10 | ||||
-rwxr-xr-x | core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt | 8 |
2 files changed, 17 insertions, 1 deletions
diff --git a/core/modules/run-virt/README b/core/modules/run-virt/README index f009f55a..d079954c 100644 --- a/core/modules/run-virt/README +++ b/core/modules/run-virt/README @@ -139,3 +139,13 @@ Note that this is a floppy, not the cloud, so you're limited to 1.44MB of storag Hook to set up read or write access to image. Here, only *.inc type hooks make sense, since they're expected to set either VM_DISKFILE_RO or VM_DISKFILE_RW, depending on desired access. + +# pre-exec.d/ + +Hook that is run right before the virtualizer is executed. $1 is the virtualizer ID, $2 is the +imageuuid. + +# post-exec.d/ + +Hook that is run right after the virtualizer finished executing. $1 is the virtualizer ID, $2 is the +imageuuid. 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 a2d0f3cb..cf4bc1ca 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 @@ -177,11 +177,17 @@ main() { cleanexit 1 fi + run_hooks "pre-exec" "$PLUGIN_ID" "$IMGUUID" + writelog "VM command: ${VIRTCMD} ${VIRTCMDOPTS[*]}" # This will start the VM (no eval needed!) + local retval "${VIRTCMD}" "${VIRTCMDOPTS[@]}" + retval=$? + + run_hooks "post-exec" "$PLUGIN_ID" "$IMGUUID" - writelog "Virtualizer exited with '$?'. Bye." + writelog "Virtualizer exited with '$retval'. Bye." cleanexit 0 } |