Skip to content

Commit

Permalink
Add support for VNC console for shim VMs
Browse files Browse the repository at this point in the history
We enable access to shim VMs via VNC console through the following
steps:
- add another virtual console in the QEMU configuration that's gonna be
used by VNC
- call agetty on that virtual console during VMs boot to enable login

When connecting to the QEMU instance via VNC the user will first be
presented with a view of the currently running process (container's
entry point). To switch to the shell of the shim VM the user will have
to press 'Ctrl+Alt+2' and then 'Enter' to get the login prompt.
Due to inability of some VNC clients to change the resolution of the
display, the client might crash. However upon the client restart the
new virtual console will appear as expected. The user can then switch
back to the previous virtual console by pressing 'Ctrl+Alt+1'.

Signed-off-by: Paul Gaiduk <paulg@zededa.com>
  • Loading branch information
europaul committed Mar 15, 2024
1 parent 1cd8f6a commit 868c4ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions pkg/pillar/hypervisor/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ const qemuConfTemplate = `# This file is automatically generated by domainmgr
driver = "virtconsole"
chardev = "charserial1"
name = "org.lfedge.eve.console.prime"
[chardev "charserial2"]
backend = "vc"
[device]
driver = "virtconsole"
chardev = "charserial2"
name = "org.lfedge.eve.console.prime.forvnc"
{{end}}
{{if .DomainConfig.EnableVnc}}
Expand Down
14 changes: 9 additions & 5 deletions pkg/xen-tools/initrd/init-initrd
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,25 @@ maxupdateskew 100.0
EOF
/usr/sbin/chronyd -u root -f /etc/chrony/chrony.conf &&
echo "chronyd started!" > /dev/kmsg ||
echo "chronyd NOT started!" > /dev/ksmg
echo "chronyd NOT started!" > /dev/kmsg
else
echo "PTP_KVM device is not available!" > /dev/kmsg
fi
fi

run_agetty_loop()
{
while true; do
setsid agetty --autologin root --noclear hvc1 linux
done
console_name="$1"
while true; do
setsid agetty --autologin root --noclear "$console_name" linux
done
}

echo "Executing agetty"
run_agetty_loop &
# run agetty on the virtual console connected to the socket
run_agetty_loop hvc1 &
# run agetty on the virtual console available for VNC
run_agetty_loop hvc2 &

cmd=`cat /mnt/cmdline`
echo "Executing $cmd"
Expand Down

0 comments on commit 868c4ce

Please sign in to comment.