Page MenuHomeFreeBSD

bhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN
ClosedPublic

Authored by jhb on Oct 12 2023, 9:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 11 2024, 5:27 AM
Unknown Object (File)
Dec 20 2023, 7:15 AM
Unknown Object (File)
Dec 10 2023, 9:23 PM
Unknown Object (File)
Oct 16 2023, 10:18 PM

Details

Summary

EPRINTLN handles newlines appropriately when stdout/stderr have been
reused as the backend for a serial port.

For bhyverun.c itself, the rule this attempts to follow is to use
regular fprintf/perror/warn/err prior to init_pci() (which is when
serial ports are configured) and to switch to EPRINTLN afterwards.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Do you plan to convert uses of warn() as well?

This revision is now accepted and ready to land.Oct 13 2023, 2:12 PM

Do you plan to convert uses of warn() as well?

I didn't have it in my plan as that requires a bit more work. There are probably several perror calls that also still need fixing after this. I had noticed the rdmsr messages recently in a Linux guest and went for the low-hanging fruit (initially just in vmexit.c but then expanding to what my a grep of fprintf found). There might still be some fprintf calls in snapshot.c that this change doesn't address.

corvink added inline comments.
usr.sbin/bhyve/bhyverun.c
955–956

Is it ok to use EPRINTLN if the serial port initialization of init_pci failed?

usr.sbin/bhyve/bhyverun.c
955–956

Yes, it's always safe to use as it just checks raw_stdio to determine if it should output "\r\n" vs "\n".