summaryrefslogtreecommitdiffstats
path: root/remote/modules/vmchooser/data
diff options
context:
space:
mode:
Diffstat (limited to 'remote/modules/vmchooser/data')
-rwxr-xr-xremote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env6
-rwxr-xr-xremote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt46
2 files changed, 46 insertions, 6 deletions
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env
index 50eace20..4119ad9c 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env
@@ -91,7 +91,11 @@ if grep -q ^flags.*\\\<vmx\\\> /proc/cpuinfo; then
fi
# write mac
-echo "hostmacaddr=${SLX_PXE_MAC}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf
+if [ -n "$SLX_PXE_MAC" ]; then
+ echo "hostmacaddr=${SLX_PXE_MAC}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf
+else ## Fallback:
+ echo "hostmacaddr=$(ip a | grep ether | grep -o -E -i '([0-9a-f]{2}:){5}[0-9a-f]{2}' | head -n 1)" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf
+fi
# ip addr
echo "hostip=${SLX_PXE_CLIENT_IP}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf
# hostname
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
index 979db35a..f6e4e491 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
@@ -23,11 +23,11 @@
################################################################################
# include general configuration from vmchooser
-[ -f /opt/openslx/etc/vmchooser/vmchooser.conf ] && \
-. /opt/openslx/etc/vmchooser/vmchooser.conf
+[ -f /opt/openslx/etc/vmchooser/vmchooser.conf ] && . /opt/openslx/etc/vmchooser/vmchooser.conf
# load general virtualization information
-[ -f /opt/openslx/etc/vmchooser/virtualization.conf ] && \
-. /opt/openslx/etc/vmchooser/virtualization.conf
+[ -f /opt/openslx/etc/vmchooser/virtualization.conf ] && . /opt/openslx/etc/vmchooser/virtualization.conf
+# Load general openslx config
+[ -f /opt/openslx/config ] && . /opt/openslx/config
################################################################################
### Functions used throughout the script
@@ -359,8 +359,9 @@ hostmem="$[ $totalmem - $mem ]"
# last two bytes are taken from the bridge of the host
# define one MAC per guest
macguestpart="00:50:56:${VM_ID}"
-machostpart=$(echo ${hostmacaddr} | awk -F ":" '{print $(NF-1)":"$NF}')
+machostpart=$(echo "${hostmacaddr}" | awk -F ":" '{print $(NF-1)":"$NF}')
macaddr=$(echo "${macguestpart}:${machostpart}" | tr "[a-z]" "[A-Z]")
+macaddrsuffix=$(echo "${VM_ID}:${machostpart}" | tr "[a-z]" "[A-Z]")
# Virtual fd/cd/dvd and drive devices, floppy b: for configuration
# if $floppy_0 from run-virt.include set then fdtest="TRUE"
@@ -432,6 +433,32 @@ cp "$xmlfile" "/opt/openslx/etc/vmchooser/fd-loop/config.xml"
# Add another file with resolution information
xrandr | grep -o -E 'current\s*[0-9]+\s*x\s*[0-9]+' | cut -c 8- | sed -r 's/(\s|\t|\n)//g' | head -n 1 > "/opt/openslx/etc/vmchooser/fd-loop/hostres.txt"
+# Try to use dnbd3 to access the image
+unset vm_diskfile
+unset vm_revision
+unset dnbd3
+if [ -n "$SLX_DNBD3_SERVERS" ]; then
+ if [ -e "/dev/dnbd0" -a -e "/var/run/dnbd3.socket" ]; then
+ for SRV in $SLX_DNBD3_SERVERS; do
+ dnbd3=$(dnbd3-client -h "$SRV" -i "${vmpath#/mnt/vmstore/}" -r 0)
+ RET=$?
+ if [ "$RET" = "0" ]; then
+ vm_diskfile="$dnbd3"
+ vm_revision=$(cat "/sys/block/${dnbd3#/dev/}/net/rid")
+ writelog "DNBD3: $vm_diskfile on $dnbd3 with rid $vm_revision"
+ break
+ fi
+ done
+ [ -z "$vm_diskfile" ] && writelog "No working dnbd3 server found :-("
+ else
+ writelog "Won't use dnbd3 as it's not loaded, or the daemon is not running..."
+ fi
+else
+ writelog "Won't use dnbd3 as no servers are given in config"
+fi
+[ -z "$vm_diskfile" ] && vm_diskfile="$vmpath"
+writelog "Used diskfile: $vm_diskfile"
+
# Get all virtual machine specific stuff from the respective include file
if [ -e /opt/openslx/etc/"${xmlvirt}"/run-virt.include ] ; then
self="${xmlvirt}"
@@ -463,6 +490,15 @@ if [ -e /opt/openslx/etc/"${xmlvirt}"/run-virt.include ] ; then
if [ -n "${POSTRUN}" ]; then
eval ${POSTRUN} >/dev/null 2>&1
fi
+
+ # Disconnect dnbd3 device
+ if [ -n "$dnbd3" ]; then
+ for timeout in 1 1 2; do
+ dnbd3-client -c "$dnbd3" && break
+ writelog "dnbd3 still busy...."
+ sleep "$timeout"
+ done
+ fi
cleanexit 0
else