bhyve How do you share files into bhyve VMs?

Hi, all the online tutorial mentions that I need to use NFS or SAMBA to share files. Do you know if there is any easier way or what is your preferred way of doing it?

Also if I share via NFS, is there a performance hit or higher CPU load compared to use cases of Jail where I mounted the files via nullfs?
 
15 includes p9fs which apparently lets you share a file system with bhyve, but I haven't used it. It requires running 15 on the host which I don't do.

I use NFS to share from my 14 host to bhyve VMs. I can't compare perf / CPU to nullfs. I would assume it's slower, not sure about CPU, but I'm just speculating.

I'd def be curious about people's experiences with p9fs. That would make working with bhyve instances that much better.
 
15 includes p9fs which apparently lets you share a file system with bhyve, but I haven't used it. It requires running 15 on the host which I don't do.

I use NFS to share from my 14 host to bhyve VMs. I can't compare perf / CPU to nullfs. I would assume it's slower, not sure about CPU, but I'm just speculating.

I'd def be curious about people's experiences with p9fs. That would make working with bhyve instances that much better.
No, you don't need to run 15 on the host. I run stable/14 on the host but I think 14.x-RELEASE will likely also work. It is the *VM* kernel that needs drivers for 9p but on the host it is bhyve that handles all the logic.

There are pros and cons of using 9p vs nfs. 9p is about 4 times faster than nfs in my experiments but there is no caching. For NFS while the first access is slow, subsequent accesses of the same data is much faster due to caching.

Also note that logic for network access of 9p is removed from kernel drivers (the orig. code written at Juniper had this functionality).

Also be aware of this bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288444

Another issue is that (AFAIK) 9p2000.L (what bhyve and qemu implement) doesn't know about FreeBSD's extended attributes (flags). This may be an issue, for example, if you do "cd /usr/src; make installworld" and /usr/obj is 9p mounted [I don't recall all the details now but I had to manually fix up a few files]
 
Do you have an intro document I can look over? I found this bhyve wiki, but it mentions 15-current host and does not mention driver on VM side.

My VM is debian 12 and 13. My host is FreeBSD 14.3
 
The following is for the bhyve command (and not any bhyve management package). As an example, if you want to export "/usr/src" under sharename "src" in the VM, add

-s 8,virtio-9p,src=/usr/src

to the bhyve command line. Add a different pci device & distinct sharename for each separate filesystem you want to export. For example to export "/usr/obj" readonly under sharename "obj", add

-s 9,virtio-9p,obj=/usr/obj,ro

To mount one of these on a debian host you'd need something like

mount -t 9p -o trans=virtio,version=9p2000.L,rw,cache=mmap src /mnt

I'm not familiar with various mount options for 9p on linux but there is a detailed documentation online. Also, do read the bhyve(8) carefully and experiment to become familiar with it!

I *think* this should work with 14.3 but I haven't tried. Also note that I haven't looked into bhyve's soruce code to check if there are bug fixes in the 15- branch that are not backported to 14.3 or earlier.
 
Back
Top