Repository navigation
virtio: add userspace vsock save/restore - #4982
AdityaMittal1306 wants to merge 6 commits into
Conversation
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
There was a problem hiding this comment.
🟡 Changes recommended
RX and TX completion paths still swallow used-ring publication failures, allowing saves to capture orphaned descriptors that restore cannot complete; both paths need failure propagation and a non-reset regression test.
1 open issue
What changed in this PR
Adds reconnect-on-restore support for OpenVMM’s userspace virtio-vsock relay over PCI and MMIO. Ordinary pause/resume preserves streams; snapshot restoration resets saved connections so applications reconnect.
Changes:
- Adds asynchronous device-state hooks and vsock connection metadata persistence.
- Retains pending resets and fixes MSI-X restoration and Windows snapshot flushing.
- Adds device, transport, and VM regressions, Petri helpers, and reconnect-policy documentation.
| File | Description |
|---|---|
vmm_tests/vmm_tests/tests/tests/multiarch/vsock.rs |
Adds reconnect and file-backed snapshot VM tests. |
vmm_tests/vmm_tests/tests/tests/multiarch.rs |
Registers the vsock test module. |
vm/devices/virtio/virtio/src/transport/task.rs |
Handles device save/restore commands. |
vm/devices/virtio/virtio/src/transport/saved_state.rs |
Adds an optional device-state payload. |
vm/devices/virtio/virtio/src/transport/pci.rs |
Awaits shared save/restore hooks. |
vm/devices/virtio/virtio/src/transport/mmio.rs |
Converts save/restore to asynchronous operations. |
vm/devices/virtio/virtio/src/transport/core.rs |
Routes state operations through the device task. |
vm/devices/virtio/virtio/src/tests.rs |
Tests completion errors and device-state transport behavior. |
vm/devices/virtio/virtio/src/device.rs |
Defines asynchronous device-state hooks. |
vm/devices/virtio/virtio/src/common.rs |
Adds fallible queue completion. |
vm/devices/virtio/virtio_vsock/src/lib.rs |
Implements connection persistence and reset delivery. |
vm/devices/virtio/virtio_vsock/src/integration_tests.rs |
Tests lifecycle, reconnect, backpressure, and validation. |
vm/devices/virtio/virtio_vsock/src/connections.rs |
Exposes connection keys and centralizes pending resets. |
vm/devices/virtio/virtio_vsock/Cargo.toml |
Adds typed-error support. |
vm/devices/pci/pci_core/src/capabilities/msix.rs |
Restores interrupt delivery, routes, and pending state. |
vm/devices/pci/pci_core/Cargo.toml |
Adds tracing support for tests. |
petri/src/vm/openvmm/start.rs |
Enables userspace vsock save/restore eligibility. |
petri/src/vm/openvmm/runtime.rs |
Exposes a strict save/reset/restore helper. |
petri/src/vm/openvmm/modify.rs |
Adds MMIO vsock configuration support. |
openvmm/openvmm_entry/src/vm_controller.rs |
Uses a writable handle for snapshot flushing. |
Guide/src/reference/openvmm/management/cli.md |
Documents reconnect semantics and backend limitations. |
Cargo.lock |
Records added crate dependencies. |
Review effort: Balanced
| 0 | ||
| } | ||
| }; | ||
| state.rx_queue.complete(queue_work, bytes); |
Add async device-specific saved state to the PCI and MMIO transports. Preserve vsock runtime across pause/resume and restore old guest connections as pending resets, retaining invalidations under RX backpressure. Rearm MSI-X delivery and pending state on restore, and use a writable RAM-file handle when flushing Windows snapshots. Add device, transport, and Petri regressions plus reconnect documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e07981d to
5d2a62b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Awaiting reset delivery when RX has no buffers blocks TX and write-ready processing, stalling unrelated connections and risking deadlock; the fix needs a regression test covering a pending reset with a ready TX descriptor.
2 open issues
Review effort: Balanced
Propagate normal RX/TX completion failures and reject saves from failed workers. Keep reset delivery nonblocking while preserving RX ordering, bound the pending reset backlog, and add failure and backpressure regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Reconnect/reset ordering affects guest connection lifetimes, worker cancellation, and shared MSI-X routing, requiring human architectural review and still-pending Linux/KVM runtime and stress validation.
1 resolved since last review
Review effort: Balanced
Reuse queue-size and split/packed cursor validation before applying supplied active-queue state. Preserve legacy behavior when progress is absent. Add PCI/MMIO rejection tests and vsock regressions for queued work across pause/resume and restore into fresh guest memory without another kick. Document early rejection of malformed queue progress. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Publish VIRTIO_VSOCK_EVENT_TRANSPORT_RESET after actual restore while preserving ordinary pause/save/resume connections. Gate outbound RX until the guest replenishes event buffers, using producer progress rather than stale kicks, and preserve outstanding event acknowledgments across saves. Keep targeted RSTs for runtime errors and unconfirmed handshakes, including responses published but not yet consumed by the guest. Add shared queue notification regressions and real-guest persistent-listener restore tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
|
||
| state.queue_pending(pending); | ||
| Ok(()) | ||
| Ok(pending) |
Add opt-in PCIe and MMIO workloads using an unmodified upstream Linux vsock_perf binary with native AF_VSOCK and Unix-relay host peers. Require exact endpoint byte counts across pause/resume and fresh transfers after interrupting both directions with actual save/reset/restore. Bound lifecycle waits and verify guest identity, reconnect, and clean teardown. Add artifact-free report/peer regressions, shared workload helpers, and reproduction instructions. Keep iperf/bulk workloads and their dependencies outside this commit; the benchmark executable is not vendored. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Build on the shared lifecycle from microsoft#4713 while retaining the current asynchronous snapshot interfaces. Park the shared device owner for direct metadata access and defer restored notifications until start. Stage vsock metadata until activation, retain queues for ordinary pause/resume, and block activation after incomplete restore. Share vsock queue setup so startup and restore validate the same features. Add lifecycle, staging, notification, and queue-construction regressions and document the retained-pause and restore-activation contract. Validate virtio and virtio_vsock on Windows and Linux with check, all-targets clippy, rustdoc, and agent nextest (194 and 199 passed). Run cargo xtask fmt --fix last; no additional source changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
A critical pending-reset race can send a stale RST before a replacement connection’s RESPONSE, causing ECONNRESET; the fix must retire the reset only after successful acceptance and add ordering and real-guest reconnection coverage.
3 open issues
Review effort: Balanced
|
|
||
| state.queue_pending(pending); | ||
| Ok(()) | ||
| Ok(pending) |

Summary
Add reconnect-on-restore support for the built-in userspace virtio-vsock Unix relay through PCI and MMIO.
Rebase and API integration
Rebased commit:
5d2a62b4521428d59f4c6b40f9f12c95936cb9cc.Base:
42d4fe619dd3f14ef3ddefca3bb432dc4c524596, including the SaveVM/RestoreVM APIs merged in #4553.The Windows writable RAM-file flush fix is now supplied by #4553, so its duplicate controller hunk was dropped from this feature commit. This PR uses the existing public APIs; it does not extend their schema.
Latest transport-reset validation
Follow-up commit:
f52d93c2ad1ac07992c2cd13dbc18dc70b28e5d2.The exact 15-file event-only commit tree was validated in an isolated checkout without the local bulk/iperf changes:
virtio,virtio_vsock,petri,pipette, andvmm_tests.The ten new event/cursor regressions also passed ten repetitions on both Windows and Linux during development. Normal targeted RSTs are retained, including the case where a RESPONSE is already in guest RAM but has not yet been consumed.
The separate bulk/iperf test implementation remains local and is not included in this follow-up.
Earlier implementation validation
All VM executions below used a Windows host with WHP and Linux guests. WSL was the cross-build environment, not the VM's hypervisor backend.
pci_core,virtio,virtio_vsock,petri, andvmm_tests. Repository formatting passed last.cargo xflowey vmm-tests-run: PCI pulse, MMIO pulse, CLI fresh-process snapshot for both transports, and ttrpc PCIe fresh-process snapshot. All four passed 10 repetitions (40 executions), and passed again from the finalized commit.openvmm 0.5.0+g5d2a62b45without a dirty suffix.The ttrpc case verifies CID 42, same-stream PauseVM/ResumeVM, rejected saves preserving the source connection, returned snapshot ID matching the manifest, a paused source with ResumeVM blocked, teardown disconnect, wrong-ID rejection, restoration in a different OpenVMM process, paused restoration followed by ResumeVM, preserved guest boot ID/RAM marker, and successful reconnection/data exchange.
A short Windows output directory was required for cross-run temporary Unix-socket paths to fit SUN_LEN. Test assertions were not weakened for that environment issue.
Scope and draft status
vhost-vsockremains unsupported. External host streams and application state are not checkpointed.The PR remains a draft for team review of the reconnect/reset-priority design and remaining platform coverage. Guest images, local harness assets, logs, and the separate validation checkout are not committed.
Native vsock_perf workload validation
Commit:
c7fe63258f1e3baded963dc76dcb5b6c53cfcca2.vsock_perfexecutable, supplied throughPETRI_VSOCK_PERF_BIN. The executable and upstream source are not vendored, and no new dependency versions are introduced.Earlier native stress runs intermittently stalled in WHP doorbell cleanup during reset or guest shutdown. They did not recur in the two post-restart full reruns or the isolated pre-commit run; this test commit does not claim a production fix for that historical issue. Linux-host VM execution remains unverified.
The separate stock-iperf3/SHA-256 bulk test implementation, its dependency wiring, and its artifact-discovery changes remain local and uncommitted.