Page MenuHomeFreeBSD

bhyve: allow overriding snapshot socket directory
ClosedPublic

Authored by novel on Jun 7 2026, 7:46 AM.
Tags
None
Referenced Files
F166383538: D57494.id180434.diff
Thu, Aug 13, 7:05 AM
F166333903: D57494.id.diff
Wed, Aug 12, 11:38 PM
F166304791: D57494.id180849.diff
Wed, Aug 12, 7:07 PM
Unknown Object (File)
Wed, Aug 12, 12:59 AM
Unknown Object (File)
Wed, Aug 12, 12:48 AM
Unknown Object (File)
Tue, Aug 11, 8:00 PM
Unknown Object (File)
Mon, Aug 10, 9:03 PM
Unknown Object (File)
Mon, Aug 10, 11:29 AM

Details

Summary

By default bhyve(8) creates a snapshot socket in
"/var/run/bhyve/" (BHYVE_RUN_DIR).
As this is a system directory not writable by users,
this does not work when bhyve(8) is being started
as a non-root user.

Address that by allowing to override this directory.
In bhyve(8) it is done by setting 'rundir' option
with '-o rundir=<path>'.

In bhyvectl(8) it is done with '--rundir=<path>'.

Test Plan

sudo -u bhyve -g vmm bhyve -M -c 2 -m 4096 -o pci.enable_bars=1 -u -H -P \

-s 0:0,hostbridge -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-s 2:0,xhci,tablet -s 1:0,lpc \
-s 3:0,ahci,cd:/data/isos/alpine-standard-3.23.4-x86_64.iso \
-s 6:0,fbuf,tcp=127.0.0.1:5901 \
-l com1,stdio \
-o rundir=/tmp/bhyve_run \
alpine

sudo -u bhyve -g vmm bhyvectl --checkpoint=/tmp/vm --vm=alpine --rundir=/tmp/bhyve_run

Diff Detail

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

Event Timeline

novel requested review of this revision.Jun 7 2026, 7:46 AM
bnovkov added inline comments.
usr.sbin/bhyve/amd64/bhyverun_machdep.c
71

This will fail to compile on a non-BHYVE_SNAPSHOT build otherwise.

usr.sbin/bhyvectl/bhyvectl.c
160

Isn't this array supposed to hold information about the type of the argument? Would it make more sense to put "path" here?

393–394
547–550

One more thing, could you please document this feature in bhyve's manpage?

This is cool! Please add the docs to bhyvectl as well!

usr.sbin/bhyve/bhyve_config.5
229

Use the Pa macro to add filesystem paths to the whatis database. This facilitates searching the manual by filename.

Address review comments about manpages.

bcr added a subscriber: bcr.

The manpage looks good now, thanks!

This revision is now accepted and ready to land.Jun 24 2026, 5:36 PM
usr.sbin/bhyvectl/bhyvectl.8
43–44

We need it here too.

bhyvectl.8: add '--rundir' to synopsis

This revision now requires review to proceed.Jun 25 2026, 3:40 PM

Two more nits, looks good otherwise.

usr.sbin/bhyve/snapshot.c
1424–1432
usr.sbin/bhyvectl/bhyvectl.c
274–275

Address comments (formatting).

This revision is now accepted and ready to land.Jul 4 2026, 2:19 PM