Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fill out snapshot/restore support for vhost-user devices - #7908

Merged
rbradford merged 10 commits into
cloud-hypervisor:mainfrom
rbradford:202603/vhost-user-snapshot-restore
Mar 27, 2026
Merged

rbradford merged 10 commits into
cloud-hypervisor:mainfrom
rbradford:202603/vhost-user-snapshot-restore

Conversation

@rbradford

@rbradford rbradford commented Mar 26, 2026

Copy link
Copy Markdown
Member
  • virtio-devices: vhost_user: Consolidate device State into VhostUserState
  • virtio-devices: vhost_user: Add VhostUserCommon::state() helper
  • virtio-devices: vhost_user: Access acked_protocol_features directly
  • virtio-devices: vhost_user: Adapt state() to return Result
  • virtio-devices: vhost_user: Rename update_supports_migration
  • virtio-devices: vhost_user: Add get/set of backend state support
  • virtio-devices: vhost_user: Fetch and store the backend state/vring
  • virtio-devices: vhost_user: Add common code for restoring state
  • virtio-devices: vhost_user: Enable snapshot/restore for vhost-user-*
  • tests: Add snapshot/restore integration test for virtio-fs

See: #7850

@rbradford
rbradford force-pushed the 202603/vhost-user-snapshot-restore branch 2 times, most recently from 699eba3 to ac54f0d Compare March 26, 2026 23:01
@rbradford
rbradford marked this pull request as ready for review March 26, 2026 23:22
@rbradford
rbradford requested a review from a team as a code owner March 26, 2026 23:22
@rbradford

rbradford commented Mar 26, 2026

Copy link
Copy Markdown
Member Author

Currently only have test cover for virtiofsd (which I know uses the DEVICE_STATE extension). The test_ovs_dpdk test does a snapshot/restore for a vhost-user-net device. The per-device stuff is the same per device so if it works for virtio-fs...

I've also done a lot of manual testing with virtiofsd and this works well.

Comment thread virtio-devices/src/vhost_user/mod.rs Outdated
Each vhost-user device type had near identical State structs.
Deduplicate those by introducing a new common struct (and parameterising
it when it needs to embed a config member.) This will make it easier to
reuse more code in the future and to add more struct members to handle
the requirements of snapshot/restore.

These changes have been designed to have no impact on the existing
snapshot/restore state.

Signed-off-by: Rob Bradford <[email protected]>
With a common state structure for all vhost-user devices the state()
methods can also be refactored for reuse. This will make it easier to
add new common fields in the future for snapshot/restore.

Signed-off-by: Rob Bradford <[email protected]>
In GenericVhostUser's read_config and write_config, access
vu_common.acked_protocol_features directly instead of going through
the state() method which creates a struct. This removes creating the
struct just to access two fields that are already directly accessible.

Signed-off-by: Rob Bradford <[email protected]>
This is a refactoring step in preparation for fetching backend device
state via SET_DEVICE_STATE_FD which can fail.

Signed-off-by: Rob Bradford <[email protected]>
Rename update_supports_migration() to update_supported_features() as
this method will be extended to track additional capability flags beyond
just migration support (e.g. DEVICE_STATE for snapshot/restore.)

Signed-off-by: Rob Bradford <[email protected]>
@rbradford
rbradford force-pushed the 202603/vhost-user-snapshot-restore branch from ac54f0d to bd23c34 Compare March 27, 2026 10:53

@sboeuf sboeuf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!!

Comment thread virtio-devices/src/vhost_user/vu_common_ctrl.rs Outdated
The vhost-user protocol now has support for the backend to provide an
opaque blob of data (read or written through a pipe) that the VMM can
use to save/restore state after snapshot/restore or live migration.

It also adds a command for checking the backend accepts the uploaded
device state. One quirk of saving the state is that GET_VRING_BASE must
be used first to quiesce the state of the backend and flush any
in-flight requests. This then also requires saving that index for use on
the restore.

Signed-off-by: Rob Bradford <[email protected]>
Fetch the opaque device state from the backend and store it along with
the last vring used in the state used for the snapshot.

Signed-off-by: Rob Bradford <[email protected]>
Add a common method for validating the state (checking vrings &
device_state) and then restoring the backend state if present.

Signed-off-by: Rob Bradford <[email protected]>
Enable the DEVICE_STATE protocol feature negotiation for all vhost-user
devices (block, fs, net, and generic). Restoring the state (including
the backend state if present) and vrings.

Signed-off-by: Rob Bradford <[email protected]>
Add test_snapshot_restore_virtio_fs which validates that virtio-fs
continues to work correctly across a snapshot/restore cycle.

Signed-off-by: Rob Bradford <[email protected]>
@rbradford
rbradford force-pushed the 202603/vhost-user-snapshot-restore branch from bd23c34 to 322fac5 Compare March 27, 2026 13:14
@rbradford
rbradford enabled auto-merge March 27, 2026 13:14
@rbradford
rbradford added this pull request to the merge queue Mar 27, 2026
Merged via the queue into cloud-hypervisor:main with commit 0bc3ca1 Mar 27, 2026
37 checks passed
@rbradford
rbradford deleted the 202603/vhost-user-snapshot-restore branch March 28, 2026 00:07
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants