Page MenuHomeFreeBSD

bhyve: add UNIX domain socket support to rfb
ClosedPublic

Authored by quentin.thebault_defenso.fr on Nov 19 2025, 8:24 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jan 26, 11:00 AM
Unknown Object (File)
Sun, Jan 25, 4:03 AM
Unknown Object (File)
Sun, Jan 25, 2:25 AM
Unknown Object (File)
Fri, Jan 23, 12:25 PM
Unknown Object (File)
Thu, Jan 22, 5:15 PM
Unknown Object (File)
Thu, Jan 22, 5:04 PM
Unknown Object (File)
Tue, Jan 13, 3:54 PM
Unknown Object (File)
Tue, Jan 13, 3:25 PM

Details

Summary

This commit adds support for a UNIX domain socket to bhyve's remote
framebuffer. It enables the use of the graphical console when the bhyve instance
is running in a jail with no networking, for instance. A VNC client running on
the host can then connect to the UNIX domain socket through the filesystem.

Signed-off-by: Quentin Thébault <quentin.thebault@defenso.fr>
Sponsored by: Defenso
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans added inline comments.
usr.sbin/bhyve/bhyve.8
927

New sentence must start on a new line

usr.sbin/bhyve/rfb.c
1310

strncpy won't terminate if it fills the buffer, which is fine since you zeroed it all out but imo it's better to be defensive and clear here.

1385–1386

I would have maybe instead asserted that hostname[0] != '/' if AI is non-NULL, since that could be indicative of funkiness.

quentin.thebault_defenso.fr retitled this revision from bhyve: add UNIX domain socket support for rfb to bhyve: add UNIX domain socket support to rfb.Nov 24 2025, 3:47 AM
quentin.thebault_defenso.fr edited the summary of this revision. (Show Details)

Replace strncpy with strlcpy, add assert before freeaddrinfo and newline to bhyve.8

Implementation looks fine to me, but I defer to bhyve-y folks for final review... in particular, I do wonder if they might prefer some more explicit prefix like unix:/path/to/sock

This revision is now accepted and ready to land.Nov 24 2025, 11:28 PM
markj added a subscriber: markj.

I think this is ok, but yes I'd somewhat prefer to have an explicit unix:<path>. That way there's no need to require the path to be absolute.

Added a unix: prefix for UNIX domain sockets

This enables the use of relative paths.
To avoid parsing the configuration value twice, I decided to pass a sa_family_t parameter to the rfb_init function. I hope that is an acceptable way to implement it.

This revision now requires review to proceed.Dec 1 2025, 2:21 PM
usr.sbin/bhyve/pci_fbuf.c
289

I probably wouldn't assert on these, since value is presumably user-supplied -- we can do an EPRINTLN / returrn -1, as in the above error cases.

Added a unix: prefix for UNIX domain sockets

This enables the use of relative paths.
To avoid parsing the configuration value twice, I decided to pass a sa_family_t parameter to the rfb_init function. I hope that is an acceptable way to implement it.

IMO passing the family hint is a perfectly fine option - I can't really picture a better alternative offhand.

usr.sbin/bhyve/pci_fbuf.c
297

This could just be unindented by a level in the containing block, but I don't insist

This revision is now accepted and ready to land.Dec 2 2025, 5:05 AM

Looks ok to me aside from the one question.

usr.sbin/bhyve/rfb.c
1338

Why unlink it? Shouldn't it be an error if we try to bind the socket and it is already bound?

usr.sbin/bhyve/rfb.c
1338

I think the theory is that we don't know if it's bound or not; iirc, bind(2) will fail if the file exists at all (and not just if something's currerntly bound to it).

markj added inline comments.
usr.sbin/bhyve/rfb.c
1338

Ah, right, I was thinking they could be reused like named pipes.

This revision was automatically updated to reflect the committed changes.