Repository navigation
Conversation
Snapshotting a microVM with a vhost-user block device skipped the device entirely, so a restored microVM had no data drive. Save the device like any other virtio device. Before its state is saved, stop the ring with VHOST_USER_GET_VRING_BASE: the backend completes what it took into the used ring and replies with the next available index, which becomes the queue's saved position. On restore, connect to the socket again, require the features negotiated before, and hand the ring over at that index. Resuming the same microVM after a snapshot restarts the ring the same way. A backend needs guest memory it can map, so restoring from a File memory backend copies the snapshot's memory into a memfd and maps it shared. Mapping the file itself would let guest writes change the snapshot. Restoring with Uffd is refused for microVMs with vhost-user devices. vCPU and transport state are saved before devices, so a completion the backend writes in between finds the interrupt state already saved. Raise the queue interrupt once on resume so the guest sees it. Also offer SIZE_MAX, SEG_MAX, BLK_SIZE, DISCARD and WRITE_ZEROES when the backend does, and send the queue's next available index as the ring base rather than the guest's available index.
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.
Prototype: snapshot and restore for vhost-user-blk devices. Today a snapshot skips them, so a restored microVM comes back without its data drive.
What changes
VHOST_USER_GET_VRING_BASE. The backend completes what it took into the used ring and replies with the next available index, which becomes the queue's saved position.RestoreFeatureserror otherwise), and hand the ring over at the saved index. Resuming the same microVM after a snapshot restarts the ring the same way.SET_VRING_BASEnow sends the queue's next available index rather than the guest's available index.Filememory backend copies the snapshot's memory into a memfd and maps it shared.Uffdis refused for microVMs with vhost-user devices.SIZE_MAX,SEG_MAX,BLK_SIZE,DISCARDandWRITE_ZEROESare offered when the backend offers them.No seccomp changes: device restore runs before the filter is installed, and stopping and restarting the ring only uses
sendmsg/recvmsg.Not done
Testing
test_device_manager_persistence, which fails attaching pmem before any block code runs. That looks environmental and pre-existing, but it has not been checked on the base commit.