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, Oct 31, 6:38 AM
Unknown Object (File)
Tue, Oct 29, 8:47 PM
Unknown Object (File)
Fri, Oct 18, 9:14 AM
Unknown Object (File)
Thu, Oct 17, 2:23 AM
Unknown Object (File)
Tue, Oct 15, 2:49 AM
Unknown Object (File)
Mon, Oct 14, 10:16 AM
Unknown Object (File)
Sat, Oct 12, 11:01 AM
Unknown Object (File)
Fri, Oct 11, 3:48 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".