Re: virsh console hangs when ssh connection is lost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 12, 2025 at 11:08:09AM +0100, Olaf Hering via Devel wrote:
Hello,

the command 'virsh -c qemu+ssh://root@remotehost/system console vm' from
libvirt 10.0.0 just hangs when the remotehost is rebooted. It prints
error: Disconnected from qemu+ssh://root@remotehost/system due to end of file
and waits for the user to press return. Then it prints

The problem here is that the code in virshRunConsole():

  https://gitlab.com/libvirt/libvirt/-/blob/master/tools/virsh-console.c?ref_type=heads#L495-501

is waiting for a condition that gets signaled from virConsoleShutdown()
that gets called only on events on the stream.  The part of the code
that gets the information about the disconnection handles it in
virshCatchDisconnect():

  https://gitlab.com/libvirt/libvirt/-/blob/master/tools/virsh.c?ref_type=heads#L63-97

which:

 a) shouldn't do much

 b) does not have access to that condition or that stream

and one of those will need to be linked together somehow.

error: internal error: client socket is closed
and the command terminates as expected. I tried to add -k and -K, but
that does not help. If for some reason the vm is shutdown manually via
'virsh shutdown --domain vm' on remotehost or via "poweroff", then
'virsh console' also terminates properly.


That's because any event (hitting <enter> triggers the stdin event)
wakes up the event loop which notices the disconnection.

Is there a way to avoid such a hang state if the ssh connection drops?

It seems the simple reproducer is to send SIGTERM to the sshd child process.

Olaf


Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux