diff options
author | Jonathan Bauer | 2019-07-17 10:31:37 +0200 |
---|---|---|
committer | Jonathan Bauer | 2019-07-17 10:31:37 +0200 |
commit | 8cd22fd7b69df208d6611013de0fe4e3c34ebaae (patch) | |
tree | c9138e7011bc9195ea415c4d14cf8763aaeded46 | |
parent | Merge branch 'master' into installer (diff) | |
parent | [rootfs-stage31] tarcopy: Ignore directories (diff) | |
download | mltk-8cd22fd7b69df208d6611013de0fe4e3c34ebaae.tar.gz mltk-8cd22fd7b69df208d6611013de0fe4e3c34ebaae.tar.xz mltk-8cd22fd7b69df208d6611013de0fe4e3c34ebaae.zip |
Merge branch 'master' into installer
18 files changed, 204 insertions, 176 deletions
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 index becb2a80..890f956e 100644 --- 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 @@ -18,67 +18,62 @@ set_vm_hw_limits() { # 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= + local bits=64 case "${VM_OS_TYPE}" in beos*) - VIRTCMD="qemu-system-i386" - VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg" + bits=32 SOUND_DEV="sb16" ;; win3*|win*3*|Win*3*) - VIRTCMD="qemu-system-i386" - VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg" + bits=32 SOUND_DEV="sb16" MAXMEM=32 ;; win95*|Win*95) - VIRTCMD="qemu-system-i386" - VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg" + bits=32 MAXMEM=96 ;; win98) - VIRTCMD="qemu-system-i386" - VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg" + bits=32 MAXMEM=256 ;; winme*|windowsme*) - VIRTCMD="qemu-system-i386" - VIRTCMDOPTS="${VIRTCMDOPTS} -machine accel=tcg" + bits=32 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" + 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 -rg HOST_CORE_COUNT="${CPU_CORES}" 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 index a458f255..6d9df363 100644 --- 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 @@ -21,27 +21,27 @@ finalize_start_command() { # set cpu type - VIRTCMDOPTS="${VIRTCMDOPTS} -cpu host" + VIRTCMDOPTS+=( "-cpu" "host" ) # set cpu cores - VIRTCMDOPTS="${VIRTCMDOPTS} -smp ${CPU_CORES}" + VIRTCMDOPTS+=( "-smp" "${CPU_CORES}" ) # set RAM - VIRTCMDOPTS="${VIRTCMDOPTS} -m ${VM_MEM}" - + 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}" - + 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="${VIRTCMDOPTS} -cdrom ${CDROM_0}" - + isset CDROM_0 && VIRTCMDOPTS+=( "-cdrom" "${CDROM_0}" ) + # audio - isset SOUND_DEV && VIRTCMDOPTS="${VIRTCMDOPTS} -soundhw ${SOUND_DEV}" - + isset SOUND_DEV && VIRTCMDOPTS+=( "-soundhw" "${SOUND_DEV}" ) + # serial devices TODO test if isset SERIAL_PORTS; then for DEV in $SERIAL_PORTS; do - : # buggeh: VIRTCMDOPTS="${VIRTCMDOPTS} -serial ${DEV}" + : # buggeh: VIRTCMDOPTS+=( "-serial" "${DEV}" ) done fi } 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 index 7666bedd..fee2cd1c 100644 --- 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 @@ -40,15 +40,15 @@ fi # 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}" +VIRTCMDOPTS+=( "-name" "${CMD_DISPLAYNAME}" ) # graphical start: vga, vmware, qxl, spice? -VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen" +VIRTCMDOPTS+=( "-vga" "std" "-full-screen" ) # hot keys ALT+CTRL+SHIFT (does not work properly!?) -VIRTCMDOPTS="${VIRTCMDOPTS} -alt-grab" +VIRTCMDOPTS+=( "-alt-grab" ) # TODO support other types of boot? any usecase for network boot? # for now just boot from disk -VIRTCMDOPTS="${VIRTCMDOPTS} -boot c" +VIRTCMDOPTS+=( "-boot" "c" ) 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 index 13fcbdf2..73fb2518 100644 --- 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 @@ -13,7 +13,7 @@ setup_network() { declare -rg NIC_MODEL="e1000" # add MAC address and network card model - VIRTCMDOPTS="${VIRTCMDOPTS} -device ${NIC_MODEL},mac=${VM_MAC_ADDR},netdev=guestnet0" + 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" @@ -37,18 +37,18 @@ setup_network() { 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" - ;; + 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 } 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 index e066a55c..32637e5d 100644 --- 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 @@ -7,15 +7,18 @@ setup_rw_layer() { # 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="${VIRTCMDOPTS} -drive if=virtio,format=qcow2,file=${VM_DISKFILE_RW}" + 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" + # How is this supposed to even work without a disk? + VIRTCMDOPTS+=( "-snapshot" ) fi } diff --git a/core/modules/run-virt/README b/core/modules/run-virt/README index d3368ede..f009f55a 100644 --- a/core/modules/run-virt/README +++ b/core/modules/run-virt/README @@ -1,4 +1,86 @@ -Configuring run-virt: +Attempt at documenting run-virt. + +Note that lecture and VM are often used interchangeably here and in the +actual run-virt scripts. + +-------------------- +### Global constants +-------------------- + +These constants are globally defined in the run-virt environment and are read-only. + +# $CONFDIR +This is where the downloaded metadata for the VM to be run is located. +Contains the VM hw description (virtualizer specific), network shares to +mount, startup scripts, ... + +# $DEBUG +Set to either "true" or "false" so it can simply be used like this: +if $DEBUG; then .... + +# $IMGUUID +The UUID of this VM/lecture, extracted from the passed $XMLFILE. +Used to fetch meta data for the VM, like vmx, netrules, netshares, etc. + +# $LOGFILE +Log file for run-virt. You shouldn't need to access this file directly but +rather use the "writelog" function. + +# $PLUGIN_ID +Name of the virtualizer plugin required to run the current VM, e.g. +vmware or virtualbox. This is used to source the according scripts +from $VMCHOOSER_DIR/plugins/$PLUGIN_ID/* + +# $SELF +Absolute path to the main run-virt script. Should usually be +/opt/openslx/vmchooser/vmchooser-run_virt + +# $SRC_IMG_ABSOLUTE +Absolute path to the VMs HDD image. When using DNBD3, which requires +$SRC_IMG_RELATIVE to be set, this file might not actually exist. +This can be empty if $SRC_IMAGE_RELATIVE is given. + +# $SRC_IMG_RELATIVE +Relative path to the VMs HDD image. Used for DNBD3, or for constructing +the absolute path in case it's not supplied via the $XMLFILE, but +$VMSTORE_PATH is known. +This can be empty if $SRC_IMG_ABSOLUTE is given. + +# $TMPDIR +Temporary directory to work in. Create single files, or if you feel like you +need a bunch of them, group within a subdirectory. This will be wiped on exit. + +# $USER +Name of the currently logged in user. This doesn't necessarily match the +name on the auth server (LDAP/AD) but rather what the running Linux system sees. + +# $VMCHOOSER_CONF_DIR +Config dir of run-virt, where several (sourcable) files are located. + +# $VMCHOOSER_DIR +Base directory of run-virt/vmchooser, usually /opt/openslx/vmchooser + +# $VMSTORE_PATH +Currently hard-coded to /mnt/vmstore via run-virt-includes/get_xml_file_variables.inc. +In case VMs are read via CIFS/NFS, this is where it should be mounted. + +# $VM_CLEANNAME +"Clean" version of $VM_DISPLAYNAME, no spaces or special chars except +'_', '-' and '.', 32 chars max. + +# $VM_DISPLAYNAME +Name of the VM as shown to the user, and displayed in vmchooser. + +# $VM_OS_TYPE +Name of the VMs operating system as known to the virtualizer in use. +This should not exist but does for complicated reasons. + +# $XMLFILE +XML description file of VM session to be run. Passed via command line. + +------------------------ +### Configuring run-virt +------------------------ ## /opt/openslx/vmchooser/config/resource_urls.conf @@ -56,4 +138,4 @@ Note that this is a floppy, not the cloud, so you're limited to 1.44MB of storag # image-access.d/ 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.
\ No newline at end of file +expected to set either VM_DISKFILE_RO or VM_DISKFILE_RW, depending on desired access. diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc index 7bf07458..ff5c736c 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc @@ -37,7 +37,9 @@ parse_xml() { EXIT_TYPE="user" EXIT_REASON="Ungültiger asboluter Pfad zur virtuellen Maschine!" cleanexit 1 fi - notempty SRC_IMG_ABSOLUTE || SRC_IMG_ABSOLUTE="${VMSTORE_PATH}/${SRC_IMG_RELATIVE}" + if isempty SRC_IMG_ABSOLUTE && notempty VMSTORE_PATH; then + SRC_IMG_ABSOLUTE="${VMSTORE_PATH}/${SRC_IMG_RELATIVE}" + fi readonly SRC_IMG_ABSOLUTE declare -rg IMG_BASENAME=$(basename "$SRC_IMG_ABSOLUTE") diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/init_core.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/init_core.inc index 79b2ddd1..97d08440 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/init_core.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/init_core.inc @@ -11,14 +11,15 @@ fi # Check that /tmp/virt is not in RAM. # Either mounted directly (e.g. NFS) or backed by hdd mounted /tmp. -# This variable is empty (but set!) if /tmp/virt isn't backed at all -# else it will be non-empty (check with helper function 'notempty'). -declare -g TMPDIR_NOT_RAM= -if ! dir_on_tmpfs /tmp/virt ; then +# This variable will be true or false +declare -g TMPDIR_IN_RAM=false +if fs_path_isvolatile /tmp/virt ; then + TMPDIR_IN_RAM=true + writelog "/tmp/virt is in RAM, will allocate little RAM to VMs." +else writelog "/tmp/virt is not in RAM, will allocate more RAM to VMs." - TMPDIR_NOT_RAM=1 - readonly TMPDIR_NOT_RAM fi +readonly TMPDIR_IN_RAM # Get a unique VM_ID for the current invocation get_vm_id diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc index c3a5009f..414c654a 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc @@ -31,24 +31,28 @@ set_virt_memory() { EXIT_TYPE="internal" EXIT_REASON="Konnte die Größe des Arbeitsspeichers nicht ermitteln!" cleanexit 1 fi - # Amount of memory for the VM. Be generous if diff is written to HDD + # Calculare amount of memory for the VM. Be generous if diff is written to HDD. + # First, determine how much should be left to the host system. Minimum is 1GB. local min=1024 local reserve max - if notempty TMPDIR_NOT_RAM; then + if $TMPDIR_IN_RAM; then + # tmp in RAM, so reserve a lot for the system since that is where the HDD diff goes. + reserve=65 + max=8192 # But max. 8GB + else + # We have a backing store for the HDD diff, be generous if lsmod | grep -q '^nvidia'; then + # With nvidia cards, the host needs a bit more RAM. max=2800 reserve=28 else max=1800 reserve=21 fi - else - reserve=65 - max=8192 fi # Calculate absulute amount of RAM that should stay available to the host - local reserve="$(( ( HOST_MEM_TOTAL * reserve ) / 100 ))" + reserve="$(( ( HOST_MEM_TOTAL * reserve ) / 100 ))" # Respect some upper and lower bounds for the host amount [ "$reserve" -lt "$min" ] && reserve="$min" [ "$reserve" -gt "$max" ] && reserve="$max" diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc index b10623be..fad51c5d 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc @@ -13,7 +13,6 @@ # indicate to the virt plugin that it doesn't need to # handle creating a temporary CoW layer itself. - # Helper to cleanup the image mounted with dnbd3-fuse cleanup_dnbd3() { if ! isset DNBD3_MOUNT_POINT; then @@ -21,7 +20,8 @@ cleanup_dnbd3() { return 1 fi # try to umount it now - for timeout in 1 1 1 FAIL; do + for timeout in 1 1 1 2 2 3 FAIL; do + fs_path_ismountpoint "${DNBD3_MOUNT_POINT}" || break fusermount -u "${DNBD3_MOUNT_POINT}" && break writelog "dnbd3 still busy...." [ "$timeout" = "FAIL" ] && break @@ -86,7 +86,6 @@ setup_image_access() { writelog "Setting up virtual hard disk access for virtualizer/emulator ..." unset VM_DISKFILE_RO VM_DISKFILE_RW declare -g VM_DISKFILE_RO VM_DISKFILE_RW - run_hooks "image-access" if [ -n "$VM_DISKFILE_RW" ]; then diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc index aaace562..08ab4f72 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc @@ -29,15 +29,19 @@ get_vm_id() { ################# LOGGING FUNCTIONS ################## # Helper function to write to stdout and logfile writelog() { - local DATE=$(date +%Y-%m-%d-%H-%M-%S) + local DATE="$(date +%Y-%m-%d-%H-%M-%S)" # write to stdout? if [ "x$1" = "x--quiet" ]; then shift else - echo -e "$DATE: $@" + echo -e "$DATE: $*" fi # log into file - echo -e "$DATE: ${SLX_DEBUG:+(${FUNCNAME[1]}) }$@" >> "${LOGFILE}" + if $DEBUG; then + echo -e "$DATE: (${FUNCNAME[1]}) $*" >> "${LOGFILE}" + else + echo -e "$DATE: $*" >> "${LOGFILE}" + fi } # Helper function to notify the user. @@ -120,8 +124,9 @@ add_cleanup() { # EXIT_REASON should contain a user-friendly message to print to the user. # it can be prefixed with err.\S+, which will serve as a translation identifier cleanexit() { + trap "" SIGHUP SIGINT SIGTERM EXIT writelog "Cleanexit '$1' triggered by '${BASH_SOURCE[1]}:${FUNCNAME[1]}'" - sleep 1 + usleep 250000 while isset CLEANUP_TASKS; do local TASK=${CLEANUP_TASKS[-1]} unset -v CLEANUP_TASKS[-1] @@ -133,9 +138,13 @@ cleanexit() { writelog "Failed to run cleanup function '$TASK'! Exit code: $RET" fi done + usleep 250000 + + # kill potential remaining background jobs + kill $(jobs -p) # If we're not in debug mode, remove all temporary files - if notempty SLX_DEBUG && isset TMPDIR; then + if ! $DEBUG && notempty TMPDIR; then rm -rf -- "${TMPDIR}" fi @@ -174,12 +183,6 @@ cleanexit() { ERR_TEXT="Unbekannter Fehler" fi - # first send the logfile (in case the user does not close the error before using magic keys e.g.) - # for any other error types besides 'user'. Do no slxlog if we run wrapped (from /opt/openslx/scripts/vmchooser-run_virt) - if [ "x${EXIT_TYPE}" != "xuser" ]; then - writelog "Critical error happened in '${BASH_SOURCE[1]}:${FUNCNAME[1]}'" - fi - # finally display the error error_user "${ERR_TITLE}" " ${ERR_TEXT} @@ -228,7 +231,7 @@ translate() { run_hooks() { local dir file retval r declare -a files - dir="$BASEDIR/hooks/${1}.d" + dir="$VMCHOOSER_DIR/hooks/${1}.d" [ -d "$dir" ] || return 100 shift files=( "${dir}"/* ) @@ -496,33 +499,6 @@ clean_string() { fi } -# Helper to check whether given directory resides in RAM, either -# by being mounted as tmpfs or not mounted at all in which case -# we assume the same. Returns 0 if so, 1 otherwise. -dir_on_tmpfs() { - local current_dir="$1" - while [ -n "$current_dir" ]; do - local mount_line="$(awk -v dir="$current_dir" '$2 == dir' /proc/mounts)" - if [ -z "$mount_line" ]; then - # check its parent directory - current_dir="${current_dir%/*}" - continue - fi - [ "x$(cut -d' ' -f3 <<< ${mount_line})" == "xtmpfs" ] - return $? - done - # NG: check if / is fully backed by hard drive - local dmsetup_state="/run/openslx/dmsetup.state" - if [ -s "$dmsetup_state" ]; then - local dnbd3_cow_dev="$SLX_DNBD3_DEVICE_COW" - [ -z "$dnbd3_cow_dev" ] && dnbd3_cow_dev="/dev/mapper/root" - grep -qE "^${dnbd3_cow_dev}\s+/\s+type=0" "$dmsetup_state" - return $? - fi - # else assume old-gen were / was in RAM - return 0 -} - # Helper to detect given cpu flags. # If more than one flag is given, assume that matching # any of them is sufficient. 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 f545145b..a2d0f3cb 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 @@ -29,16 +29,22 @@ if [ -z "$SELF" ] || ! [ -f "$SELF" ]; then fi readonly SELF -# Useless without this -. /opt/openslx/config - # Global variables needed for the core functionality -declare -rg VMCHOOSER_DIR="/opt/openslx/vmchooser" +declare -rg VMCHOOSER_DIR="$( dirname "$SELF" )" declare -rg VMCHOOSER_CONF_DIR="$VMCHOOSER_DIR/config" declare -rg USER="$(whoami)" declare -rg TMPDIR="/tmp/virt/${USER}/$$" declare -rg CONFDIR="${TMPDIR}/metadata" +if ! [ -d "$VMCHOOSER_DIR" ]; then + slxlog "run-virt" "$SELF is not in a directory!?" + exit 1 +fi + +# Useless without this +. /opt/openslx/config +. /opt/openslx/bin/slx-tools + # Debug mode? if [ "x$1" = "x--debug" ]; then shift @@ -48,6 +54,7 @@ elif [ "$SLX_DEBUG_MODE" = "ON" ] || grep -qE '\bdebug\b' "/proc/cmdline"; then else DEBUG=false fi +readonly DEBUG # Check for existence of plugin if [ "x$1" = "x--query" ]; then @@ -72,21 +79,23 @@ declare -rg XML_FILE="$1" # A path to the logfile can be given as second argument declare -g LOGFILE="$2" if [ -z "$LOGFILE" ] || ! touch "$LOGFILE" || ! [ -f "$LOGFILE" ]; then - LOGFILE="/var/log/openslx/run-virt.$(whoami).$$.log" + LOGFILE="/var/log/openslx/run-virt.${USER}.$$.log" touch "$LOGFILE" || LOGFILE="$(mktemp)" fi +readonly LOGFILE main() { # Functions needed by vmchooser-run_virt (writelog(), cleanexit(), safesource()) - BASEDIR="$( dirname "${SELF}" )" - RUN_VIRT_INCLUDE_DIR="${BASEDIR}/run-virt-includes" - readonly BASEDIR RUN_VIRT_INCLUDE_DIR + declare -rg RUN_VIRT_INCLUDE_DIR="${VMCHOOSER_DIR}/run-virt-includes" if ! source "${RUN_VIRT_INCLUDE_DIR}/vmchooser_runvirt_functions.inc"; then slxlog "run-virt" "Could not source ${RUN_VIRT_INCLUDE_DIR}/vmchooser_runvirt_functions.inc" exit 1 fi - trap 'trap "" SIGINT SIGTERM; cleanexit' SIGINT SIGTERM + trap 'cleanexit $?' EXIT + trap 'cleanexit 129' SIGHUP + trap 'cleanexit 130' SIGINT + trap 'cleanexit 143' SIGTERM # Starting sourcing the includes files. Note that the critical ones should use # the '--exit' option of safesource to trigger cleanexit in case of a corrupted/bad @@ -151,6 +160,9 @@ main() { notify_user "Feature '$FEAT' nicht unterstützt" fi done + # Prepare array for the command line options + unset VIRTCMDOPTS + declare -a VIRTCMDOPTS # The features should now be initialized, call the main 'run_plugin' function of the hypervisor writelog "#################### Plugin run: $PLUGIN_ID ####################" writelog "Calling 'run_plugin' of '$PLUGIN_ID'..." @@ -165,15 +177,14 @@ main() { cleanexit 1 fi - writelog "VM command: ${VIRTCMD} ${VIRTCMDOPTS}" + writelog "VM command: ${VIRTCMD} ${VIRTCMDOPTS[*]}" # This will start the VM (no eval needed!) - ${VIRTCMD} ${VIRTCMDOPTS} + "${VIRTCMD}" "${VIRTCMDOPTS[@]}" writelog "Virtualizer exited with '$?'. Bye." cleanexit 0 } - # Detach main & RUNVIRT_PID="$!" diff --git a/core/modules/sshd/data/etc/ssh/sshd_config b/core/modules/sshd/data/etc/ssh/sshd_config index 32e34d8d..7c077bbe 100644 --- a/core/modules/sshd/data/etc/ssh/sshd_config +++ b/core/modules/sshd/data/etc/ssh/sshd_config @@ -1,26 +1,12 @@ -# Package generated configuration file -# See the sshd_config(5) manpage for details - # Only use IPv4 stack. Using IPv6 breaks X11 forwarding # as sshd won't be able to create an IP socket with following message: # error: Failed to allocate internet-domain X11 display socket. AddressFamily inet # What ports, IPs and protocols we listen for Port 22 -# Use these options to restrict which interfaces/protocols sshd will bind to -#ListenAddress :: -#ListenAddress 0.0.0.0 -Protocol 2 -# HostKeys for protocol version 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key -#Privilege Separation is turned on for security -UsePrivilegeSeparation yes - -# Lifetime and size of ephemeral version 1 server key -KeyRegenerationInterval 3600 -ServerKeyBits 768 # Logging SyslogFacility AUTH @@ -31,19 +17,13 @@ LoginGraceTime 30 PermitRootLogin yes StrictModes yes -RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile %h/.ssh/authorized_keys # Don't read the user's ~/.rhosts and ~/.shosts files IgnoreRhosts yes -# For this to work you will also need host keys in /etc/ssh_known_hosts -RhostsRSAAuthentication no # similar for protocol version 2 HostbasedAuthentication no -# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication -#IgnoreUserKnownHosts yes - # To enable empty passwords, change to yes (NOT RECOMMENDED) PermitEmptyPasswords no @@ -51,27 +31,12 @@ PermitEmptyPasswords no # some PAM modules and threads) ChallengeResponseAuthentication no -# Change to no to disable tunnelled clear text passwords -#PasswordAuthentication yes - -# Kerberos options -#KerberosAuthentication no -#KerberosGetAFSToken no -#KerberosOrLocalPasswd yes -#KerberosTicketCleanup yes - -# GSSAPI options -#GSSAPIAuthentication no -#GSSAPICleanupCredentials yes - X11Forwarding yes X11DisplayOffset 10 PrintMotd no PrintLastLog yes TCPKeepAlive yes -#UseLogin no -#MaxStartups 10:30:60 Banner /etc/issue.net # Allow client to pass locale environment variables @@ -79,15 +44,6 @@ AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server -# Set this to 'yes' to enable PAM authentication, account processing, -# and session processing. If this is enabled, PAM authentication will -# be allowed through the ChallengeResponseAuthentication and -# PasswordAuthentication. Depending on your PAM configuration, -# PAM authentication via ChallengeResponseAuthentication may bypass -# the setting of "PermitRootLogin without-password". -# If you just want the PAM account and session checks to run without -# PAM authentication, then enable this but set PasswordAuthentication -# and ChallengeResponseAuthentication to 'no'. UsePAM yes # OpenSLX diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/run-virt.include b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/run-virt.include index 5ac7ab51..bca5c250 100755 --- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/run-virt.include +++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/run-virt.include @@ -42,11 +42,11 @@ run_plugin() { # set the variables appropriately (several interfaces with different names) declare -rg VIRTCMD="${VBOX_BASE_DIR}/VirtualBoxVM" - declare -rg VIRTCMDOPTS="--startvm ${MACHINE_UUID} --start-running --fullscreen" + VIRTCMDOPTS+=( "--startvm" "${MACHINE_UUID}" "--start-running" "--fullscreen" ) - # set headless mode (-v off to disable vrdp) - declare -rg VIRTCMDHL="${VBOX_BASE_DIR}/VBoxHeadless" - declare -rg VIRTCMDOPTSHL="-s ${MACHINE_UUID}" + # set headless mode (-v off to disable vrdp) XXX currently not supported/used + #declare -rg VIRTCMDHL="${VBOX_BASE_DIR}/VBoxHeadless" + #declare -rg VIRTCMDOPTSHL="-s ${MACHINE_UUID}" # for debugging purposes cp "$VBOX_MACHINE_CONFIG" "/tmp/vbox-last-config.$USER" diff --git a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/init_core.inc b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/init_core.inc index 2aba4cdf..8a71a21b 100644 --- a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/init_core.inc +++ b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/init_core.inc @@ -46,10 +46,6 @@ fi [ -n "$gmax" ] && maxhardwareversion="$gmax" -# VMware start options -# "-X": start in fullscreen -declare -rg VM_START_OPTIONS="-X" - # create vmware directories mkdir -p "$VM_REDO_DIR" >/dev/null 2>&1 mkdir -p "$VM_CONF_DIR" >/dev/null 2>&1 diff --git a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/run-virt.include b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/run-virt.include index e98595b7..33d9de29 100644 --- a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/run-virt.include +++ b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/run-virt.include @@ -58,5 +58,6 @@ run_plugin() { # HACK: using the modified version of the wrapper script declare -rg VIRTCMD="/opt/openslx/bin/vmplayer" - declare -rg VIRTCMDOPTS="${VM_START_OPTIONS} ${VM_RUN_FILE}" + # -X for fullscreen, plus VMX file + VIRTCMDOPTS+=( "-X" "${VM_RUN_FILE}" ) } diff --git a/core/rootfs/rootfs-stage31/data/inc/functions b/core/rootfs/rootfs-stage31/data/inc/functions index 6edbeffb..a4ad56db 100644 --- a/core/rootfs/rootfs-stage31/data/inc/functions +++ b/core/rootfs/rootfs-stage31/data/inc/functions @@ -93,6 +93,8 @@ bench_event() { tarcopy() { [ -d "$1" -a -d "$2" ] || return 1 cd "$1" - tar -cp * | tar -xp -C "$2" + find . \! -type d > /tmp/tctmp + tar -c -p -T /tmp/tctmp | tar -xp -C "$2" + rm -f -- /tmp/tctmp cd - &>/dev/null } @@ -165,7 +165,7 @@ read_params() { # for a GUI, you could add: # - xorg # - kdm - # - plymouth + # - plymouth TARGET="" if [[ "$1" != -* ]]; then TARGET="$1" |