The QEMU firmware configuration device (also exposed by bhyve) is a
device for injecting data into virtual machines. It provides a simple
map from 16-bit numbers (selectors) to blobs. A small number of
selectors have well-defined meanings, including one that provides names
(which may contain slashes and be modelled as paths) for the dynamically
allocated set.
This commit includes two parts:
- A NetBSD-compatible qemufwcfg driver.
- A FUSE filesystem that talks to the driver.
Linux provides an in-kernel filesystem for translating qemu firmware
configuration blobs things into a directory tree of files. NetBSD
adopts a model that better respects the principle of least privilege and
provides a very simple in-kernel driver that handles the low-level
device I/O but delegates the filesystem parts to userspace.
This kernel driver is not a port of the NetBSD one but is directly
inspired by it and provides a compatible interface. The NetBSD FUSE
filesystem can run on top of it.
The NetBSD FUSE filesystem brings in a lot of complexity via libfuse,
which is not in the FreeBSD base system. libfuse is designed for
implementing high-performance multi-threaded FUSE filesystems. This is
overkill for a read-only filesystem intended for providing rarely-read
small data. Instead, this implements a very simple single-threaded
version with no dependencies outside of the base system. This runs in
Capsicum mode, with no ability to access anything other than stderr, the
(opened) fuse device and the qemufwcfg device.