Re: VFS mount rollback for virtio 9pfs

From: Navdeep Parhar <np_at_freebsd.org>
Date: Mon, 17 Oct 2022 23:07:44 UTC
On Mon, Oct 17, 2022 at 3:33 PM Bakul Shah <bakul@iitbombay.org> wrote:
>
> On Oct 13, 2022, at 6:01 PM, Daniel O'Connor <darius@dons.net.au> wrote:
> >
> > It's come to my attention that someone else also ported this:
> > https://github.com/swills/virtfs-9p-kmod
> >
> > I was wondering if you would be interesting in trying and seeing how it fairs. Unfortunately I am not in a position to do a test poudriere with it as yet.
>
> FWIW I played with swills port a few months ago. It worked on -12 but
> failed on -13 and -current (panics on kldload). I didn't investigate
> it further. Tested in bhyve.

I tried the github.com/swills/virtfs-9p-kmod repository very recently
and had better luck with it.  I had to make these changes to the code
to get it to compile on latest main:
https://people.freebsd.org/~np/9pfs/  After that I was able to mount
/usr/{src,obj} read-only in the FreeBSD VM.  I've done a number of
installworld/installkernel inside the VM since then without any
apparent problems (except the warnings about read-only /usr/src during
installkernel -- those have nothing to do with 9pfs)

These are the entries in the vm.conf file on the host that export
these directories (I use vm-bhyve):
disk2_type="virtio-9p"
disk2_dev="custom"
disk2_name="src=/usr/src,ro"
disk3_type="virtio-9p"
disk3_dev="custom"
disk3_name="obj=/usr/obj,ro"

This is what I have in the VM's /etc/fstab:
src    /usr/src    virtfs    trans=virtio,ro,late    0    0
obj    /usr/obj    virtfs    trans=virtio,ro,late    0    0

This in /etc/rc.conf in the VM:
kld_list="virtio_9pfs"

Regards,
Navdeep

>
> Note that bhyve on 13.1-stable does work with a linux guest:
> ubuntu# mount -t 9p -o trans=virtio,version=9p2000.L,rw,cache=mmap sharename /opt
> ubuntu# dd < largefile >/dev/null bs=1M count=1000
> 1000+0 records in
> 1000+0 records out
> 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.65227 s, 287 MB/s
>
> I took your port & copied relevant files to a -current tree
> (8cee2ebac54a). I had to hack a few things to compile[1]. kldload
> doesn't crash as with swills port but mount fails:
>
> # mount -t virtio -o trans=virtio sharename /mnt
> mount: sharename: Operation not supported by device
>
> Note that the same line works fine on -12, with swill's changes.
>
> Relevant bhyve line:
>         -s 8,virtio-9p,sharename=mydir \
>
> Given that mount on ubuntu works seems the problem must be elsewhere
> and not 9p2000.L vs 9p2000.u (as you surmised in the original msg in
> this thread). I even changed code in the driver to unconditionally
> pass 9p2000.L but that didn't help.
>
> [1] Fixed up module Makefiles and had to add
> #define SAVENAME        0x00000400 /* save pathname buffer */
> to 9pfs/virtiofs_vnops.c
>
> As only this define from namei.h seemed to be somehow lost.
>
>
>
>
>
>