Page MenuHomeFreeBSD

bhyve: allow overriding snapshot socket directory
ClosedPublic

Authored by novel on Jun 7 2026, 7:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 8, 9:59 PM
Unknown Object (File)
Tue, Jul 7, 3:52 PM
Unknown Object (File)
Mon, Jul 6, 10:44 AM
Unknown Object (File)
Mon, Jul 6, 9:26 AM
Unknown Object (File)
Mon, Jul 6, 4:51 AM
Unknown Object (File)
Sun, Jul 5, 9:54 PM
Unknown Object (File)
Sat, Jul 4, 5:28 AM
Unknown Object (File)
Sat, Jul 4, 5:26 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 74347
Build 71230: arc lint + arc unit

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.Wed, Jun 24, 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.Thu, Jun 25, 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.Sat, Jul 4, 2:19 PM