summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include')
-rw-r--r--core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include71
1 files changed, 71 insertions, 0 deletions
diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include
new file mode 100644
index 00000000..04dca832
--- /dev/null
+++ b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include
@@ -0,0 +1,71 @@
+# -----------------------------------------------------------------------------
+#
+# Copyright (c) 2009..2021 bwLehrpool-Projektteam
+#
+# This program/file is free software distributed under the GPL version 2.
+# See https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
+#
+# If you have any feedback please consult https://bwlehrpool.de and
+# send your feedback to bwlehrpool@hs-offenburg.de.
+#
+# General information about bwLehrpool can be found at https://bwlehrpool.de
+#
+# -----------------------------------------------------------------------------
+# run-virt.include
+# - qemu plugin for vmchooser run-virt
+################################################################################
+
+# BASH_SOURCE[0] contains the file being sourced, namely this one
+declare -rg QEMU_PLUGIN_DIR="$(dirname "${BASH_SOURCE[0]}")"
+declare -rg QEMU_INCLUDE_DIR="${QEMU_PLUGIN_DIR}/includes"
+
+# Define which features the QEMU plugin supports
+declare -rg PLUGIN_FEATURES="firewall printer usb slxfloppy sound netshares"
+
+run_plugin() {
+ # setup RW image access for operation
+ local vm_diskfile
+ if notempty VM_DISKFILE_RO; then
+ # create copy-on-write layer for readonly image
+ vm_diskfile="${TMPDIR}/$(basename ${VM_DISKFILE_RO}).cow.qcow2"
+ local vm_diskfile_type="$(qemu-img info --output=json ${VM_DISKFILE_RO} | jq -r '.format')"
+ qemu-img create -F "${vm_diskfile_type}" -b "${VM_DISKFILE_RO}" -f qcow2 "${vm_diskfile}"
+ elif notempty VM_DISKFILE_RW; then
+ # use supplied RW disk image from run-virt
+ vm_diskfile="${VM_DISKFILE_RW}"
+ fi
+
+ # write finalized config in debug mode to temporary folder for debugging purposes
+ if [ "${DEBUG}" = "true" ]; then
+ local vm_final_config="/tmp/qemu-last-config.xml"
+ fi
+
+ # call the Libvirt Java tool to finalize configuration and start VM
+ declare -rg VIRTCMD="java"
+ VIRTCMDOPTS=( "-jar" "${QEMU_PLUGIN_DIR}/runvirt-plugin-qemu.jar" )
+
+ notempty DEBUG && VIRTCMDOPTS+=( "-debug" "${DEBUG}" )
+ notempty VM_CLEANNAME && VIRTCMDOPTS+=( "-vmname" "${VM_CLEANNAME}" )
+ notempty VM_DISPLAYNAME && VIRTCMDOPTS+=( "-vmdsplname" "${VM_DISPLAYNAME}" )
+ notempty VM_OS_TYPE && VIRTCMDOPTS+=( "-vmos" "${VM_OS_TYPE}" )
+ notempty TMPCONFIG && VIRTCMDOPTS+=( "-vmcfginp" "${TMPCONFIG}" )
+ notempty vm_final_config && VIRTCMDOPTS+=( "-vmcfgout" "${vm_final_config}" )
+ notempty IMGUUID && VIRTCMDOPTS+=( "-vmuuid" "${IMGUUID}" )
+ notempty HW_CORES && VIRTCMDOPTS+=( "-vmncpus" "${HW_CORES}" )
+ notempty VM_MEM && VIRTCMDOPTS+=( "-vmmem" "${VM_MEM}" )
+ notempty VM_MAC_ADDR && VIRTCMDOPTS+=( "-vmmac0" "${VM_MAC_ADDR}" )
+ notempty vm_diskfile && VIRTCMDOPTS+=( "-vmhdd0" "${vm_diskfile}" )
+ VIRTCMDOPTS+=( "-vmfloppy0" "${FLOPPY_0}" )
+ notempty SLX_FLOPPY_IMG && VIRTCMDOPTS+=( "-vmfloppy1" "${SLX_FLOPPY_IMG}" )
+ notempty CDROM_0 && VIRTCMDOPTS+=( "-vmcdrom0" "${CDROM_0}" )
+ notempty CDROM_1 && VIRTCMDOPTS+=( "-vmcdrom1" "${CDROM_1}" )
+ notempty SERIAL0 && VIRTCMDOPTS+=( "-vmserial0" "${SERIAL0}" )
+ notempty PARALLEL0 && VIRTCMDOPTS+=( "-vmparallel0" "${PARALLEL0}" )
+
+ if [ "${SHARE_REMAP_MODE}" -gt 1 ]; then
+ notempty HOME_SHARE_PATH && VIRTCMDOPTS+=( "-vmfssrc0" "${HOME_SHARE_PATH}" )
+ notempty HOME_SHARE_NAME && VIRTCMDOPTS+=( "-vmfstgt0" "${HOME_SHARE_NAME}" )
+ notempty COMMON_SHARE_PATH && VIRTCMDOPTS+=( "-vmfssrc1" "${COMMON_SHARE_PATH}" )
+ notempty COMMON_SHARE_NAME && VIRTCMDOPTS+=( "-vmfstgt1" "${COMMON_SHARE_NAME}" )
+ fi
+}