### Build and Install Linux Kernel Source: https://virtio-fs.gitlab.io/howto-qemu.html Build and install the configured Linux kernel and its modules within the guest VM. This process ensures the kernel is ready for use. ```bash make -j 8 && make -j 8 modules && make -j 8 modules_install && make -j 8 install ``` -------------------------------- ### Register and start the virtiofs service Source: https://virtio-fs.gitlab.io/howto-windows.html Commands to register the virtiofs service with automatic startup and initiate the service. ```cmd C:\> sc.exe create VirtioFsSvc binpath="(your binary location)\virtiofs.exe" start=auto depend="WinFsp.Launcher/VirtioFsDrv" DisplayName="Virtio FS Service" ``` ```cmd C:\> sc start VirtioFsSvc ``` -------------------------------- ### Start virtiofs daemon Source: https://virtio-fs.gitlab.io/howto-boot.html Launches the virtiofsd daemon to manage the shared directory socket. ```bash # virtiofsd --socket-path=/tmp/vhostqemu -o source=virtio-fs-root -o cache=none ``` -------------------------------- ### Start virtiofsd Daemon Source: https://virtio-fs.gitlab.io/howto-qemu.html Run the virtiofsd daemon, specifying the socket path and source directory for the shared filesystem. Cache options can also be set. ```bash /usr/libexec/virtiofsd --socket-path=/tmp/vhostqemu -o source=$TESTDIR -o cache=always ``` -------------------------------- ### Clone QEMU for virtiofs Development Source: https://virtio-fs.gitlab.io/howto-qemu.html Clone the QEMU repository if you need to build it from source for development purposes, particularly for modifying vhost-user-fs device setup. ```bash git clone https://gitlab.com/qemu-project/qemu.git ``` -------------------------------- ### Configure and Build QEMU Source: https://virtio-fs.gitlab.io/howto-qemu.html Configure QEMU with the specified target list and build it. This step is typically needed for development or if a specific version is required. ```bash ../configure --prefix=$PWD --target-list=x86_64-softmmu make -j 8 ``` -------------------------------- ### QEMU Device Instantiation for virtiofs Source: https://virtio-fs.gitlab.io/howto-qemu.html Instantiate the vhost-user-fs-pci device in QEMU, linking it to the defined character device and setting a tag that must match the guest's mount command. ```bash -device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=myfs ``` -------------------------------- ### Full QEMU Command for virtiofs Source: https://virtio-fs.gitlab.io/howto-qemu.html A complete QEMU command line to launch a VM with virtiofs enabled, including memory sharing, the virtiofs device, and a root filesystem image. ```bash 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=rootfsimage.qcow2 ``` -------------------------------- ### Create Fedora root file system Source: https://virtio-fs.gitlab.io/howto-boot.html Initializes a directory to serve as the root file system for the guest. ```bash # mkdir virtio-fs-root # dnf --installroot=$PWD/virtio-fs-root --releasever=29 install system-release vim-minimal systemd passwd dnf rootfiles # $EDITOR virtio-fs-root/etc/shadow # set password or allow password-less root login ``` -------------------------------- ### Set QEMU kernel parameters Source: https://virtio-fs.gitlab.io/howto-boot.html Defines the root file system type and mount options for the guest kernel. ```bash -append "rootfstype=virtiofs root=myfs rw" ``` -------------------------------- ### Configure QEMU kernel path Source: https://virtio-fs.gitlab.io/howto-boot.html Specifies the location of the guest kernel image for QEMU. ```bash -kernel path/to/bzImage ``` -------------------------------- ### Mount virtiofs with DAX in Guest Source: https://virtio-fs.gitlab.io/howto-qemu.html Mount the virtiofs filesystem with the 'dax' option enabled in the guest. This requires kernel support and the corresponding QEMU device configuration. ```bash mount -t virtiofs myfs /mnt -o dax ``` -------------------------------- ### Mount virtiofs Filesystem in Guest Source: https://virtio-fs.gitlab.io/howto-qemu.html Mount the virtiofs filesystem within the guest VM using the tag specified in the QEMU configuration. This makes the shared directory accessible. ```bash mount -t virtiofs myfs /mnt ``` -------------------------------- ### QEMU Configuration for virtiofs Socket Source: https://virtio-fs.gitlab.io/howto-qemu.html Define a character device in QEMU to establish a socket connection with the virtiofsd daemon. The path must match the one used by virtiofsd. ```bash -chardev socket,id=char0,path=/tmp/vhostqemu ``` -------------------------------- ### QEMU Device Configuration for DAX Source: https://virtio-fs.gitlab.io/howto-qemu.html Modify the vhost-user-fs-pci device configuration in QEMU to enable DAX (Direct Access) by specifying a cache size. This improves performance for certain workloads. ```bash -device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=myfs,cache-size=2G ``` -------------------------------- ### Alternative Mount Syntax with DAX for Older Kernels (Pre-4.19) Source: https://virtio-fs.gitlab.io/howto-qemu.html This demonstrates the mount syntax for virtiofs with DAX enabled on Linux kernels older than 4.19. It includes the 'dax' option along with the older format for other parameters. ```bash mount -t virtio_fs none /mnt -o tag=myfs,rootmode=040000,user_id=0,group_id=0,dax ``` -------------------------------- ### QEMU Memory Sharing Configuration Source: https://virtio-fs.gitlab.io/howto-qemu.html Configure QEMU to use memory sharing with virtiofsd by creating a memory backend file in /dev/shm. This is crucial for efficient data transfer. ```bash -m 4G -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on -numa node,memdev=mem ``` -------------------------------- ### Alternative Mount Syntax for Older Kernels (Pre-4.19) Source: https://virtio-fs.gitlab.io/howto-qemu.html This shows the mount syntax for virtiofs on Linux kernels older than 4.19, which required a different format for specifying options like tag, rootmode, user_id, and group_id. ```bash mount -t virtio_fs none /mnt -o tag=myfs,rootmode=040000,user_id=0,group_id=0 ``` -------------------------------- ### Clone and Build virtiofsd Source: https://virtio-fs.gitlab.io/howto-qemu.html Clone the virtiofsd repository and build the release version using Cargo. This daemon is essential for virtiofs functionality. ```bash git clone https://gitlab.com/virtio-fs/virtiofsd.git cd virtiofsd cargo build --release ``` -------------------------------- ### Configure Kernel for virtiofs Source: https://virtio-fs.gitlab.io/howto-qemu.html Select the necessary configuration options for the Linux kernel to enable virtiofs support. CONFIG_VIRTIO_FS is required, and CONFIG_FUSE_DAX is optional. ```bash CONFIG_VIRTIO_FS CONFIG_FUSE_DAX # optional ``` -------------------------------- ### Clone Linux Kernel for virtiofs Source: https://virtio-fs.gitlab.io/howto-qemu.html Clone the Linux kernel repository to build a guest kernel with virtiofs support. Ensure your kernel version is 5.4 or later. ```bash git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.