vdev virtio-fs

Updated: April 19, 2023

Emulate a virtual filesystem that supports the FUSE protocol

Synopsis

vdev virtio-fs [directio enabled]
               [host_path dir]
               [loc addr intr guest_intr]
               [num_req_queues num]
               [sched priority]
               [tag name]

Options

directio enabled
Whether direct I/O support is enabled. When this option is true, the FUSE daemon is launched with this feature enabled. If the directory you share is managed by a resource manager such as pps, enabling direct I/O may be needed to make certain functionality work correctly; for example, blocking reads like this one:
cat /data/qnxhost/services/networking/status_public?wait,delta
host_path dir
The host directory to be shared with a guest through the virtual filesystem. The contents of this directory will appear under the mountpoint chosen by the guest.

A root user can create and share any directory they want. Guest applications don't need extra permissions; if they have permission to access the mountpoint, they can access the host directory files as though they were local files.

intr guest_intr
Set the guest interrupt for this virtual device; include this option only if you also include the loc option.

The guest_intr argument consists of two colon-separated components:

  1. the identifier of the name of the guest device Progammable Interrupt Controller (PIC)
  2. the input line that is asserted when the interrupting device wishes to raise an interrupt

For example: gic:43

For more information on setting guest interrupts, see the section on “Configuring guests” in the QNX Hypervisor User's Guide.

loc addr
Set the device space address to addr. The addr argument is typically specified in hexadecimal.

If you include this option, the vdev presents itself to the guest as a memory-mapped I/O (MMIO) device at the location specified by addr. Otherwise, the vdev presents itself as a PCI device.

You must use this option with the intr option.

num_req_queues num
The number of request queues to be created.
sched priority
Set the priority of the pulses that the VM generates to indicate that new input is available. The default is 10.

In most cases, you can omit this option.

tag name
The name of the virtual filesystem. When mounting the filesystem, guests must refer to it by this name.

Description

(ARM and x86) The virtio-fs vdev emulates a virtual filesystem in which host directories become accessible to a guest as though they were local directories. The guest can access files in the virtual filesytem and perform operations such as read(), write(), and stat(). In the guest, the driver for the vdev encapsulates the filesystem requests using the Filesystem in USErspace (FUSE) protocol. In the host, the vdev interacts with a FUSE daemon to carry out these requests, and passes the responses from this daemon back to the guest.

Normally, the vdev appears as a PCI device on x86. But if you specify the loc and intr options, the guest will see the vdev as a memory-mapped I/O (MMIO) device at the location specified by loc.

You can define multiple virtio-fs instances; each instance can share one host directory with one guest. Many guests can access the same shared directory but each can choose its own mountpoint for this directory.

Example

Suppose the host wants to share its /etc directory with a guest. In the configuration file for the guest's VM, a virtio-fs vdev instance must be configured with host_path set to /etc:

vdev virtio-fs
  loc 0x1c0fe000
  intr gic:56
  tag qhostfs    # Tag to use in the guest's mount command.
  num_req_queues 1
  host_path /etc # If you set this to a resource manager path (e.g., /pps),
                 # set directio to "true" below.
  directio false # Set to "true" to pass -D to the FUSE deamon.

The loc and intr options mean the vdev will appear as an MMIO device, at the guest-physical address of 0x1c0fe000, and will use a PIC name of gic and interrupt line 56. For more information about these options, see “Common vdev options” in the QNX Hypervisor User's Guide.

Because the directory being shared is not managed by a resource manager in this case, we set directio to false. We also set num_req_queues to 1 to use just one request queue.

The vdev configuration assigns a tag of qhostfs for the shared directory. The guest must then use this tag name when creating the mountpoint for the virtual filesystem through which it will access that host directory. Note that the guest may have to create the corresponding local directory before defining the mountpoint, as follows:

mkdir /mnt/user/10/emulated/10/Download/qnx_host
mount -t virtiofs qhostfs /mnt/user/10/emulated/10/Download/qnx_host