13. Graphics (Desktop) configuration

What graphical output the user will see can be configured according to the respective needs.
While during development showing the Hypervisor Host desktop (the Linux desktop) is very convenient this typically is not wanted when the system is shipped to customers.

13.1. Display both, Host and Guest Desktop

This is the default configuration after installation of the RTOSVisor.

13.2. Display Guest Desktop only

When shipping the system to customers you may want to only display the guest desktop in full screen (= kiosk) mode. If kiosk mode is enabled, the Windows (or Ubuntu) guest will run in full screen mode without the option to switch back to the Hypervisor Host desktop.

13.2.1. Guest autostart

In a production environment, the whole application should be started automatically after powering on the system.

  • How to automatically start guests, see section Automatic guest startup.

  • The section Standalone console mode describes how to automatically start one of the guests showing its desktop in full screen mode (standalone console).

  • If you want to use guest autostart with Hypervisor Host desktop enabled, you must enable host autologin. The chapter Hypervisor Host autologin describes how to autologin into the Hypervisor Host in desktop mode.

13.2.2. Disable Hypervisor Host desktop

When using guest autostart with the standalone console (full screen desktop view of the guest), the Hypervisor Host desktop is no longer required and should be disabled. In this case the guest is also started faster after power on.

Execute the following command to configure the Hypervisor Host into a console-only mode.

sudo systemctl set-default multi-user.target

After rebooting $ sudo reboot and configuring guest autostart in standalone mode according to Standalone console mode, the guest should be started automatically in kiosk mode without showing the Hypervisor Host desktop.

Hint

If you want to reactivate the Hypervisor Host desktop, run

sudo systemctl set-default graphical.target
sudo reboot

If you want to temporary start the Hypervisor Host desktop, run

startx
It is even possible to completely uninstall the Hypervisor Host GUI to save disk space.
Please note, if the GUI is uninstalled, the interaction with the Hypervisor Host can be performed only via a SSH connection.
As an alternative, you may configure a separate Grub Menu Entry or Press Ctrl-Alt-F2 to switch to a tty2 console
The following command will completely uninstall the GUI component:
sudo apt-get purge lightdm

13.2.3. Monitor Mirroring (Windows guests)

If running a Windows guest in standalone console mode and more than one monitor is connected to the PC, by default the main display will be mirrored to all other displays. The display resolution will be set automatically. Depending on the connected monitors, it may be necessary to adjust the display resolution.

You will have to determine the display names and the related resolutions of the connected monitor.

export DISPLAY=:0
sudo xrandr

Below you can see a typical example where at HDMI-1 the main monitor is connected and at DP-1 the secondary one is connected.

Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
HDMI-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 410mm x 230mm
   1366x768      59.79*+
   1920x1080     60.00    59.94
   1280x1024     75.02    60.02
   1280x720      60.00    59.94
   1024x768      75.03    60.00
   800x600       75.00    60.32
   720x480       60.00    59.94
   640x480       75.00    72.81    66.67    60.00    59.94
   720x400       70.08
DP-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 531mm x 299mm
   1920x1080     60.00*+
   1680x1050     59.95
   1280x1024     75.02    60.02
   1280x960      60.00
   1152x864      75.00
   1024x768      75.03    60.00
   832x624       74.55
   800x600       75.00    60.32    56.25
   640x480       75.00    59.94
   720x400       70.08

If the resolution shall be adjusted, this can be set in /hv/config/mirrormon.config.

To set the resolution of the monitor connected at DP-1 to the same value as for HDMI-1, you may enter the following line into mirrormon.config:

DP-1:1366x768

Depending on the monitors connected, you may be able to set a resolution that the monitor originally did not support (in the above example, the monitor connected to DP-1 did not support 1366x768).

Caution

You should use the same resolution on all connected monitors and the resolution should by default be supported by the monitor!

13.2.4. Monitor Switching (Linux/Debian guests)

Use case: A system which is configured to automatically start the guest in full-screen Kiosk mode after the Hypervisor Host boots. Two physical monitors are connected to the hardware with identical or different graphics resolution and a single power source. One of the two monitors is powered on when the VM starts. This monitor can be powered off while the second one is powered on (power switch), the guest display then will be automatically shown at the second monitor.

A template script, that has to be modified is located in /hv/guests/etc/multi-mon/switchmon-1mon.py When the script detects that one display is connected and the first one is disconnected, it executes commands on the guest VM. Therefore, it is necessary to configure the guest VM to allow the Hypervisor Host root user to execute commands via an SSH connection without a password. Make sure to establish an SSH key exchange between the Hypervisor Host and guest. If the guest has no external access and is configured for NAT Network, the Hypervisor Host should be set up for port forwarding.

Follow the steps below to configure this script:

  • Install the spice-vdagent Debian package on the Linux VM.

  • Save this script to a directory within the KVM guest, e.g., /hv/guests/guest0001.

  • Make the script executable: chmod 755 multimon.py.

  • Modify the VM_USER variable to a user in your VM. The Hypervisor Host will execute commands in the VM using this user.

13.2.4.1. Port Forwarding

This script assumes that the VM is isolated from the external network and operates through NAT, without any external IP address. If your VM has an IP address, you need to edit and adapt this script appropriately.

Port forwarding refers to the scenario where the Hypervisor Host connects to itself through a specific port, and this connection is then forwarded to a VM. To enable port forwarding, make the following changes to /hv/bin/kvm_guest.sh:

Locate the following lines:

if [ $private_nw -eq 1 ]; then
...
USERNET=$USERNET" -netdev user,id=networkusr,smb=$HV_ROOT/guests

Replace them with:

if [ $private_nw -eq 1 ]; then
...
USERNET=$USERNET" -netdev user,id=networkusr,smb=$HV_ROOT/guests,hostfwd=tcp:127.0.0

13.2.4.2. Hypervisor Host - Guest SSH Key Exchange

To establish a secure connection between the Hypervisor Host and VM, it is necessary to exchange cryptographic keys. Follow these steps on the Hypervisor Host:

  • Switch to the root user: sudo -i.

  • Generate host keys: ssh-keygen -t rsa. When prompted to provide an “Enter passphrase,” press ENTER without entering a password.

  • Copy the host key to the VM by executing the following commands:

ssh username@127.0.0.1 -p 8822 "mkdir -p .ssh"
cat .ssh/id_rsa.pub | ssh username@127.0.0.1 -p 8822 'cat >> .ssh/authorized_keys'
  • Replace “username” with the appropriate VM user.

  • Test the connection to the VM using the following command:

ssh username@127.0.0.1 -p 8822

13.2.4.3. Verify

Perform the following steps to verify, if the script works properly:

  • Start the VM.

  • Execute the script: cd /hv/guests/guest0001 && sudo ./switchmon.py.

  • Switch the power source and video cable from one monitor to another.

  • The script’s output should resemble the following

2023-05-03 16:18:04,990 Switchmon started
2023-05-03 16:18:05,012 Active monitor: DP-2
2023-05-03 16:18:07,040 Active monitor resolution: 1920x1200
2023-05-03 16:18:27,194 Active monitor: NONE
2023-05-03 16:18:31,978 Active monitor: DP-2
2023-05-03 16:18:34,007 Active monitor resolution: 1920x1200
2023-05-03 16:18:40,165 Active monitor: NONE
2023-05-03 16:18:44,937 Active monitor: HDMI-1
2023-05-03 16:18:46,962 Active monitor resolution: 1280x1024
2023-05-03 16:18:49,075 Active monitor: NONE
2023-05-03 16:18:53,130 Active monitor: DP-2
2023-05-03 16:18:55,222 Active monitor resolution: 1920x1200

13.2.4.4. Automatic start

To start the script automatically in the background, make the following change to /hv/bin/kvm_start.sh:

Add /hv/guests/guest0001/multimon.py& before the remote-viewer line.

13.2.5. Suppress boot stage messages

13.2.5.1. Boot log

You may completely hide all logging messages while the computer boots. Adjust the files /etc/grub.d/40_custom and /etc/grub.d/41_custom. You need to edit the linux kernel boot line which includes the text “linux /boot/vmlinuz- “.

Add the following parameters to the bootline:

"quick splash console=ttyS0".

Save the file, update the grub menu and reboot.

sudo update-grub
sudo reboot

13.2.5.2. Login prompt

It is also possible to completely hide the login/password prompt that is displayed before the VM Guest window is shown in the kiosk mode. Execute the following command:

"systemctl disable getty@tty1.service"

and reboot.

You should see no login prompt anymore. The screen should remain black and then the VM Desktop should be displayed. If you wish to log in, press the hot key combination Ctrl-Shift-F2..F6.

13.2.5.3. Grub boot menu

If you want to suppress the grub boot menu, you need to edit the grub menu which is set in /etc/default/grub

sudo gedit /etc/default/grub

Adjust these entries:

GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=3

Then you need to apply the changes:

sudo update-grub
sudo reboot

Then, during boot there will be a 3 seconds period where you have the chance to press the ESC key to show the boot menu if needed.

13.3. Guest Desktop via Pass-Through

Using graphics pass-through mode the integrated graphics hardware is assigned to the Windows guest and no longer available for the Hypervisor Host. This is described in the Graphics Pass-Through Guide.