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

Skip to content

virtio-devices: vhost_user: Support virtio-fs migration - #7937

Merged
rbradford merged 8 commits into
cloud-hypervisor:mainfrom
rbradford:202603/vhost-user-migration
Apr 1, 2026
Merged

rbradford merged 8 commits into
cloud-hypervisor:mainfrom
rbradford:202603/vhost-user-migration

Conversation

@rbradford

Copy link
Copy Markdown
Member
  • virtio-devices: Embed VirtioCommon in VhostUserCommon
  • virtio-devices: Move epoll_thread to VhostUserCommon
  • virtio-devices: vhost_user: Correctly shutdown epoll thread
  • virtio-devices: vhost_user: Use the VhostUserHandle enum for LOG_ALL
  • virtio-devices: Reject dirty logging if backend does not support it
  • virtio-devices: vhost_user: Advertise LOG_ALL feature
  • virtio-devices: Reuse common shutdown code in drop implementations
  • tests: Add live migration test for virtio-fs

Since vhost-user devices are always virtio devices it makes sense to
structure this struct inside the VhostUserCommon struct. This then also
makes some of the methods on VhostUserCommon cleaner since they can now
act directly on the common virtio bits (e.g. for kill_evt)

Signed-off-by: Rob Bradford <[email protected]>
This is used by all devices so it can be part of the common state.
Moving it simplifies the code and simplifies some future improvements
around shutdown for migration.

Signed-off-by: Rob Bradford <[email protected]>
If the epoll thread is paused, which would be expected as a part of live
migration/snapshot-restore unpause the thread so that it can receive the
kill event. This mirrors the reset() behaviour of virtio devices. It is
important here so as to close the connection with the vhost-user-backend
to allow same host and --local migration and since after getting the
device state the vhost-user backend should no longer be used.

As a result of this change we can do --local and same-host migration
with virtio-fs.

Signed-off-by: Rob Bradford <[email protected]>
This is equivalent value but removes the need to manually use the
constant to shift.

Signed-off-by: Rob Bradford <[email protected]>
Advertising support for this virtio feature is required to enable
support for migration. (Along with the LOG_SHMFD protocol feature.)

Signed-off-by: Rob Bradford <[email protected]>

@phip1611 phip1611 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.

nice, first version already looking good!

Comment thread virtio-devices/src/vhost_user/blk.rs Outdated
@rbradford
rbradford force-pushed the 202603/vhost-user-migration branch from 48c3f93 to b2befd9 Compare March 31, 2026 17:51
Now that the VhostUserCommon::shutdown implementation has been filled
out to support migration it can also be used for the drop
implementations in the vhost-user devices.

It's worth noting that the call to wait_for_epoll_threads() was a no-op
as those threads are only configured on conventional virtio devices.

Signed-off-by: Rob Bradford <[email protected]>
@rbradford
rbradford force-pushed the 202603/vhost-user-migration branch from b2befd9 to 87bfcbb Compare March 31, 2026 18:59
@rbradford
rbradford marked this pull request as ready for review March 31, 2026 18:59
@rbradford
rbradford requested a review from a team as a code owner March 31, 2026 18:59

@phip1611 phip1611 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.

Left a few remarks. Especially getting rid of the sleep(10s) would be great. WDYT?

Comment thread cloud-hypervisor/tests/integration.rs Outdated
.args(["--tag", "myfs"])
.spawn()
.unwrap();
thread::sleep(std::time::Duration::new(10, 0));

@phip1611 phip1611 Apr 1, 2026

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.

I'm concerned about all the sleeps in the code base. They make the integration test suite all in all much slower on the happy path / on fast machines.

I think we should add helpers to gracefully wait for certain events to happen (but that's another story, see #7891)

I think a solid workaround could be:

// Wait for virtiofds to start
let deadline = Instant::now() + Duration::from_secs(10);
while !Path::new(&virtiofsd_socket_clone).exists() {
    if Instant::now() > deadline {
        panic!("virtiofsd socket did not appear within 10s");
    }
    thread::sleep(Duration::from_millis(50));
}

a little more verbose, however but the test suite will execute ~18s quicker on fast machines

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Great idea - thanks! I split it into a function and switched the existing virtiofsd launching code to use that too.

Comment thread cloud-hypervisor/tests/integration.rs Outdated
Comment thread cloud-hypervisor/tests/integration.rs Outdated
@rbradford
rbradford force-pushed the 202603/vhost-user-migration branch from 87bfcbb to 5ece53c Compare April 1, 2026 09:17

@rbradford rbradford left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @phip1611

Comment thread cloud-hypervisor/tests/integration.rs Outdated
Comment thread cloud-hypervisor/tests/integration.rs Outdated

@phip1611 phip1611 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.

LGTM now, thanks!

@rbradford
rbradford force-pushed the 202603/vhost-user-migration branch from 5ece53c to 8300fb0 Compare April 1, 2026 09:25
@rbradford
rbradford enabled auto-merge April 1, 2026 09:25
@rbradford
rbradford added this pull request to the merge queue Apr 1, 2026
Merged via the queue into cloud-hypervisor:main with commit a99c40d Apr 1, 2026
38 checks passed
@rbradford
rbradford deleted the 202603/vhost-user-migration branch April 1, 2026 14:28
@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.

2 participants