Getting Serial Devices into bhyve VM?

Status
Not open for further replies.
Joined
Feb 2, 2016
Messages
574
I have a bhyve VM under FreeNAS. That VM needs a serial port. I'm stumped.

I don't see a way to pass through a serial port. I don't see a way to pass through a USB serial port adapter.

There are a lot of serial port to ethernet adapters in the world. I've used those by Lantronix and Brainboxes. So that's an option, I guess. But I'd rather have a native software-based solution (that doesn't require me to spend money on hardware) since the FreeNAS server has a hardware serial port.

(The VM is for a weather station that is serial only. There are data collection applications that run under Linux and Windows so, while I'd prefer a Linux solution, I'm flexible. Running the data collection application in a VM means one more physical computer I can turn off and decommission.)

Suggestions, please.

Cheers,
Matt
 

Artion

Patron
Joined
Feb 12, 2016
Messages
331
It seems that serial device pass-through is supported by bhyve.

Code:
-s slot,emulation[,conf]
		 Configure a virtual PCI slot and function.

		 bhyve provides PCI bus emulation and virtual devices that can be attached to
		 slots on the bus.  There are 32 available slots, with the option of providing up
		 to 8 functions per slot.

		 slot		 pcislot[:function] bus:pcislot:function

				 The pcislot value is 0 to 31. The optional function value is 0 to 7.
				 The optional bus value is 0 to 255.  If not specified, the function
				 value defaults to 0.  If not specified, the bus value defaults to 0.

		 emulation

				 hostbridge | amd_hostbridge

					 Provide a simple host bridge.	This is usually config-
					 ured at slot 0, and is required by most guest operating
					 systems.  The amd_hostbridge emulation is identical but
					 uses a PCI vendor ID of AMD.

				 passthru	 PCI pass-through device.

				 virtio-net  Virtio network interface.

				 virtio-blk  Virtio block storage interface.

				 virtio-rnd  Virtio RNG interface.

				 ahci-cd	 AHCI controller attached to an ATAPI CD/DVD.

				 ahci-hd	 AHCI controller attached to a SATA hard-drive.

				 uart	 PCI 16550 serial device.

				 lpc	 LPC PCI-ISA bridge with COM1 and COM2 16550 serial
					 ports. The LPC bridge emulation can only be configured
					 on bus 0.

		 [conf]	  This optional parameter describes the backend for device emulations.
				 If conf is not specified, the device emulation has no backend and
				 can be considered unconnected.

				 Network devices:

				 tapN[,mac=xx:xx:xx:xx:xx:xx]

				 vmnetN[,mac=xx:xx:xx:xx:xx:xx]

					 If mac is not specified, the MAC address is derived from
					 a fixed OUI and the remaining bytes from an MD5 hash of
					 the slot and function numbers and the device name.

					 The MAC address is an ASCII string in ethers(5) format.

				 Block storage devices:

				 /filename[,nocache][,direct][,ro]

				 /dev/xxx[,nocache][,direct][,ro]

					 nocache   Open the file with O_DIRECT.

					 direct	Open the file using O_SYNC.

					 ro	   Force the file to be opened read-only.

					 The nocache, direct, and ro options are not available
					 for virtio block devices.

				 TTY devices:

				 stdio	 Connect the serial port to the standard input and output
					 of the bhyve process.

				 /dev/xxx	 Use the host TTY device for serial port I/O.

				 Pass-through devices:

				 slot/bus/function
					 Connect to a PCI device on the host at the selector
					 described by slot, bus, and function numbers.

				 The host device must have been reserved at boot-time using the
				 pptdev loader variable as described in vmm(4).
 
Last edited:
Joined
Feb 2, 2016
Messages
574
Thank you! Is that the version used by FreeNAS? I read a few threads that talked about how serial passthrough was coming but not available just yet.

Cheers,
Matt
 

DaVo

Cadet
Joined
Jun 4, 2013
Messages
9
@MatthewSteinhoff Did you manage to get your setup running? I'm searching for the same solution (use an USB-Serial-Adapter connected to the host within my bhyve-guest (debian)).
I tried the following option: -s 7,uart,/dev/cuaU0 when starting the vm from CLI - and the device gets created (can see the loaded driver in dmesg of guest). But I have no idea how to proceed. Can anyone help here?

@dlavigne: As far as I got it, the standard behavior of the FreeNAS-GUI is to use the serial-port just for a console, but not for any other device. Is this correct?
 
Status
Not open for further replies.
Top