From b2316680aba34df3debff965acdb02dfc01ae923 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 1 Jul 2026 06:00:02 -0300 Subject: [PATCH] fix(console): drive the KVM serial console via tmux+virsh, not screen cons/kvm ran `ssh -t screen ... `, which requires screen on every hypervisor. Bare libvirt hosts (notably ppc64le power servers) ship tmux but not screen, so goconserver's console fork failed and no console was captured. Use tmux (present on all our libvirt hosts) for the shared detach/reattach session, wrapping `virsh console` keyed on the domain name (== the xCAT node name for KVM) -- stable across guest reboots, unlike the raw serial pty. The session status bar is disabled so the captured console log stays clean serial. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> (cherry picked from commit e331290414371282e198050218f7316caea114a1) --- xCAT-server/share/xcat/cons/kvm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/cons/kvm b/xCAT-server/share/xcat/cons/kvm index 4a8d07ce2..9cd5fb6dd 100755 --- a/xCAT-server/share/xcat/cons/kvm +++ b/xCAT-server/share/xcat/cons/kvm @@ -69,12 +69,24 @@ until ($dsthost and $speed and $dstty) { } release_lock(); -# The screen command needs the TERM env var, -# TERM might be empty for some unknown reasons, -# for example, on SLES 12 and on PowerKVM +# TERM may be empty (SLES 12, PowerKVM); a terminal multiplexer needs it. if (!$ENV{'TERM'}) { $ENV{'TERM'} = "vt100"; } -exec "ssh -t $dsthost screen -U -a -O -e ^]a -d -R -S serial-" . $ARGV[0] . "-cons -A $dstty $speed"; - +# Attach to the KVM guest's serial console inside a shared tmux session on the +# hypervisor. tmux (unlike screen) is present on every libvirt host we target, +# incl. ppc64le power hosts that ship no screen; `new-session -A` gives the same +# detach/reattach + multi-client behaviour screen provided (goconserver and an +# interactive rcons share one session). The console itself is opened by +# `virsh console` keyed on the domain name (== the xCAT node name for KVM), which +# is stable across guest reboots (the raw serial pty is not). -x/-y size the +# pane so the guest sees a sane terminal geometry. +my $node = $ARGV[0]; +my $session = "serial-$node-cons"; +my $virshcons = "virsh -c qemu:///system console --force $node"; +# Create the session once, detached, with the status bar OFF so the captured +# console log stays clean serial (no tmux chrome/clock redraws) -- matching what +# screen gave; then attach. `new-session -d -A` is a no-op if it already exists, +# so concurrent clients (goconserver + rcons) share the single session. +exec "ssh -t $dsthost \"tmux -u new-session -d -A -x 200 -y 50 -s $session '$virshcons'; tmux set-option -t $session status off; exec tmux -u attach -t $session\"";