diff options
3 files changed, 55 insertions, 0 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env index 6a30acf4..ddffa4e9 100755 --- a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env +++ b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env @@ -143,6 +143,11 @@ for FLOPPY in $(dmesg|grep -i "Floppy drive"|sed "s,.*(s): ,,;s, is .*,,"); do j=$(expr $j + 1) done +# Serial ports +echo "SERIAL_PORTS='$(dmesg | grep -Eo 'ttyS[0-9]+' | sed 's,^,/dev/,' | tr '\n' ' ')'" >> "${VMCHOOSER_VIRT_CONF}" +# Parallel ports +modprobe parport_pc + ################################################################################ ### Setup VM networking ################################################################################ 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 e4a1353f..a2eb18f0 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 @@ -105,11 +105,34 @@ check_optical_drives() { readonly FLOPPY0 CDROM0 CDROM1 } +# Dynamically detect serial ports here instead of at boot time +# (virtualization.conf), since USB serial ports get quite common +# and might not be plugged in at boot time yet +set_serial_ports() { + declare -g SERIAL0= + #for port in $(awk '{ if ($1 ~ /^[0-9]+:/ && $2 != "uart:unknown") print "/dev/ttyS" sub(/:\$/, "", $1) }' /proc/tty/driver/serial); do + for PORT in $SERIAL_PORTS /dev/ttyUSB*; do + [ -c "$PORT" ] || continue + SERIAL0="$PORT" + break + done + + declare -g PARALLEL0= + for PORT in /dev/parport*; do + [ -c "$PORT" ] || continue + PARALLEL0="$PORT" + break + done + + readonly SERIAL0 PARALLEL0 +} + ## MAIN ## call_post_source \ set_virt_cpu \ set_virt_memory \ set_virt_mac \ set_virt_hostname \ + set_serial_ports \ check_optical_drives diff --git a/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc b/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc index 247efd03..94996ff1 100644 --- a/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc +++ b/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc @@ -56,6 +56,32 @@ setup_floppies() { HEREEND } +setup_serial() { + # Serial port + if [ -n "$SERIAL0" ]; then + cat >> "${TMPCONFIG}" <<-HEREEND + serial0.present = "TRUE" + serial0.startConnected = "TRUE" + serial0.fileType = "device" + serial0.fileName = "$SERIAL0" + serial0.tryNoRxLoss = "FALSE" + serial0.autodetect = "FALSE" + HEREEND + fi + + # Parallel port + if [ -n "$PARALLEL0" ]; then + cat >> "${TMPCONFIG}" <<-HEREEND + parallel0.present = "TRUE" + parallel0.startConnected = "TRUE" + parallel0.fileType = "device" + parallel0.fileName = "$PARALLEL0" + parallel0.bidirectional = "TRUE" + parallel0.autodetect = "FALSE" + HEREEND + fi +} + # CPU and RAM setup_vcpu_ram() { #writelog "numvcpus = ${CPU_CORES} - maxvcpus=${HOST_CORE_COUNT}" @@ -213,6 +239,7 @@ write_final_vmx() { setup_ethernet setup_optical_drives setup_floppies + setup_serial setup_vcpu_ram setup_usb [ "x$HGFS_DISABLED" = "xFALSE" ] && setup_shared_folders |