https://virtio-fs.gitlab.io/howto-qemu.html
virtio-fs
环境:
- A Linux 5.4 or later guest kernel with virtiofs support
- QEMU 4.2.0 or later for built-in virtiofs support
- virtiofsd
guest kernel
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
CONFIG_VIRTIO_FS
CONFIG_FUSE_DAX # optional
make -j 8 && make -j 8 modules && make -j 8 modules_install && make -j 8 install
Building QEMU
git clone https://gitlab.com/qemu-project/qemu.git
cd qemu
mkdir build && cd build
../configure --prefix=$PWD --target-list=x86_64-softmmu
make -j 8 && make install
Create qcow2 img
qemu-img create -f qcow2 rootfsimage.qcow2.img 10G
Building virtiofsd
git clone https://gitlab.com/virtio-fs/virtiofsd.git
cd virtiofsd
cargo build --release
Running with virtiofs
qemu-img create -f qcow2 test-qcow2.img 10G
/usr/libexec/virtiofsd --socket-path=/tmp/vhostqemu -o source=$TESTDIR -o cache=always
qemu-system-x86_64 -M pc -cpu host --enable-kvm -smp 2 \
-m 4G -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on -numa node,memdev=mem \
-chardev socket,id=char0,path=/tmp/vhostqemu -device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=myfs \
-chardev stdio,mux=on,id=mon -mon chardev=mon,mode=readline -device virtio-serial-pci -device virtconsole,chardev=mon -vga none -display none \
-drive if=virtio,file=test-qcow2.qcow2
#guest os
mount -t virtiofs myfs /mnt
Enabling DAX
-device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=myfs,cache-size=2G
#guest os
mount -t virtiofs myfs /mnt -o dax