Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devices/console: Fix a bug which would cause libkrun to hang on exit #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mtjhrc
Copy link
Collaborator

@mtjhrc mtjhrc commented Jan 28, 2025

This fixes a hang observed when the VM is about to exit. The problem was the console device was joining a thread on vm shutdown (or device reset) which would never exit.

To replicate the hang, the stdin must not be a terminal (for example you can use a pipe).
Before this fix, this would hang:
echo hello | ./chroot_vm rootfs_fedora /bin/cat
(Btw libkrun used 100% (1 core) of CPU when it was stuck in this state - I don't know why exactly.)

This seems to be a regression introduced by the commit: 4076b7: devices/console: implement reset method

Make PortInputEmpty and PortInputSigInt `wait_until_readable` implementations
poll the stopfd EventFd to ensure the thread eventually exits.
(The thread is joined in Port::shutdown method causing the hang).

To replicate the hang, the stdin must not be a terminal. For example you can use
a pipe - `echo hello | ./chroot_vm rootfs_fedora /bin/cat` would hang without
this fix.

This seems to be a regresion introduced by the commit:
4076b7: devices/console: implement reset method

Signed-off-by: Matej Hrica <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant