No description
  • C 60.9%
  • Python 36.6%
  • Meson 1.4%
  • Shell 0.8%
  • Makefile 0.3%
Find a file
Andre Devay 2e888540fe
Remove stale comments: migration-region docs and errno/fcntl FIXMEs (#912)
Live migration no longer uses a device region: it is set up with
vfu_setup_device_migration_callbacks() and driven by the
VFIO_USER_DEVICE_FEATURE / MIG_DATA_READ / MIG_DATA_WRITE messages.

Drop the comments that still describe the old region-based interface:

- the vfu_setup_region() documentation for VFU_PCI_DEV_MIGR_REGION_IDX /
  VFU_GENERIC_DEV_MIGR_REG_IDX, which refers to symbols (struct
  vfio_user_migration_info, vfu_get_migr_register_area_size(),
  vfu_setup_device_migration()) that no longer exist
- the FIXME in vfu_create_ctx() about always allocating a migration
  region

The "fcntl can overwrite recv's errno" FIXMEs in tran_sock_recv_fds()
and tran_pipe_recv() date from when a recv_blocking() helper toggled
O_NONBLOCK with fcntl() around recv(). That helper is gone: neither
get_msg() nor tran_pipe_get_msg() calls fcntl(), and both return
straight after a failed recvmsg()/read(), so errno is preserved.

Fixes #870

Signed-off-by: Andre Devay <andretorresdg@alumni.usp.br>
2026-12-02 22:38:08 +00:00
.github Remove debian:11 CI build (#880) 2026-09-08 12:10:36 +01:00
docs docs: fix QEMU device JSON and image download commands (#911) 2026-11-30 10:13:07 +00:00
include Remove stale comments: migration-region docs and errno/fcntl FIXMEs (#912) 2026-12-02 22:38:08 +00:00
lib Remove stale comments: migration-region docs and errno/fcntl FIXMEs (#912) 2026-12-02 22:38:08 +00:00
samples Fix Coverity nits (#924) 2026-12-02 17:03:57 +00:00
scripts cleanup scripts (#850) 2026-04-15 19:40:49 +01:00
test Fix Coverity nits (#924) 2026-12-02 17:03:57 +00:00
.clangd Add .clangd to point at Meson's compile_commands.json (#867) 2026-06-25 15:39:29 +01:00
.ctags exclude build dir in ctags (#577) 2021-07-09 08:31:48 +01:00
.gitignore add a gcov target (#498) 2021-05-25 15:09:03 +01:00
.gitmodules remove libparthtrap and libvfio 2020-11-02 04:23:45 -05:00
LICENSE add a github-recognised LICENSE file 2020-11-18 09:14:18 +00:00
Makefile cleanup scripts (#850) 2026-04-15 19:40:49 +01:00
meson.build De-duplicate file descriptors used for DMA region access (#841) 2026-04-07 17:52:18 +01:00
meson_options.txt avoid vfu_log() in SGL hot path (#705) 2022-08-18 10:58:58 +01:00
README.md Rework documentation (#817) 2025-10-10 11:13:28 +01:00

libvfio-user

vfio-user is a framework that allows implementing PCI devices in userspace. Clients (such as qemu) talk the vfio-user protocol over a UNIX socket to a server. This library, libvfio-user, provides an API for implementing such servers.

vfio-user example block diagram

VFIO is a kernel facility for providing secure access to PCI devices in userspace (including pass-through to a VM). With vfio-user, instead of talking to the kernel, all interactions are done in userspace, without requiring any kernel component; the kernel VFIO implementation is not used at all for a vfio-user device.

Put another way, vfio-user is to VFIO as vhost-user is to vhost.

The vfio-user protocol is intentionally modelled after the VFIO ioctl() interface, and shares many of its definitions. However, there is not an exact equivalence: for example, IOMMU groups are not represented in vfio-user.

There many different purposes you might put this library to, such as prototyping novel devices, testing frameworks, implementing alternatives to qemu's device emulation, adapting a device class to work over a network, etc.

The library abstracts most of the complexity around representing the device. Applications using libvfio-user provide a description of the device (eg. region and IRQ information) and as set of callbacks which are invoked by libvfio-user when those regions are accessed.

Memory Mapping the Device

The device driver can allow parts of the virtual device to be memory mapped by the virtual machine (e.g. the PCI BARs). The business logic needs to implement the mmap callback and reply to the request passing the memory address whose backing pages are then used to satisfy the original mmap call; more details here.

Interrupts

Interrupts are implemented via eventfd's passed from the client and registered with the library. libvfio-user consumers can then trigger interrupts by writing to the eventfd.

Building libvfio-user

Build requirements:

  • meson (v0.53.0 or above)
  • apt install libjson-c-dev libcmocka-dev or
  • yum install json-c-devel libcmocka-devel

The kernel headers are necessary because VFIO structs and defines are reused.

To build:

meson build
ninja -C build

Finally build your program and link with libvfio-user.so.

Using the library

qemu

Step-by-step instructions for using libvfio-user with qemu can be found here.

See also libvirt.

SPDK

SPDK uses libvfio-user to implement a virtual NVMe controller: see SPDK and libvfio-user for more details.

Developing with the library

See Developing with libvfio-user.

Mailing List & Chat

libvfio-user development is discussed in libvfio-user-devel@nongnu.org. Subscribe here: https://lists.gnu.org/mailman/listinfo/libvfio-user-devel.

We are on Slack at libvfio-user.slack.com (invite link); or IRC at #qemu on OFTC.

Contributing

Contributions are welcome; please file an issue or open a PR. Anything substantial is worth discussing with us first.

Please make sure to mark any commits with Signed-off-by (git commit -s), which signals agreement with the Developer Certificate of Origin v1.1.

Running make pre-push will do the same checks as done in github CI. After merging, a Coverity scan is also done.

See Testing for details on how the library is tested.

History

This project was formerly known as "muser", short for "Mediated Userspace Device". It implemented a proof-of-concept VFIO mediated device in userspace. Normally, VFIO mdev devices require a kernel module; muser implemented a small kernel module that forwarded onto userspace. The old kernel-module-based implementation can be found in the kmod branch.