From d7e17204f14f90d0c2c1f8fb71d3e68edda9d83d Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Tue, 9 Feb 2021 10:05:18 +0100 Subject: [qemu] Remove unused run-virt includes --- .../includes/determine_hardware_limitations.inc | 89 ---------------------- .../qemu/includes/finalize_start_command.inc | 49 ------------ .../vmchooser/plugins/qemu/includes/init_core.inc | 54 ------------- .../plugins/qemu/includes/log_config_summary.inc | 35 --------- .../plugins/qemu/includes/setup_network.inc | 56 -------------- .../plugins/qemu/includes/setup_rw_layer.inc | 25 ------ 6 files changed, 308 deletions(-) delete mode 100644 core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/determine_hardware_limitations.inc delete mode 100644 core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/finalize_start_command.inc delete mode 100644 core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/init_core.inc delete mode 100644 core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/log_config_summary.inc delete mode 100644 core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/setup_network.inc delete mode 100644 core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/setup_rw_layer.inc diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/determine_hardware_limitations.inc b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/determine_hardware_limitations.inc deleted file mode 100644 index dd83b587..00000000 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/determine_hardware_limitations.inc +++ /dev/null @@ -1,89 +0,0 @@ -################################################################## -# qemu/kvm include: determine virtual hardware based on guest OS # -################################################################## - -set_vm_hw_limits() { - # FIXME when we have better metadata for qemu - if isempty VM_OS_TYPE; then - writelog "VM_OS_TYPE is empty! This should have been parsed from the XML file" - EXIT_TYPE="user" EXIT_REASON="Konnte Gastbetriebsystems der virtuellen Maschine nicht ermitteln!" cleanexit 1 - fi - - # define global hardware-related variables - declare -g MAXMEM="9999999" - declare -g MAXCORES="4" - declare -g SOUND_DEV="es1370" - - # determine if we need a 32bit or 64bit machine - # FIXME depending on the guest OS for now - # (sadly does not support all the exotic OSs the - # the world has even seen like vmware plugin :<) - local bits=64 - case "${VM_OS_TYPE}" in - beos*) - bits=32 - SOUND_DEV="sb16" - ;; - win3*|win*3*|Win*3*) - bits=32 - SOUND_DEV="sb16" - MAXMEM=32 - ;; - win95*|Win*95) - bits=32 - MAXMEM=96 - ;; - win98) - bits=32 - MAXMEM=256 - ;; - winme*|windowsme*) - bits=32 - SOUND_DEV="ac97" - MAXMEM=384 - ;; - winxp*64|windowsxp*64) - SOUND_DEV="ac97" - ;; - windows7|windows8|windows9) - SOUND_DEV="ac97" - MAXMEM="8000" - MAXCORES="4" - ;; - windows7-64|windows8-64|windows9-64) - SOUND_DEV="ac97" - MAXMEM="32000" - MAXCORES="8" - ;; - *64) - MAXMEM="16000" - MAXCORES="4" - ;; - *) - bits=32 - MAXMEM="8000" - MAXCORES="1" - ;; - esac - declare -g VIRTCMD - if [ "$bits" = 32 ]; then - declare -rg VIRTCMD="qemu-system-i386" - VIRTCMDOPTS+=( "-machine" "accel=tcg" ) # TODO: 32bit VMs can't use kvm!? - else # 64 bit - declare -rg VIRTCMD="qemu-system-x86_64" - VIRTCMDOPTS+=( "-machine" "accel=kvm" ) - fi - - - # check for allocated cores - declare -g CPU_CORES="${HW_THREADS:-1}" - declare -rg HOST_CORE_COUNT="${CPU_CORES}" - [ "${CPU_CORES}" -gt "${MAXCORES}" ] && CPU_CORES="${MAXCORES}" - - # check if memory set by the generic run-virt is above the threshold - [ "${VM_MEM}" -gt "${MAXMEM}" ] && VM_MEM="${MAXMEM}" - return 0 -} - -## MAIN ## -call_post_source set_vm_hw_limits diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/finalize_start_command.inc b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/finalize_start_command.inc deleted file mode 100644 index 6d9df363..00000000 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/finalize_start_command.inc +++ /dev/null @@ -1,49 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# 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 bwlehrpool@hs-offenburg.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/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/init_core.inc b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/init_core.inc deleted file mode 100644 index fee2cd1c..00000000 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/init_core.inc +++ /dev/null @@ -1,54 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# 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 bwlehrpool@hs-offenburg.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/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/log_config_summary.inc b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/log_config_summary.inc deleted file mode 100644 index 6b4b279f..00000000 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/log_config_summary.inc +++ /dev/null @@ -1,35 +0,0 @@ -################################################## -# Include: Print vm config summary into log file # -################################################## - -log_config_summary() { - writelog "Directories:" - writelog "\tTMPDIR:\t\t\t$TMPDIR" - writelog "Disk image:" - writelog "\tSource disk:\t\t$VM_DISKFILE_RO" - if [ -e "${VM_DISKFILE_RW}" ]; then - writelog "\tDisk mode:\t\twritable" - writelog "\tRW-Layer:\t\t$VM_DISKFILE_RW" - else - writelog "\tDisk mode:\t\tread-only" - fi - - writelog "Virtual Hardware:" - writelog "\tvCPU cores:\t\t${CPU_CORES}" - writelog "\tGuest RAM:\t\t${VM_MEM} MB" - - # echo nur wenn HOST_MEM_REMAINING gesetzt - if isset HOST_MEM_REMAINING; then - writelog "\tHost RAM:\t\t${HOST_MEM_REMAINING} MB" - fi - writelog "\tMAC address:\t\t${VM_MAC_ADDR}" - writelog "\tNetwork card:\t\t${NIC_MODEL}" - writelog "\tNetwork kind:\t\t${NETWORK_MODE}" - writelog "\tCD-ROM1:\t${CDROM_0}" - writelog "\tCD-ROM2:\t${CDROM_1}" - writelog "\tFloppy_A:\t${FLOPPY_0}" - writelog "\tFloppy_B:\t${SLX_FLOPPY_IMG}" - #writelog "\tShared Folders 'home':\t/home/${USER}" -} - -call_post_source log_config_summary diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/setup_network.inc b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/setup_network.inc deleted file mode 100644 index 73fb2518..00000000 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/setup_network.inc +++ /dev/null @@ -1,56 +0,0 @@ -################################### -# qemu/kvm include: Network setup # -################################### -# This now makes use of the qemu's bridge helper -# which creates a tap device and adds it to the -# bridge corresponding to the network type -# TODO configurable network type -setup_network() { - # list available models with: - # qemu-system-x86_64 -net nic,model=? - # e.g. as of 2.0.0: - # ne2k_pci,i82551,i82557b,i82559er,rtl8139,e1000,pcnet,virtio - declare -rg NIC_MODEL="e1000" - - # add MAC address and network card model - VIRTCMDOPTS+=( "-device" "${NIC_MODEL},mac=${VM_MAC_ADDR},netdev=guestnet0" ) - - # TODO support different network kinds for lectures in bwlehrpool-suite, just NAT for now - declare -g NETWORK_MODE="nat" - - # detect if qemu's bridge helper binary is available - declare -g QEMU_BRIDGE_HELPER= - for HELPER_PATH in /usr/lib/qemu-bridge-helper /usr/local/libexec/qemu-bridge-helper; do - if [ -x "${HELPER_PATH}" ] && [ -u "${HELPER_PATH}" ]; then - QEMU_BRIDGE_HELPER="${HELPER_PATH}" - readonly QEMU_BRIDGE_HELPER - break - fi - done - if isempty QEMU_BRIDGE_HELPER; then - writelog "Could not find qemu-bridge-helper on this machine. Setting network mode to user." - # Even though falling back to creating tap devices ourselves, we should instead - # garantee the existance of qemu's helper on minilinux build time. - # qemu's user network mode allows tcp/udp connections in a nat-fashion and - # it allows access to the web which seems suffisant for a fallback. - NETWORK_MODE="user" - fi - - case "${NETWORK_MODE}" in - nat*) - VIRTCMDOPTS+=( "-netdev" "bridge,br=nat1,id=guestnet0,helper=${QEMU_BRIDGE_HELPER}" ) - ;; - bridge*) - VIRTCMDOPTS+=( "-netdev" "bridge,br=br0,id=guestnet0,helper=${QEMU_BRIDGE_HELPER}" ) - ;; - host*) - VIRTCMDOPTS+=( "-netdev" "bridge,br=vsw2,id=guestnet0,helper=${QEMU_BRIDGE_HELPER}" ) - ;; - user*|*) - VIRTCMDOPTS+=( "-netdev" "user,id=guestnet0" ) - ;; - esac -} - -## MAIN ## -call_post_source setup_network diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/setup_rw_layer.inc b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/setup_rw_layer.inc deleted file mode 100644 index 32637e5d..00000000 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/includes/setup_rw_layer.inc +++ /dev/null @@ -1,25 +0,0 @@ - -setup_rw_layer() { - if isempty VM_DISKFILE_RO; then - writelog "No source diskfile found! This should be specified in the given XML file. Is it valid?" - EXIT_TYPE="user" EXIT_REASON="Keine virtuelle Festplatte zu dieser Veranstaltung angegeben!" cleanexit 1 - fi - - # setup qcow2 backing file for that disk file - writelog "Creating backing file for '${VM_DISKFILE_RO}'..." - # TODO: WTF? This is fucked up, VM_DISKFILE_RW is set if we want to run in persistent mode, - # this plugin shouldn't mess around with it.... - declare -rg VM_DISKFILE_RW="${TMPDIR}/$(basename ${VM_DISKFILE_RO}).qcow2" - if qemu-img create -f qcow2 -b "${VM_DISKFILE_RO}" "${VM_DISKFILE_RW}"; then - # all good, use it as main disk drive - # TODO: determine the proper type of controller to use, ideally virtio? - VIRTCMDOPTS+=("-drive" "if=virtio,format=qcow2,file=${VM_DISKFILE_RW}" ) - else - writelog "Error creating backing file for '${VM_DISKFILE_RO}'" - # TODO use -snapshot as fallback, test it! - # How is this supposed to even work without a disk? - VIRTCMDOPTS+=( "-snapshot" ) - fi -} - -call_post_source setup_rw_layer -- cgit v1.2.3-55-g7522