Without this change, bhyve's UART emulation uses the stdin fd for both
input and output. This makes it difficult to capture bhyve's output by
having it write to a pipe. This is helpful for example for Syzkaller,
which wants to be able to capture console output (so it can tell when a
VM has panicked and extract the panic string) but never needs to send
input to the console.
One solution to the above problem would be to use nmdm(4) instead, but
this turned out to be too complicated. You can't easily open the other
nmdm node and read from it as though it's a stream. Running a cu(1)
process and treating its standard output as a console stream kind of
works, but clean-up is hard to get right, partly because cu(1) uses a
child process to read from the modem device, and sending SIGINT to the
parent causes a hang. Meanwhile, other hypervisors (qemu, vmm, kvm)
have no problems running with redirected std* streams.
Note that bhyveload(8) already uses separate fds for input and output
when interacting with stdio, so no change was needed there.
I did not attempt to modify the bvmconsole driver (bhyve -b) since
it does not appear to be used much and the man page claims that it
will be deprecated.