Other Status of VirtFS

I'm wondering if anyone knows about the status of VirtFS/9p and its usability on FreeBSD. I cannot seem to find any clear information about it and few seem to have tried it or currently using it.

According to this there was an implementation 3 years ago stable enough for upstreaming. However without capability mode, meaning that bhyve has to be built without Capsicum support. There are however some comments regarding added capability mode later in the thread. It also seems like there still are some activity in this Github repo and a fork of it is included in the FreeNAS source tree. It's funded project. Are they missing funds to complete it? Is it being planned to be included in FreeBSD?

I'm a bit confused about the current status of this project and if it's possible to use with FreeBSD.
 
The examples on how to mount the filesystem in a guest seems to be Linux centric in most cases I've seen, is there a particular reason for this?

--

I'm using vm-bhyve to manage guests.

Configuration excerpt:
Code:
...
bhyve_options="-s 15,virtio-9p,sharename=/test"

vm-bhyve.log excerpt:
Code:
...
Apr 15 11:24:21:  [bhyve options: -c 8,sockets=1,cores=4,threads=2 -m 1G -Hwl bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd -s 15,virtio-9p,sharename=/test -U eeae286e-9dc6-11eb-a972-0025907b906a -u]
Apr 15 11:24:21:  [bhyve devices: -s 0,hostbridge -s 31,lpc -s 4:0,virtio-blk,/dev/zvol/system/vm/lab2/disk0 -s 5:0,virtio-net,tap6,mac=58:9c:fc:07:b8:fe -s 6:0,virtio-rnd]
Apr 15 11:24:21:  [bhyve console: -l com1,stdio]
Apr 15 11:24:21:  [bhyve iso device: -s 3:0,ahci-cd,/vm/.config/null.iso]
...

..and in my FreeBSD bhyve guest:
Code:
# dmesg | grep virtio
virtio_pci0: <VirtIO PCI (legacy) Block adapter> port 0x2000-0x207f mem 0xc0002000-0xc0003fff irq 17 at device 4.0 on pci0
vtblk0: <VirtIO Block Adapter> on virtio_pci0
virtio_pci1: <VirtIO PCI (legacy) Network adapter> port 0x2080-0x20bf mem 0xc0004000-0xc0005fff irq 18 at device 5.0 on pci0
vtnet0: <VirtIO Networking Adapter> on virtio_pci1
virtio_pci2: <VirtIO PCI (legacy) Entropy adapter> port 0x20c0-0x20df mem 0xc0006000-0xc0007fff irq 19 at device 6.0 on pci0
virtio_pci3: <VirtIO PCI (legacy) 9P Transport adapter> port 0x2200-0x23ff mem 0xc0008000-0xc0009fff irq 20 at device 15.0 on pci0
vtrnd0: <VirtIO Entropy Adapter> on virtio_pci2

Code:
# mount -t 9p -o trans=virtio -o version=9p2000.u sharename /mnt/
mount: sharename: Operation not supported by device
 
Are you sure there is actually a p9 client in FreeBSD?
I can't find it confirmed anywhere but I'm pretty sure the original reason for the examples being for Linux is that, while bhyve gained the ability to share a folder over p9, FreeBSD guests didn't actually have the ability to use it.
 
usdmatt:
You might just be right. Too bad if that's the case. I want to use it in a similar way as with nullfs in jails.

https://bsdfund.org/projects/ mentions "FreeBSD 9p client improvements as needed" as a future project. It implies that there's a client somewhere?
 
Hello.

I've started a bhyve / freebsd 13R VM,adding the virtio-9p driver between the bhyve parameters like this :

Code:
-s 9,virtio-9p,sharename=/ \

and then,inside the freebsd guest (it's the same version,13R),I have tried to mount the shared folder like this :

Code:
mount -t 9p -o cache=mmap -o msize=512000 sharename /mnt/9p

mount: sharename: Operation not supported by device

and :

Code:
mount -t 9p -o trans=virtio -o version=9p2000.u sharename /mnt/9p

mount: sharename: Operation not supported by device

do u know why ?
 
FreeBSD needs a kernel mode v9fs for this to work.

how can I achieve this ? it seems that the project is ready :

Screenshot_2022-02-16_11-03-45.png
 
Because you didn't read the thread you posted in.

client is not ready ? so,let me understand : someone created the 50% of the project only ? it's something like this : I went to buy a car and the dealer did not sell me the wheels because they were not created for that type of car ? sounds good.
 
The feature is fully functional with client systems that have a virtfs/9p client, so don't talk nonsense here. Running other systems in bhyve is arguably the more important usecase (cause otherwise, often a jail would do as well ... there are some exceptions of course)

Of course it would be awesome to have a virfs/9p client in FreeBSD as well. All I could find so far is this: https://github.com/swills/virtfs-9p-kmod -- unfortunately, it's just crashing when I try to use it with a recent -CURRENT.
 
The feature is fully functional with client systems that have a virtfs/9p client, so don't talk nonsense here. Running other systems in bhyve is arguably the more important usecase (cause otherwise, often a jail would do as well ... there are some exceptions of course)

Of course it would be awesome to have a virfs/9p client in FreeBSD as well. All I could find so far is this: https://github.com/swills/virtfs-9p-kmod -- unfortunately, it's just crashing when I try to use it with a recent -CURRENT.

how can I try it ? I've cloned the repo and then ? what should I do to try ?
 
It contains two modules below modules/virtio, just type "make" in both dirs to build the respective .ko files (requires /usr/src/sys of course). Still I don't see a reason why this code shouldn't crash on your machines. It's obviously unfinished and buggy.

(I might try asking swills@ directly about the status of this thing. Tried reaching him on IRC already many months ago, but wasn't lucky...)
 
It is the bhyve user program that maps 9p server side calls to filesystem syscalls (for the configured FS tree). The kernel module would have to do the opposite -- map filesystem calls to 9p client side calls. Sort of like how the nfs client module maps filesystem calls to NFS calls. This is much more involved. Ideally you'd want a proper 9p fs, separate from virtio. You sort of get that with devel/plan9port's 9fuse but only for accessing 9p filesystems over tcp/ip and it only talks 9p2000, not the 9p2000.L variant (what virtfs uses).

I will take a look at swill's github code when I get a chunk of free time.
 
Code:
@marietto:/home/marietto/Desktop/Scripts/virtfs-9p-kmod/sys/modules/virtio/9pfs # make

machine -> /usr/src/sys/amd64/include
x86 -> /usr/src/sys/x86/include
awk -f /usr/src/sys/tools/vnode_if.awk /usr/src/sys/kern/vnode_if.src -p
awk -f /usr/src/sys/tools/vnode_if.awk /usr/src/sys/kern/vnode_if.src -q
awk -f /usr/src/sys/tools/vnode_if.awk /usr/src/sys/kern/vnode_if.src -h
touch opt_global.h
Warning: Object directory not changed from original /usr/home/marietto/Desktop/Scripts/virtfs-9p-kmod/sys/modules/virtio/9pfs
cc  -O2 -pipe  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /usr/home/marietto/Desktop/Scripts/virtfs-9p-kmod/sys/modu
les/virtio/9pfs/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointe
r -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include     -MD  -MF.depend.virtfs_subr.o -MTv
irtfs_subr.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protecto
r -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__prin
tf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-bo
dy -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-membe
r -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -c /usr/home/marietto/Desktop/Scripts/virtfs-9p-kmod/sys/modules/virtio/9pfs/../.
./../dev/virtio/9pfs/virtfs_subr.c -o virtfs_subr.o
In file included from /usr/home/marietto/Desktop/Scripts/virtfs-9p-kmod/sys/modules/virtio/9pfs/../../../dev/virtio/9pfs/virtfs_subr.c:48:
/usr/home/marietto/Desktop/Scripts/virtfs-9p-kmod/sys/modules/virtio/9pfs/../../../dev/virtio/9pfs/virtfs_proto.h:33:10: fatal error: 'dev/virtio/
virtio_fs_9p.h' file not found
#include <dev/virtio/virtio_fs_9p.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.                                                                                 
*** Error code 1

Stop.
make: stopped in /usr/home/marietto/Desktop/Scripts/virtfs-9p-kmod/sys/modules/virtio/9pfs
 
Just a guess: try copying files in "virtfs-9p-kmod/sys" to directories relative to "/usr/src/sys" and then build the module. But a clean compile doesn't necessarily imply it will work right.

[Edit] With a few changes I managed to compile a recent -current kernel & it stays up under bhyve after loading the relevant modules but that doesn't mean much. This was just a "get things compiled with as little understanding as I can get away with" step. At least mount_virtfs or something equivalent is missing. I have asked swills for help. I will post an update if I make any real progress.
 
Did you install the other project?
That's not meant to be installed. It's a fork of FreeBSD (everyting) with some change to integrate the modules into the kernel tree. It was the first thing I found, I tried to port that changes from there to a recent -CURRENT myself and funnily came up with almost the same changes as thos in swills' repo.

But now I remember this was never meant to build "out of tree". You have to copy at least "dev/virtio" into the kernel tree (/usr/src/sys) yourself. Or maybe some symlinks would do as well.
 
Uf, it's a shame it doesn't work out of the box :( Anyone could help with how-to make happen if there was any success at all?
Trying to bhyve various systems/vm's (even freebsd as guest for consistency) and 9p for sharing would be perfect solution...
 
I don't care anymore. I've configured sshfs server and client between a Windows bhve VM as guest os and Freebsd 13R as host and it works like a charm. On FreeBSD I can show the Windows shared drives with this script :

Code:
#!/usr/local/bin/bash

/usr/local/bin/sshfs marietto@192.168.1.4:/C:/ "/mnt/sshfs/C"

thunar /mnt/sshfs/C
 
Uf, it's a shame it doesn't work out of the box :( Anyone could help with how-to make happen if there was any success at all?
Trying to bhyve various systems/vm's (even freebsd as guest for consistency) and 9p for sharing would be perfect solution...
Works with linux and with freebsd 12 as bhyve guest VMs. Doesnt work with freebsd 13 or -current as a guest.
 
Back
Top