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)
Thu, Dec 12, 3:41 PM
Unknown Object (File)
Nov 25 2024, 1:46 PM
Unknown Object (File)
Nov 23 2024, 8:34 AM
Unknown Object (File)
Nov 21 2024, 6:42 AM
Unknown Object (File)
Nov 20 2024, 3:00 AM
Unknown Object (File)
Nov 19 2024, 4:23 PM
Unknown Object (File)
Nov 15 2024, 7:16 AM
Unknown Object (File)
Nov 10 2024, 10:32 AM

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".