summaryrefslogtreecommitdiffstats
path: root/core/modules/qemukvm
diff options
context:
space:
mode:
authorJonathan Bauer2017-08-17 18:09:18 +0200
committerJonathan Bauer2017-08-17 18:09:18 +0200
commitdd9f5e920cff8432ab31d9a3f6318a10daec8711 (patch)
tree8cd71a8ee32269ed4fe3f79dab77b411ca1f1a16 /core/modules/qemukvm
parentMerge branch 'master' of git.openslx.org:openslx-ng/mltk (diff)
downloadmltk-dd9f5e920cff8432ab31d9a3f6318a10daec8711.tar.gz
mltk-dd9f5e920cff8432ab31d9a3f6318a10daec8711.tar.xz
mltk-dd9f5e920cff8432ab31d9a3f6318a10daec8711.zip
[qemukvm] reworked qemu run-virt module
now uses a similar structure than the vmware plugin for run-virt guest OS stuff needs to go aways, kept for compat reasons for now TODO metadata handling in bwLehrpool-Suite
Diffstat (limited to 'core/modules/qemukvm')
-rw-r--r--core/modules/qemukvm/FIXME1
-rw-r--r--core/modules/qemukvm/data/etc/qemu/bridge.conf6
-rw-r--r--core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env19
-rw-r--r--core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/determine_hardware_limitations.inc93
-rw-r--r--core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/finalize_start_command.inc47
-rw-r--r--core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/init_core.inc52
-rw-r--r--core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/log_config_summary.inc35
-rw-r--r--core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/setup_network.inc56
-rw-r--r--core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/setup_rw_layer.inc22
-rw-r--r--core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include275
-rw-r--r--core/modules/qemukvm/module.build2
-rw-r--r--core/modules/qemukvm/module.conf11
-rw-r--r--core/modules/qemukvm/module.conf.ubuntu22
13 files changed, 354 insertions, 287 deletions
diff --git a/core/modules/qemukvm/FIXME b/core/modules/qemukvm/FIXME
deleted file mode 100644
index a3523e53..00000000
--- a/core/modules/qemukvm/FIXME
+++ /dev/null
@@ -1 +0,0 @@
-This module was never finished. It should not be used as is.
diff --git a/core/modules/qemukvm/data/etc/qemu/bridge.conf b/core/modules/qemukvm/data/etc/qemu/bridge.conf
new file mode 100644
index 00000000..b8478434
--- /dev/null
+++ b/core/modules/qemukvm/data/etc/qemu/bridge.conf
@@ -0,0 +1,6 @@
+# These needs to be compatible with the
+# bridge's names generated by
+# /opt/openslx/scripts/systemd-run_virt_env
+allow br0
+allow nat1
+allow vsw2
diff --git a/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env b/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env
index e19ae1ee..03a138be 100644
--- a/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env
+++ b/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env
@@ -1,6 +1,6 @@
#!/bin/ash
# -----------------------------------------------------------------------------
-# Copyright (c) 2013 - OpenSLX GmbH
+# Copyright (c) 2017 - OpenSLX GmbH
#
# This program/file is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
@@ -14,20 +14,13 @@
# - 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
-# check for Linux kvm modules (if required at all)
-
-lsmod |grep kvm || slxlog "qemukvm-modules" "Cannot find any kvm kernel module(s)"
-
-cat >> /etc/sudoers << EOF
-# allow to start and stop kvm services / load-/unload kvm modules
-ALL ALL=NOPASSWD: /opt/openslx/sbin/tunctl -t kvmnet*
-ALL ALL=NOPASSWD: /opt/openslx/sbin/tunctl -d kvmnet*
-ALL ALL=NOPASSWD: /opt/openslx/sbin/brctl addif br0 kvmnet*
-ALL ALL=NOPASSWD: /opt/openslx/bin/ip link set dev kvmnet* *
-EOF
+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/determine_hardware_limitations.inc b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/determine_hardware_limitations.inc
new file mode 100644
index 00000000..becb2a80
--- /dev/null
+++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/determine_hardware_limitations.inc
@@ -0,0 +1,93 @@
+##################################################################
+# 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 :<)
+ declare -g VIRTCMD=
+ case "${VM_OS_TYPE}" in
+ beos*)
+ VIRTCMD="qemu-system-i386"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg"
+ SOUND_DEV="sb16"
+ ;;
+ win3*|win*3*|Win*3*)
+ VIRTCMD="qemu-system-i386"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg"
+ SOUND_DEV="sb16"
+ MAXMEM=32
+ ;;
+ win95*|Win*95)
+ VIRTCMD="qemu-system-i386"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg"
+ MAXMEM=96
+ ;;
+ win98)
+ VIRTCMD="qemu-system-i386"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg"
+ MAXMEM=256
+ ;;
+ winme*|windowsme*)
+ VIRTCMD="qemu-system-i386"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg"
+ SOUND_DEV="ac97"
+ MAXMEM=384
+ ;;
+ winxp*64|windowsxp*64)
+ VIRTCMD="qemu-system-x86_64"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=kvm"
+ SOUND_DEV="ac97"
+ ;;
+ windows7|windows8|windows9)
+ VIRTCMD="qemu-system-x86_64"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=kvm"
+ SOUND_DEV="ac97"
+ MAXMEM="8000"
+ MAXCORES="4"
+ ;;
+ windows7-64|windows8-64|windows9-64)
+ VIRTCMD="qemu-system-x86_64"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=kvm"
+ SOUND_DEV="ac97"
+ MAXMEM="32000"
+ MAXCORES="8"
+ ;;
+ *64)
+ VIRTCMD="qemu-system-x86_64"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=kvm"
+ MAXMEM="16000"
+ MAXCORES="4"
+ ;;
+ *)
+ VIRTCMD="qemu-system-i386"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=kvm"
+ MAXMEM="8000"
+ MAXCORES="1"
+ ;;
+ esac
+
+ # check for allocated cores
+ 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/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..348da296
--- /dev/null
+++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/finalize_start_command.inc
@@ -0,0 +1,47 @@
+# -----------------------------------------------------------------------------
+# Copyright (c) 2009..2017 - OpenSLX GmbH
+#
+# This program/file is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+# -----------------------------------------------------------------------------
+# 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="${VIRTCMDOPTS} -cpu host"
+ # set cpu cores
+ VIRTCMDOPTS="${VIRTCMDOPTS} -smp ${CPU_CORES}"
+
+ # set RAM
+ VIRTCMDOPTS="${VIRTCMDOPTS} -m ${VM_MEM}"
+
+ # special feature for real and virtual floppy disks
+ isset FLOPPY_0 && VIRTCMDOPTS="${VIRTCMDOPTS} -fda ${FLOPPY_0}"
+ isset SLX_FLOPPY_IMG && VIRTCMDOPTS="${VIRTCMDOPTS} -fdb ${SLX_FLOPPY_IMG}"
+
+ # add optical drive if available
+ isset CDROM_0 && VIRTCMDOPTS="${VIRTCMDOPTS} -cdrom ${CDROM_0}"
+
+ # audio
+ isset SOUND_DEV && VIRTCMDOPTS="${VIRTCMDOPTS} -soundhw ${SOUND_DEV}"
+
+ # serial devices TODO test
+ if isset SERIAL_PORTS; then
+ for DEV in $SERIAL_PORTS; do
+ : # buggeh: VIRTCMDOPTS="${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..0041d46e
--- /dev/null
+++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/init_core.inc
@@ -0,0 +1,52 @@
+# -----------------------------------------------------------------------------
+# Copyright (c) 2009..2017 - OpenSLX GmbH
+#
+# This program/file is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+# -----------------------------------------------------------------------------
+# 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")
+declare -g VIRTCMDOPTS="-name ${CMD_DISPLAYNAME}"
+
+# graphical start: vga, vmware, qxl, spice?
+VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen"
+
+# hot keys ALT+CTRL+SHIFT (does not work properly!?)
+VIRTCMDOPTS="${VIRTCMDOPTS} -alt-grab"
+
+# TODO support other types of boot? any usecase for network boot?
+# for now just boot from disk
+VIRTCMDOPTS="${VIRTCMDOPTS} -boot c"
+
diff --git a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/log_config_summary.inc b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/log_config_summary.inc
new file mode 100644
index 00000000..6b4b279f
--- /dev/null
+++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/log_config_summary.inc
@@ -0,0 +1,35 @@
+##################################################
+# 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/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/setup_network.inc b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/setup_network.inc
new file mode 100644
index 00000000..13fcbdf2
--- /dev/null
+++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/setup_network.inc
@@ -0,0 +1,56 @@
+###################################
+# 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="${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="${VIRTCMDOPTS} -netdev bridge,br=nat1,id=guestnet0,helper=${QEMU_BRIDGE_HELPER}"
+ ;;
+ bridge*)
+ VIRTCMDOPTS="${VIRTCMDOPTS} -netdev bridge,br=br0,id=guestnet0,helper=${QEMU_BRIDGE_HELPER}"
+ ;;
+ host*)
+ VIRTCMDOPTS="${VIRTCMDOPTS} -netdev bridge,br=vsw2,id=guestnet0,helper=${QEMU_BRIDGE_HELPER}"
+ ;;
+ user*|*)
+ VIRTCMDOPTS="${VIRTCMDOPTS} -netdev user,id=guestnet0"
+ ;;
+ esac
+}
+
+## MAIN ##
+call_post_source setup_network
diff --git a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/setup_rw_layer.inc b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/setup_rw_layer.inc
new file mode 100644
index 00000000..e066a55c
--- /dev/null
+++ b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/setup_rw_layer.inc
@@ -0,0 +1,22 @@
+
+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}'..."
+ 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="${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!
+ VIRTCMDOPTS="${VIRTCMDOPTS} -snapshot"
+ fi
+}
+
+call_post_source setup_rw_layer
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
index e2a60f9c..4e4811d4 100644
--- 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
@@ -1,250 +1,43 @@
# -----------------------------------------------------------------------------
-# Copyright (c) 2009..2013 - OpenSLX GmbH
+# Copyright (c) 2009..2017 - RZ Uni Freiburg
+# Copyright (c) 2009..2017 - OpenSLX GmbH
#
-# This program/file is free software distributed under the GPL version 2.
+# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
-# send your feedback to feedback@openslx.org
+# send your suggestions, praise, or complaints to feedback@openslx.org
#
-# General information about OpenSLX can be found at http://openslx.org
+# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# 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
-################################################################################
-
-################################################################################
-### Script functions
-################################################################################
-
-setup_if ()
-{
- kvmdev=$1
- hostdev=$2
- sudo /opt/openslx/rootfs/sbin/tunctl -t ${kvmdev} -u ${USER} >/dev/null 2>&1
- sudo /opt/openslx/rootfs/bin/ip link set dev ${kvmdev} up
- sudo /opt/openslx/rootfs/usr/sbin/brctl addif ${hostdev} ${kvmdev}
+# - 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")
}
-
-################################################################################
-### Declaration of default variables
-################################################################################
-# Define which features the VMware plugin supports
-declare -rg PLUGIN_FEATURES="TODO"
-
-VMCHOOSERQK="/opt/openslx/vmchooser/${self}"
-# create TMPDIR for all users
-mkdir -m 1777 /tmp/${self} 2>/dev/null
-# TMPDIR
-QKTMPDIR="/tmp/${self}/${USER}/${VM_ID}"
-# define dirs and files which can be removed after exit, be carefull!
-RMDIRS="${QKTMPDIR}"
-rm -rf ${RMDIRS} 2>/dev/null
-mkdir -m 1777 -p ${QKTMPDIR} 2>/dev/null
-# vmpath is the path to the vm, here an image (img|qcow*|vmdk)
-diskfile=${vmpath}
-
-# check the file type
-if echo ${IMG_BASENAME} | grep -iE "img|qcow|vmdk" >/dev/null 2>&1; then
- imgtype=$(echo ${IMG_BASENAME##*.} | tr "[a-z]" "[A-Z]")
-else
- writelog "${IMG_BASENAME} is not a valid image type (img|qcow*|vmdk), exiting!"
- exit 1
-fi
-
-# set the emulator/virtualization options for various operating systems
-SOUND_DEV="es1370"
-case "${VM_OS_TYPE}" in
- beos*)
- VIRTCMDOPTS="qemu-system-i386 -machine accel=tcg"
- SOUND_DEV="sb16"
- if [ "${HOST_MEM_TOTAL}" -ge "1000" ]; then
- forcemem=512
- else
- forcemem=256
- fi
- ;;
- win3*|win*3*|Win*3*)
- VIRTCMDOPTS="qemu-system-i386 -machine accel=tcg"
- SOUND_DEV="sb16"
- forcemem=32
- ;;
- win95*|Win*95)
- VIRTCMDOPTS="qemu-system-i386 -machine accel=tcg"
- forcemem=96
- ;;
- win98)
- VIRTCMDOPTS="qemu-system-i386 -machine accel=tcg"
- forcemem=256
- ;;
- winme*|windowsme*)
- VIRTCMDOPTS="qemu-system-i386 -machine accel=tcg"
- SOUND_DEV="ac97"
- forcemem=384
- ;;
- winxp*64|windowsxp*64)
- VIRTCMDOPTS="qemu-system-x86_64 -machine accel=kvm"
- SOUND_DEV="ac97"
- ;;
-esac
-
-# hot keys ALT+CTRL+SHIFT (does not work properly!?)
-#VIRTCMDOPTS="${VIRTCMDOPTS} -alt-grab"
-
-# display name, remove blanks because of cmdline problems
-VM_DISPLAYNAME=$(echo ${VM_DISPLAYNAME} | sed -e "s, ,-,g;s,(,[,g;s,),],g")
-VIRTCMDOPTS="${VIRTCMDOPTS} -name ${VM_DISPLAYNAME}"
-
-writelog "Directories:"
-writelog "\tTMPDIR:\t\t\t$QKTMPDIR"
-writelog "Diskimage:"
-writelog "\tDisk type:\t\t$imgtype"
-writelog "\tDisk file:\t\t$diskfile"
-
-################################################################################
-### Hardware checks
-################################################################################
-
-# memory part equal to vmware plugin
-# percentage of memory to use for virtualbox in standard case
-if [ -n "${forcemem}" ]; then
- mem="${forcemem}"
-else
- permem=30
- if [ "${HOST_MEM_TOTAL}" -ge "1600" ]; then
- permem=40
- fi
-# # check if /tmp is on harddisk
-# if grep -qe "/dev/.* /tmp " /proc/mounts ; then
-# permem=60
-# id44="1"
-# #if [ "${HOST_MEM_TOTAL}" -ge "2500" ]; then
-# #permem=40
-# #rmdir ${snapshotdir}
-# #snapshotdirold=${snapshotdir}
-# #snapshotdir=/dev/shm/${self}/${USER}/${VM_ID}
-# #mkdir -p ${snapshotdir}
-# #ln -sf ${snapshotdir} ${snapshotdirold}
-# #fi
-# fi
- mem=$(expr ${HOST_MEM_TOTAL} / 100 \* ${permem})
- if [ "${id44}" = "1" ]; then
- HOST_MEM_REMAINING=$(expr ${HOST_MEM_TOTAL} - ${VM_MEM})
- else
- HOST_MEM_REMAINING=$(expr ${HOST_MEM_TOTAL} - ${VM_MEM} - ${VM_MEM})
- fi
- # static first
- permem=50
- mem=$(expr ${HOST_MEM_TOTAL} / 100 \* ${permem})
- if [ "${VM_MEM}" -lt "256" ] || [ "${HOST_MEM_REMAINING}" -lt "256" ]; then
- writelog "Memory out of range: ${VM_MEM} MB (guest) / ${HOST_MEM_REMAINING} MB (host)!"
- writelog "Min. 256 MB for host and guest!"
- exit 1
- fi
-fi
-
-VIRTCMDOPTS="${VIRTCMDOPTS} -m ${VM_MEM}"
-
-# network adaptor alternatives: rtl8139, pcnet, e1000
-network_card=${network_card:=pcnet}
-# TODO handle new way of generating MAC addr with prefix/suffix
-# KVM MAC prefix should be 52:54:00
-VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,macaddr=${VM_MAC_ADDR},model=${network_card}"
-
-# define network kind and configure the interfaces
-case "${network_kind}" in
- bridge*)
- VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=kvmnet0${VM_ID}"
- setup_if kvmnet0${VM_ID} br0
- POSTRUN="sudo /opt/openslx/rootfs/sbin/tunctl -d kvmnet0${VM_ID}"
- ;;
- nat)
- VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=kvmnet1${VM_ID}"
- setup_if kvmnet1${VM_ID} nat1
- POSTRUN="sudo /opt/openslx/rootfs/sbin/tunctl -d kvmnet1${VM_ID}"
- ;;
- host*)
- VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=kvmnet2${VM_ID}"
- setup_if kvmnet2${VM_ID} vsw2
- POSTRUN="sudo /opt/openslx/rootfs/sbin/tunctl -d kvmnet2${VM_ID}"
- ;;
- *)
- network_kind="user"
- VIRTCMDOPTS="${VIRTCMDOPTS} -net user"
- ;;
-esac
-
-# translate boot, use if set else set to HardDisk
-if [ -n "${boot}" ]; then
- case ${boot} in
- n*) # usually support for a,c,d,n, stands for Floppy, HD, CD-ROM, Network
- boot="n"
- # TODO: does not work yet, can be removed if tap1 solution better
- if [ "${network_kind}" = "user" ] && [ -n "${virtualbox_tftpdir}" ]; then
- VIRTCMDOPTS="${VIRTCMDOPTS},tftp=${virtualbox_tftpdir}"
- fi
- ;;
- # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM
- *)
- boot="c"
- ;;
- esac
-else
- boot="c"
-fi
-
-# TODO externalize!
-# external GUI port
-vncport="590${VM_ID}"
-
-# ide is expected default, test for the virtual disk image type should
-# be done while creating the runscripts ...
-ide="TRUE"
-hddrv="ide"
-
-# special feature for real and virtual floppy disks
-[ -n "${floppy_0}" ] && VIRTCMDOPTS="${VIRTCMDOPTS} -fda ${FLOPPY_0}"
-VIRTCMDOPTS="${VIRTCMDOPTS} -fdb ${SLX_FLOPPY_IMG}"
-
-# add optical drive if available
-[ -n "${CDROM_0}" ] && VIRTCMDOPTS="${VIRTCMDOPTS} -cdrom ${CDROM_0}"
-
-# audio
-VIRTCMDOPTS="${VIRTCMDOPTS} -soundhw ${SOUND_DEV}"
-
-# serial
-[ "x${serial}" == "xttyS0" ] && VIRTCMDOPTS="${VIRTCMDOPTS} -serial /dev/ttyS0"
-
-writelog "Virtual Hardware:"
-writelog "\tGuest RAM:\t\t${VM_MEM} MB"
-# echo nur wenn HOST_MEM_REMAINING gesetzt
-[ -n "${HOST_MEM_REMAINING}" ] && writelog "\tHost RAM:\t\t${HOST_MEM_REMAINING} MB"
-writelog "\tMAC address:\t\t${VM_MAC_ADDR}"
-writelog "\tNetwork card:\t\t${network_card}"
-writelog "\tNetwork kind:\t\t${network_kind}"
-writelog "\tCD-ROM1:\t${CDROM_0}"
-#writelog "\tCD-ROM2:\t${cdrom1}"
-writelog "\tFloppy_A:\t${FLOPPY_0}"
-writelog "\tFloppy_B:\t${SLX_FLOPPY_IMG}"
-#writelog "\tShared Folders 'home':\t/home/${USER}"
-
-################################################################################
-### finally set env for run-virt.sh
-################################################################################
-
-# using snapshots
-VIRTCMDOPTS="${VIRTCMDOPTS} -snapshot"
-
-# TODO: boot als var, -boot n, tftp...
-VIRTCMDOPTS="${VIRTCMDOPTS} -boot c"
-
-# set headless mode
-# define first, you do not want VIRTCMDOPTS from graphical start
-VIRTCMDHL=${VIRTCMD}
-VIRTCMDOPTSHL="${VIRTCMDOPTS} -nographic ${diskfile}"
-
-# graphical start
-# vga std/cirrus/vmware?
-#VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen ${diskfile}"
-VIRTCMDOPTS="${VIRTCMDOPTS} ${diskfile}"
diff --git a/core/modules/qemukvm/module.build b/core/modules/qemukvm/module.build
index f393e689..afa58c7b 100644
--- a/core/modules/qemukvm/module.build
+++ b/core/modules/qemukvm/module.build
@@ -13,5 +13,5 @@ build() {
}
post_copy() {
- :
+ find ${TARGET_BUILD_DIR} -type f -executable -name "*qemu-bridge-helper*" -exec chmod u+s {} \;
}
diff --git a/core/modules/qemukvm/module.conf b/core/modules/qemukvm/module.conf
index 60d6fe5c..594c7918 100644
--- a/core/modules/qemukvm/module.conf
+++ b/core/modules/qemukvm/module.conf
@@ -1,12 +1,5 @@
#!/bin/bash
+REQUIRED_MODULES="kernel"
REQUIRED_DIRECTORIES="
- /etc
- /lib
- /usr/bin
- /usr/sbin
- /usr/lib
- /usr/share/lintian
- /usr/share/qemu
- /usr/share/seabios
- /usr/share/vgabios
+ /
"
diff --git a/core/modules/qemukvm/module.conf.ubuntu b/core/modules/qemukvm/module.conf.ubuntu
index e87645d9..1f086367 100644
--- a/core/modules/qemukvm/module.conf.ubuntu
+++ b/core/modules/qemukvm/module.conf.ubuntu
@@ -2,38 +2,16 @@
REQUIRED_INSTALLED_PACKAGES="
qemu
qemu-kvm
- vgabios
"
REQUIRED_CONTENT_PACKAGES="
qemu
qemu-kvm
- ipxe-qemu
qemu-keymaps
qemu-system
- qemu-system-arm
qemu-system-common
- qemu-system-mips
- qemu-system-misc
- qemu-system-ppc
- qemu-system-sparc
qemu-system-x86
qemu-user
qemu-utils
seabios
- vgabios
- cpu-checker
- kvm-ipxe
- libaio1
- libboost-thread1.49.0
- libfdt1
- librados2
- librbd1
- libsdl1.2debian
- libseccomp1
- libspice-server1
- libxen-4.2
- libxenstore3.0
- msr-tools
- sharutils
"