vhost-user-vsock: enable savevm/loadvm for VM snapshots - #13
Open
omerzlabs wants to merge 1 commit into
Open
Conversation
omerzlabs
force-pushed
the
feat/vhost-user-vsock-savevm
branch
from
April 7, 2026 17:48
4a04b4e to
b106574
Compare
vhost-user-vsock was marked as unmigratable, blocking savevm/loadvm even though the parent class (vhost-vsock-common) already provides correct save/restore hooks. This patch enables in-process VM snapshots for configurations using vhost-user-vsock-pci (e.g., vsock-based port forwarding in Penguin). Two changes to hw/virtio/vhost-user-vsock.c: 1. Replace the empty unmigratable VMStateDescription with a proper one that reuses vhost_vsock_common_pre_save (asserts backend is stopped) and vhost_vsock_common_post_load (sends VIRTIO_VSOCK_EVENT_TRANSPORT_RESET so the guest kernel reconnects vsock sockets). This matches the kernel-backed vhost-vsock variant exactly. 2. Remove the vhost-level migration blocker after vhost_dev_init(). The blocker exists because the vhost-user backend lacks VHOST_F_LOG_ALL (dirty-page tracking for live migration). For savevm/loadvm, dirty tracking is unnecessary — the VM is paused and state is captured atomically. Since PANDA uses paused in-process snapshots and does not perform live migration, removing this blocker is safe. Note: migrate_del_blocker() removes the blocker for all migration modes, not just snapshots. If live migration support is ever added for this device, the blocker handling should be revisited. Tested with: - make check (unit): 97 pass / 0 fail / 4 skip (unchanged) - migration-test (qtest): 40 subtests pass (unchanged) - savevm with vhost-user-vsock-pci enabled: succeeds - loadvm from snapshot: VM restores, transport reset delivered
omerzlabs
force-pushed
the
feat/vhost-user-vsock-savevm
branch
from
April 7, 2026 17:49
b106574 to
3081c0a
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 patch enables
savevm/loadvmfor thevhost-user-vsockdevice, allowing VM snapshots when vsock-based networking is in use (e.g., Penguin's VPN port forwarding).Currently
vhost-user-vsockis marked as non-migratable, blocking all snapshot operations even though the parent class (vhost-vsock-common) already provides correct save/restore hooks. The kernel-backed variant (vhost-vsock) uses these hooks and is fully migratable. This patch bringsvhost-user-vsockto parity.Changes
Single file:
hw/virtio/vhost-user-vsock.c(19 lines added, 1 removed)1. Replace unmigratable VMStateDescription with a proper one
The empty
vuv_vmstatewith.unmigratable = 1is replaced with a vmstate that:VMSTATE_VIRTIO_DEVICE(virtio ring state, features, config)vhost_vsock_common_pre_save()— asserts the vhost backend is stopped before savevhost_vsock_common_post_load()— sendsVIRTIO_VSOCK_EVENT_TRANSPORT_RESETafter load so the guest kernel reconnects vsock socketsThis matches the kernel-backed
vhost-vsockdevice exactly.2. Remove the vhost-level migration blocker after device init
vhost_dev_init()registers a migration blocker when the backend lacksVHOST_F_LOG_ALL(dirty-page tracking for live migration). Forsavevm/loadvm, dirty tracking is unnecessary — the VM is paused and state is captured atomically. The blocker is removed after successful device initialization.Note:
migrate_del_blocker()removes the blocker for all migration modes. If live migration support is ever added for this device, the blocker handling should be revisited.Why this is safe
vm_stop()is called beforesavevm, which triggersvirtio_vmstate_change()->vuv_set_status(0)->vhost_vsock_common_stop(). The backend is guaranteed stopped whenpre_saveruns.savevm/loadvm— nothing tears it down.loadvm,post_loadschedules aVIRTIO_VSOCK_EVENT_TRANSPORT_RESETvia timer, telling the guest kernel to reconnect.set_statusthen restarts the backend.vhost-user-vsock— no other devices are affected.Testing
make checkunit tests: 97 pass / 0 fail / 4 skip (unchanged from baseline)qtest-x86_64/migration-test: 40 subtests pass (unchanged from baseline)savevmwithvhost-user-vsock-pcienabled: succeeds (previously blocked with "State blocked by non-migratable device")loadvmfrom snapshot: VM restores, guest receives transport reset