virtio-devices: vhost_user: Support virtio-fs migration - #7937
Conversation
rbradford
commented
Mar 31, 2026
- 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]>
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
left a comment
There was a problem hiding this comment.
nice, first version already looking good!
48c3f93 to
b2befd9
Compare
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]>
b2befd9 to
87bfcbb
Compare
phip1611
left a comment
There was a problem hiding this comment.
Left a few remarks. Especially getting rid of the sleep(10s) would be great. WDYT?
| .args(["--tag", "myfs"]) | ||
| .spawn() | ||
| .unwrap(); | ||
| thread::sleep(std::time::Duration::new(10, 0)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Great idea - thanks! I split it into a function and switched the existing virtiofsd launching code to use that too.
87bfcbb to
5ece53c
Compare
Signed-off-by: Rob Bradford <[email protected]>
5ece53c to
8300fb0
Compare