vfio-user-pci: no migration blocker, a VM migrates and loses the device state
Host environment
-
Operating system: Ubuntu 22.04 (WSL2)
-
OS/kernel version: Linux 6.18.58.1-microsoft-standard-WSL2 x86_64
-
Architecture: x86
-
QEMU flavor: qemu-system-x86_64
-
QEMU version: QEMU emulator version 11.1.3 (built from the release tarball)
-
QEMU command line:
./qemu-system-x86_64 -M q35 -accel kvm -display none -nodefaults \ -object memory-backend-memfd,id=mem,size=512M,share=on \ -machine memory-backend=mem -m 512M \ -device '{"driver":"vfio-user-pci","socket":{"type":"unix","path":"/tmp/vfu.sock"}}' \ -monitor stdio
Emulated/Virtualized environment
- Operating system: none needed (SeaBIOS only, no boot disk)
- OS/kernel version: n/a
- Architecture: x86
Description of problem
A VM with a vfio-user-pci device can be live-migrated even though the vfio-user server does not support migration. QEMU accepts migrate, the migration completes, and the device's state is silently lost: the PCI config that the guest programmed (e.g. BAR addresses) is not transferred, and the server-side device state is not either. -only-migratable does not reject the device.
For comparison, a vfio-pci device without migration support gets a migration blocker (vfio_migration_realize() → vfio_block_migration()), and other non-migratable devices in the same build block migration as expected (e.g. ivshmem-plain with master=off: "Migration is disabled when using feature 'peer mode' in device 'ivshmem'").
Cause, from reading the 11.1.3 source:
vfio_pci_realize()(hw/vfio/pci.c) callsvfio_migration_realize(), which adds the blocker throughvfio_block_migration()when the device cannot migrate.vfio_user_pci_realize()(hw/vfio-user/pci.c) does not callvfio_migration_realize(), and nothing else in hw/vfio-user/ adds a blocker (migrate_add_blocker*()) or registers state.vfio_user_pci_opsonly carries the comment "No live migration support yet."- The
vfio-user-pciclass has nodc->vmsd(onlyvfio-pcisetsvfio_cpr_pci_vmstate), soqemu_savevm_state_blocked()does not catch it either. hw/vfio-user/container.cleavesdirty_pages_supported = false, andvfio_container_set_dirty_page_tracking()returns success in that case, so dirty tracking does not stop the migration either.
Note: simply adding the vfio_migration_realize() call is not enough as-is. vfio_migration_query_flags() issues a raw ioctl() on vbasedev->fd, which is -1 for vfio-user, so it would fail with EBADF (and only then block, for the wrong reason). The series "[PATCH v2 0/8] vfio-user: live migration support" (Hugo Komatsu, 2026-09-11, https://lore.kernel.org/qemu-devel/20260911140710.2348139-1-hugo.komatsu@nutanix.com/) routes the migration ioctls through io_ops and enables migration for vfio-user-pci; the last replies in that thread are from 2026-09-14. Until migration is supported, an explicit blocker in vfio_user_pci_realize() (through vbasedev->migration_blocker and migrate_add_blocker()) would prevent the silent state loss.
Steps to reproduce
-
Build the libvfio-user sample server
gpio-pci-idio-16(it registers no migration callbacks) and start it:./samples/gpio-pci-idio-16 /tmp/vfu.sock & -
Start QEMU with the command line above.
-
In the monitor:
(qemu) migrate "exec:cat > /dev/null" (qemu) info migrate Status: completedExpected:
migratefails because the vfio-user-pci device cannot migrate. -
Restart the server and QEMU, adding
-only-migratableto the command line. Expected: QEMU refuses to start. Actual: it starts (info statusshowsVM status: running). -
Migration to a second QEMU: start a second server on
/tmp/vfu2.sockand a second QEMU with the same command line (pointing at/tmp/vfu2.sock) plus-incoming unix:/tmp/mig.sock. Let SeaBIOS run on the source for a few seconds, thenmigrate unix:/tmp/mig.sock. Result:source before: 494f:0dc8 BAR2=0xc000 source: migration completed destination status: running destination after: 494f:0dc8 BAR2=unassigned(from
query-pcion both sides). The guest continues on the destination with a device whose BAR is no longer programmed.
A script that runs steps 3–5 plus the ivshmem control case over QMP is attached (repro.py), together with its output.
Additional information
- How this was found: while developing an out-of-tree vfio-user device server, with the help of an AI coding assistant (Claude) and the reproduction script mentioned above. The steps and the source analysis were checked by hand against QEMU 11.1.3. No QEMU code is proposed in this report.
- Tested on QEMU 11.1.3. The relevant code in hw/vfio-user/pci.c looked the same in 11.2.0-rc1 and master when read on GitLab (2026-11-25), but this was not rebuilt and re-run on master.
- vfio-user maintainers (MAINTAINERS, "VFIO-USER"): John Levon, Thanos Makatos, Cédric Le Goater.