Page MenuHomeFreeBSD

vmrun.sh: add option for sharing directory via p9fs to bhyve
ClosedPublic

Authored by dave_freedave.net on Feb 4 2026, 1:16 PM.
Tags
Referenced Files
Unknown Object (File)
Fri, Feb 27, 2:35 AM
Unknown Object (File)
Tue, Feb 24, 8:18 PM
Unknown Object (File)
Mon, Feb 23, 8:01 PM
Unknown Object (File)
Sun, Feb 22, 10:10 PM
Unknown Object (File)
Sun, Feb 22, 6:45 PM
Unknown Object (File)
Sun, Feb 22, 4:31 AM
Unknown Object (File)
Fri, Feb 20, 6:43 PM
Unknown Object (File)
Thu, Feb 19, 6:21 AM

Details

Summary

This is just adding the ability to share, via p9fs, a directory to bhyve. I assume it would work with arm, but at present I don't have a system to test and verify. If it does, its a one line change for it to have the option.

I basically cribbed from the code for disks which apart from the -9 option is right next to the disk code.

Test Plan

I have been running this for a while now to share ports to my poudriere bhyve instance.

I do have to lay ZFS datasets out to avoid PR 288444:

/p9fs/ports
/p9fs/distfiles
/p9fs/packages

I share them with -9 port=/p9fs/ports -9 dist=/p9fs/distfiles -9 pkg=/p9fs/packages
I was sharing another directory with the ro option which I believe is the only option supported. That would look like -9 foo=/some/path,ro.

Those can be mounted in the layout that is expected in the bhyve virtual machine. You just cant share up nested file systems as p9fs(4) shows.

Diff Detail

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

Event Timeline

When uploading diffs, please include extra context by adding -U 999999 to the diff command options: https://wiki.freebsd.org/Phabricator#Create_a_Revision_via_Web_Interface

I assume it would work with arm, but at present I don't have a system to test and verify. If it does, its a one line change for it to have the option.

I haven't tested it yet, but there's no reason not to provide this on arm64 IMO. If you update the diff accordingly I'll give it a try on my test system.

share/examples/bhyve/vmrun.sh
148

The usage message in usage() needs to be updated as well.

401

Don't you need to reset i=0 first?

adding 9: to opts for arm64 and re-creating diff with right options.

fix unititialized i=... (I had that on my local copy and somehow lost it).
add usage for -9. I'm open to better suggestions, though.

dave_freedave.net added inline comments.
share/examples/bhyve/vmrun.sh
401

yes

Works fine for me on arm64. There is one last issue with the usage message, once it's fixed I can land this.

share/examples/bhyve/vmrun.sh
66

The synopsis also needs an entry [-9 <9p share>=<path>[,<opts>]]

This revision is now accepted and ready to land.Fri, Feb 6, 7:38 PM
dave_freedave.net marked an inline comment as done.

update synopsis as well. Here is the new output for /bin/sh /usr/share/examples/bhyve/vmrun.sh -h:

Usage: vmrun.sh [-aAEhiTuvw] [-9 <9p share>=<path>[,<opts>]]
                [-c <CPUs>] [-C <console>] [-d <disk file>]
                [-e <name=value>] [-f <path of firmware>] [-F <size>]
                [-G [w][address:]port] [-H <directory>]
                [-I <location of installation iso>] [-l <loader>]
                [-L <VNC IP for UEFI framebuffer>]
                [-m <memsize>] [-n <network adapter emulation type>]
                [-p <pcidev|bus/slot/func>]
                [-P <port>] [-t <tapdev>] <vmname>

       -h: display this help message
       -9: virtio 9p (VirtFS) device to share directory
       -a: force memory mapped local APIC access
       -A: use AHCI disk emulation instead of virtio-blk
       -c: number of virtual cpus (default: 2)
       -C: console device (default: stdio)
       -d: virtio diskdev file (default: ./diskdev)
       -e: set FreeBSD loader environment variable
       -E: Use UEFI mode (amd64 only)
       -f: Use a specific boot firmware (e.g., EDK2, U-Boot)
       -F: Use a custom UEFI GOP framebuffer size (default: w=1024,h=768) (amd64 only)
       -G: bind the GDB stub to the specified address
       -H: host filesystem to export to the loader
       -i: force boot of the Installation CDROM image
       -I: Installation CDROM image location (default: ./release.iso)
       -l: the OS loader to use (default: /boot/userboot.so) (amd64 only)
       -L: IP address for UEFI GOP VNC server (default: 127.0.0.1)
       -m: memory size (default: 512M)
       -n: network adapter emulation type (default: virtio-net)
       -p: pass-through a host PCI device (e.g ppt0 or bus/slot/func) (amd64 only)
       -P: UEFI GOP VNC port (default: 5900)
       -t: tap device for virtio-net (default: tap0)
       -T: Enable tablet device (for UEFI GOP) (amd64 only)
       -u: RTC keeps UTC time
       -v: Wait for VNC client connection before booting VM
       -w: ignore unimplemented MSRs (amd64 only)
This revision now requires review to proceed.Sat, Feb 7, 5:22 AM
This revision is now accepted and ready to land.Sat, Feb 7, 9:28 PM