vfio-user: implement migration v2 (device-feature + DMA logging)#156
Draft
maxpain wants to merge 1 commit into
Draft
vfio-user: implement migration v2 (device-feature + DMA logging)#156maxpain wants to merge 1 commit into
maxpain wants to merge 1 commit into
Conversation
d4bac80 to
e91f213
Compare
Add the vfio-user migration v2 wire protocol, byte-compatible with
libvfio-user include/vfio-user.h:
- Command::{DeviceFeature=16, MigDataRead=17, MigDataWrite=18} and the
VFIO_DEVICE_STATE_* / VFIO_DEVICE_FEATURE_* / VFIO_MIGRATION_* constants.
- Server dispatch for the device-state FSM, MIG_DATA streaming (a short read
marks end-of-stream, per the spec), and DMA dirty logging; wire-controlled
allocations are bounded.
- ServerBackend hooks (migration_flags, migration_{set,get}_state,
migration_{read,write}_data, dma_logging_{start,stop,report}) and matching
Client methods. The backend owns FSM transition validity; the server forwards
the requested target state to it, as vfio-ioctls does for kernel VFIO.
- An integration test driving the FSM, MIG_DATA round-trip and DMA-logging
bitmap over a socketpair.
Non-migratable backends are unaffected: the new commands stay rejected.
The integration test also raises workspace line coverage, so bump
coverage_config_x86_64.json accordingly.
Signed-off-by: Max Makarov <maxpain@linux.com>
Assisted-by: Claude:Opus-4.8
e91f213 to
5d3da4d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds the vfio-user migration v2 wire protocol to the
vfio-usercrate, byte-compatiblewith libvfio-user's
include/vfio-user.hand the kernelVFIO_DEVICE_FEATUREmigration uAPI. It isthe foundational piece for VMM-driven live migration of vfio-user devices — the same
VfioMigrationStatesemantics the kernel-VFIO path already uses, carried over the socket.What's added
VFIO_USER_DEVICE_FEATURE(16),VFIO_USER_MIG_DATA_READ(17),VFIO_USER_MIG_DATA_WRITE(18), plus theVFIO_DEVICE_STATE_*/VFIO_DEVICE_FEATURE_*/VFIO_MIGRATION_*constants.end-of-stream, per the protocol), and DMA dirty logging. Wire-controlled allocations are bounded.
ServerBackendgains default-erroring hooks (migration_flags,migration_{set,get}_state,migration_{read,write}_data,dma_logging_{start,stop,report}).The backend owns FSM transition validity — the server forwards the requested target state to it,
the same way
vfio-ioctlsdoes for kernel VFIO.Clientgains the matching methods so a VMM can drive migration.socketpair.
Non-migratable backends are unaffected: the new commands stay rejected.
Testing
cargo test,cargo fmt -- --check, andcargo clippy --all-featuresare clean.coverage_config_x86_64.jsonis updated accordingly.Context
This lets a VMM live-migrate a vfio-user device (e.g. an emulated NVMe controller) using the
migration-v2 model that landed for kernel VFIO. A Cloud-Hypervisor consumer
(
Migratable for VfioUserPciDevice) is a follow-up that builds on this.