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

virtme: always print kernel panic / oops in interactive mode #227

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

arighi
Copy link
Owner

@arighi arighi commented Jan 30, 2025

As mentioned in #217 it would be nice to always print the output of critical kernel errors (oops / panic), instead of suppressing all the kernel logs completely by default.

Therefore, keep suppressing the boot kernel log, but always dump panic/oops to stderr by default when running in interactive mode.

Example with this change applied:

arighi@virtme-ng~/s/linux (master)> vng
          _      _
   __   _(_)_ __| |_ _ __ ___   ___       _ __   __ _
   \ \ / / |  __| __|  _   _ \ / _ \_____|  _ \ / _  |
    \ V /| | |  | |_| | | | | |  __/_____| | | | (_| |
     \_/ |_|_|   \__|_| |_| |_|\___|     |_| |_|\__  |
                                                |___/
   kernel version: 6.13.0-virtme x86_64
   (CTRL+d to exit)

arighi@virtme-ng~/s/linux (master)> echo c | sudo tee /proc/sysrq-trigger
[    8.923672] sysrq: Trigger a crash
[    8.923980] Kernel panic - not syncing: sysrq triggered crash
[    8.924183] CPU: 0 UID: 0 PID: 198 Comm: tee Not tainted 6.13.0-virtme #2
[    8.924632] Call Trace:
[    8.924704]  <TASK>
[    8.924783]  panic+0x349/0x3b0
[    8.925055]  sysrq_handle_crash+0x36/0x80
[    8.925181]  __handle_sysrq+0xed/0x270
[    8.925274]  write_sysrq_trigger+0x6a/0x90
[    8.925380]  proc_reg_write+0x56/0xa0
[    8.925489]  vfs_write+0x105/0x590
[    8.925600]  ksys_write+0x74/0xf0
[    8.925682]  do_syscall_64+0xbb/0x1d0
[    8.925767]  entry_SYSCALL_64_after_hwframe+0x77/0x7f
[    8.925891] RIP: 0033:0x7fdfed54ba84

Closes: #217

@arighi arighi requested a review from matttbe January 30, 2025 08:16
Copy link
Collaborator

@matttbe matttbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to change the log level in non-verbose mode!

Just one question to avoid exiting if stderr is not accessible.

@arighi arighi force-pushed the show-kernel-panic branch from 3be4f32 to ebf93bd Compare January 30, 2025 13:03
Copy link
Collaborator

@matttbe matttbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the new version!

It looks good to me! I just have a couple of questions, just to be sure we don't want to look at alternatives. If not, feel free to merge :)

else:
print(
"WARNING: not a valid pts, try to run vng inside tmux or screen",
file=sys.stderr,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to be sure: can we still write to stderr here if we cannot access /proc/self/fd/2?

Also, compared to before, this warning will always be printed in such environment, when stderr is not accessible. I guess it will not be an issue, right?

@arighi arighi force-pushed the show-kernel-panic branch from ebf93bd to 98cef38 Compare January 30, 2025 14:16
@arighi arighi force-pushed the show-kernel-panic branch from 98cef38 to 503e9da Compare January 30, 2025 14:41
As mentioned in #217 it would be nice to always print the output of
critical kernel errors (oops / panic), instead of suppressing all the
kernel logs completely by default.

Therefore, keep suppressing the boot kernel log, but always dump
panic/oops to stderr by default when running in interactive mode.

Example with this change applied:

arighi@virtme-ng~/s/linux (master)> vng
          _      _
   __   _(_)_ __| |_ _ __ ___   ___       _ __   __ _
   \ \ / / |  __| __|  _   _ \ / _ \_____|  _ \ / _  |
    \ V /| | |  | |_| | | | | |  __/_____| | | | (_| |
     \_/ |_|_|   \__|_| |_| |_|\___|     |_| |_|\__  |
                                                |___/
   kernel version: 6.13.0-virtme x86_64
   (CTRL+d to exit)

arighi@virtme-ng~/s/linux (master)> echo c | sudo tee /proc/sysrq-trigger
[    8.923672] sysrq: Trigger a crash
[    8.923980] Kernel panic - not syncing: sysrq triggered crash
[    8.924183] CPU: 0 UID: 0 PID: 198 Comm: tee Not tainted 6.13.0-virtme #2
[    8.924632] Call Trace:
[    8.924704]  <TASK>
[    8.924783]  panic+0x349/0x3b0
[    8.925055]  sysrq_handle_crash+0x36/0x80
[    8.925181]  __handle_sysrq+0xed/0x270
[    8.925274]  write_sysrq_trigger+0x6a/0x90
[    8.925380]  proc_reg_write+0x56/0xa0
[    8.925489]  vfs_write+0x105/0x590
[    8.925600]  ksys_write+0x74/0xf0
[    8.925682]  do_syscall_64+0xbb/0x1d0
[    8.925767]  entry_SYSCALL_64_after_hwframe+0x77/0x7f
[    8.925891] RIP: 0033:0x7fdfed54ba84

Signed-off-by: Andrea Righi <[email protected]>
@arighi arighi force-pushed the show-kernel-panic branch from 503e9da to 19c7f39 Compare January 30, 2025 14:44
Copy link
Collaborator

@matttbe matttbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the update!

Copy link
Collaborator

@matttbe matttbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the update!

@arighi arighi merged commit 1ebb7fb into main Jan 30, 2025
7 checks passed
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.

vng silently hangs if boot fails
2 participants