diff options
Diffstat (limited to 'core/modules/qemukvm/data/opt')
4 files changed, 175 insertions, 0 deletions
diff --git a/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env b/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env new file mode 100755 index 00000000..7717394d --- /dev/null +++ b/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env @@ -0,0 +1,28 @@ +#!/bin/ash +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2017..2018 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 support@bwlehrpool.de. +# +# General information about bwLehrpool can be found at https://bwlehrpool.de +# +# ----------------------------------------------------------------------------- +# systemd-qemukvm_env +# - This is the preparation script for the configuration of Linux Qemu/KVM. +################################################################################ + +# lazy load all kvm related modules +modprobe kvm +modprobe kvm_amd +modprobe kvm_intel + +if [ ! -e /dev/kvm ]; then + slxlog "qemukvm-modules" "/dev/kvm not found! Missing kvm kernel module(s)?" + exit 1 +fi + diff --git a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/finalize_start_command.inc b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/finalize_start_command.inc new file mode 100644 index 00000000..eff764fe --- /dev/null +++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/finalize_start_command.inc @@ -0,0 +1,49 @@ +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2009..2018 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 support@bwlehrpool.de. +# +# General information about bwLehrpool can be found at https://bwlehrpool.de +# +# ----------------------------------------------------------------------------- +# run-virt.include +# - Include script for running the QEMU/Linux KVM virtual machine on an +# OpenSLX client via the run-virt.sh or run-vmgrid.sh +################################################################################ + +# set options that depend on previous includes +# and build the final start command +finalize_start_command() { + + # set cpu type + VIRTCMDOPTS+=( "-cpu" "host" ) + # set cpu cores + VIRTCMDOPTS+=( "-smp" "${CPU_CORES}" ) + + # set RAM + VIRTCMDOPTS+=( "-m" "${VM_MEM}" ) + + # special feature for real and virtual floppy disks + isset FLOPPY_0 && VIRTCMDOPTS+=( "-fda" "${FLOPPY_0}" ) + isset SLX_FLOPPY_IMG && VIRTCMDOPTS+=( "-fdb" "${SLX_FLOPPY_IMG}" ) + + # add optical drive if available + isset CDROM_0 && VIRTCMDOPTS+=( "-cdrom" "${CDROM_0}" ) + + # audio + isset SOUND_DEV && VIRTCMDOPTS+=( "-soundhw" "${SOUND_DEV}" ) + + # serial devices TODO test + if isset SERIAL_PORTS; then + for DEV in $SERIAL_PORTS; do + : # buggeh: VIRTCMDOPTS+=( "-serial" "${DEV}" ) + done + fi +} + +call_post_source finalize_start_command diff --git a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/init_core.inc b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/init_core.inc new file mode 100644 index 00000000..53f214bd --- /dev/null +++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/init_core.inc @@ -0,0 +1,54 @@ +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2009..2018 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 support@bwlehrpool.de. +# +# General information about bwLehrpool can be found at https://bwlehrpool.de +# +# ----------------------------------------------------------------------------- +# run-virt.include +# - Include script for running the QEMU/Linux KVM virtual machine on an +# OpenSLX client via the run-virt.sh or run-vmgrid.sh +################################################################################ + +# check if kvm kernel module are available +if [ ! -c /dev/kvm ]; then + writelog "KVM kernel modules not loaded!" + EXIT_TYPE="internal" EXIT_REASON="QEMU/KVM Virtualisierer nicht initialisiert!" cleanexit 1 +fi + +# check if qemu binaries are available +if ! check_dep qemu-system-{i386,x86_64}; then + writelog "QEMU binaries not available!" + EXIT_TYPE="internal" EXIT_REASON="QEMU/KVM Virtualisierer nicht initialisiert!" cleanexit 1 +fi + +# set general purpose options here, mostly evaluates information +# contained in /opt/openslx/vmchooser/config/virtualization.conf + +# TODO some options should come from the server, in particular +# - disk controller type (virtio, scsi, ide...) +# - arch to emulate (x86_64, i386, ...) +# - graphics mode? +# - sound dev? +# - tbd + +# display name, remove blanks because of cmdline problems +declare -rg CMD_DISPLAYNAME=$(echo ${VM_DISPLAYNAME} | sed -e "s, ,-,g;s,(,[,g;s,),],g") +VIRTCMDOPTS+=( "-name" "${CMD_DISPLAYNAME}" ) + +# graphical start: vga, vmware, qxl, spice? +VIRTCMDOPTS+=( "-vga" "std" "-full-screen" ) + +# hot keys ALT+CTRL+SHIFT (does not work properly!?) +VIRTCMDOPTS+=( "-alt-grab" ) + +# TODO support other types of boot? any usecase for network boot? +# for now just boot from disk +VIRTCMDOPTS+=( "-boot" "c" ) + diff --git a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include new file mode 100644 index 00000000..a1a41499 --- /dev/null +++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include @@ -0,0 +1,44 @@ +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2009..2018 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 support@bwlehrpool.de. +# +# General information about bwLehrpool can be found at https://bwlehrpool.de +# +# ----------------------------------------------------------------------------- +# run-virt.include +# - qemu/kvm plugin for vmchooser run-virt +################################################################################ + +# BASH_SOURCE[0] contains the file being sourced, namely this one +declare -rg QEMUKVM_PLUGIN_DIR="$(dirname "${BASH_SOURCE[0]}")" +declare -rg QEMUKVM_INCLUDE_DIR="${QEMUKVM_PLUGIN_DIR}/includes" + +# TODO make this part of the metadata coming from the server +# TBD: "firewall printer usb slxfloppy sound netshares" +declare -rg PLUGIN_FEATURES="slxfloppy" + +run_plugin() { + # declaration of default functions and variables for vmware + $(safesource --exit "${QEMUKVM_INCLUDE_DIR}/init_core.inc") + + # determine limitations wrt RAM and CPU count of VM + $(safesource "${QEMUKVM_INCLUDE_DIR}/determine_hardware_limitations.inc") + + # setup networking + $(safesource "${QEMUKVM_INCLUDE_DIR}/setup_network.inc") + + # setup rw layer for ro image + $(safesource "${QEMUKVM_INCLUDE_DIR}/setup_rw_layer.inc") + + # build the final start command + $(safesource "${QEMUKVM_INCLUDE_DIR}/finalize_start_command.inc") + + # print summary - needs writelog() from vmchooser-run_virt + $(safesource "${QEMUKVM_INCLUDE_DIR}/log_config_summary.inc") +} |