Skip to content

Conversation

1awesomeJ
Copy link
Contributor

@1awesomeJ 1awesomeJ commented Jun 19, 2023

No description provided.

@1awesomeJ
Copy link
Contributor Author

I want to start with a function that fetches the oldest message in the journal and displays it to the console.
Currently I set PRIORITY to 5(notice) to see if I'll get any messages. I'm currently not getting any.

@1awesomeJ 1awesomeJ force-pushed the bsod branch 2 times, most recently from 2022bbe to 7bd44d9 Compare June 19, 2023 13:53
@1awesomeJ
Copy link
Contributor Author

@bluca
Following Poettering's guidance, I created this bsod tool.
Currently it just tries to fetch the oldest message from the current boot with a log level of "emergency", and prints it to a console.

Subsequently, I have to modify it to take over the entire screen, turn it blue, and display the QR code.

Howevever, I am currently not getting an output at all, even when i change the PRIORITY to numbers other than 0.
What am I doing wrong sir?

Thank you.

_cleanup_close_ int fd = -EBADF;
char * message = first_emerg_boot_message();

fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
Copy link
Member

Choose a reason for hiding this comment

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

so for this I think we should not go to /dev/console (which is a magic device that basically points to wherever boot time logs and stuff should go to which can be serial or similar) but the VT subsystem (which is the virtual terminal, i.e. a textual interface to a local physical display device, i.e. no serial), and I think we should not interfere with the usual log/progress output that /dev/console gets. Hence I'd suggest we allocate a full new VT for this, and then switch to that.

(in case you wonder what a VT is, it's this archaic textual display logic that the linux kernel uses to do early boot logging before wayland/x11 take over, and that you can log into via Alt-F2, Alt-F3, …)

i.e. open /dev/tty1 temporarily, then issue the VT_GETSTATE ioctl call on it which tells you which VTs are currently allocated via a bitmask. Look for the first free VT (i.e. determine lowest unset bit, then format /dev/tty%i with it plus one. Then open that, and use that. switch to it via the VT_ACTIVATE ioctl, then clear it by output ANSI_HOME_CLEAR on it, then display the message there.

If this sounds like a bit much, grep our sources for VT_GETSTAT, we already call that ioctl elsewhere for other reasons.

Copy link
Contributor

Choose a reason for hiding this comment

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

VT_OPENQRY might be easier than VT_GETSTATE and __builtin_ctz(~vt_stat.v_state) or whatever.

@poettering poettering added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review PR is ready for (re-)review by a maintainer labels Jun 19, 2023
@github-actions github-actions bot added please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Jun 19, 2023
@poettering poettering added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review PR is ready for (re-)review by a maintainer labels Jun 19, 2023
@1awesomeJ
Copy link
Contributor Author

1awesomeJ commented Jun 20, 2023

I read that the APIs return errno-style errors on failure. Kindly review my choice of error types sir.

I made some of the requested changes.

I still have the SD_ID128_FORMAT_STR() and SD_ID128_FORMAT_VAL() outstanding. Still need to study them more.
And of course VT.

But I don't want to miss the chance of getting a review in case you view the PR, so I decided to push some first.

@github-actions github-actions bot added please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Jun 20, 2023
@1awesomeJ
Copy link
Contributor Author

I looked up the format string and format value macros sir, and I've now used them in the patch.

So it's VT I need to look up now.

perhaps I have too many log messages?

@1awesomeJ 1awesomeJ changed the title PID1: Implement systemd blue screen of death for boot failures. PID1: Display emergency log message full-sceen on boot failure. Jun 21, 2023
@1awesomeJ
Copy link
Contributor Author

Thank you so much @yuwata for the very detailed review.
Let me fix.

@1awesomeJ
Copy link
Contributor Author

@yuwata, I made all the requested changes.
Sorry I took long.

@bluca bluca added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed documentation build-system meson please-review PR is ready for (re-)review by a maintainer labels Aug 3, 2023
@bluca bluca changed the title PID1: Display emergency log message full-sceen on boot failure. Add tool to display emergency log message full-sceen on boot failure. Aug 3, 2023
@bluca
Copy link
Member

bluca commented Aug 3, 2023

needs a rebase on main due to conflicts

@1awesomeJ
Copy link
Contributor Author

needs a rebase on main due to conflicts

Okay sir.
I'll fix in about an hour.

Copy link
Member

@yuwata yuwata left a comment

Choose a reason for hiding this comment

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

LGTM. Let's go in this form at least now.
Future tasks are

  • merge two qrcode logic more,
  • add tests for bsod.service.

@bluca
Copy link
Member

bluca commented Aug 3, 2023

When you rebase and push, please also amend the commit message, as this is not about PID1, it's a different tool

@1awesomeJ
Copy link
Contributor Author

When you rebase and push, please also amend the commit message, as this is not about PID1, it's a different tool

Certainly sir.

@1awesomeJ
Copy link
Contributor Author

LGTM. Let's go in this form at least now. Future tasks are

  • merge two qrcode logic more,
  • add tests for bsod.service.

Alright sir.
I hope "future" turns out to be next week or next month.

@bluca bluca merged commit fc7eb13 into systemd:main Aug 3, 2023
@github-actions github-actions bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Aug 3, 2023
@systemd systemd deleted a comment from grepwood Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

7 participants