Hooking FreeBSD to a VirtualBox serial port

Something's wrong, but I don't know what, nor where to look.
Works: Booting the FreeBSD-12.0-RELEASE-amd64.qcow2.xz image inside VirtualBox (after converting to .vdi, of course).
Works: Creating a Unix domain socket, via "netcat -lUk COM1". (I'd use socat but Debian-based distros found that socat cannot have both readline and openssl due to license incompatibilities, so you don't get readline support there. The netcat call is supposed to be equivalent to the usual socat incantation. OTOH the netcat docs aren't too clear and maybe I misunderstood something.)
Works: Starting the VM with that domain socket, via "VBoxManage modifyvm VM --uart1 0x3F8 4 --uartmode1 client COM1" (validated to be correctly hooked up: VM startup fails if netcat wasn't started before).

Following https://gist.github.com/snb/284940/11e6354f170be602c9c2f67b59d489ed49ebd143, in the VM, I did
sysrc -f /boot/loader.conf console=comconsole
sysrc -f /boot/loader.conf comconsole_speed="38400"
sed -i '' -e's|ttyu0.*|ttyu0 "/usr/libexec/getty std.38400" vt100 on secure|' /etc/ttys

and then told it to reboot.
Boot behaviour:
In the VirtualBox console: A few lines of boot loader appear, then an awfully long time of nothing, then the boot prompt. The boot splash screen and the pretty lengthy list of boot messages that you normally see are absent.
In the xterm with netcat, it keeps waiting for input, no output appears. Pressing enter (in the hopes of unwedging some line buffering) does not do anything.

Post-boot behaviour:
In the VirtualBox console: Everything is pretty normal. I can login, type commands, see their output, initiate a reboot.
In netcat: As above, nothing happens. Well, anything that I type is echoed in the netcat window, but nothing happens on the VirtualBox console, and pressing enter does not make anything happen in the VirtualBox console. It seems like FreeBSD is not talking to the socket that I named COM1 (but FreeBSD does recognize one serial port, so this seems to be *almost* right).

The whole setup (except the netcat command) is contained in a shell script, so if anybody wants to experiment, just take the attached setup.txt, make it executable and let it run.
It will download the qcow2 which will take a few minutes, but on the second run it will notice the downloaded&converted file and won't re-download.
The VM is started in line 122, after the "if false ; then" statement.
 

Attachments

Back
Top