Repository navigation
openvmm: require an explicit restore kind (same VM or clone) - #5244
Open
ayusharora221204 wants to merge 6 commits into
Open
ayusharora221204 wants to merge 6 commits into
ayusharora221204 wants to merge 6 commits into
Conversation
Restoring from a snapshot can mean two different things: continuing the same VM (for example, guest-transparent hibernation), or creating a new copy of it (a VM created from a template snapshot, or a rollback). The snapshot is the same in both cases, so OpenVMM can't tell them apart; the caller has to say. Add a required restore kind and pass it to the VM worker: - ttrpc: `RestoreVMRequest.kind` (`RestoreKind`: `RESTORE_KIND_SAME_VM` or `RESTORE_KIND_CLONE`). `RESTORE_KIND_UNSPECIFIED` is rejected with `INVALID_ARGUMENT`. It is independent of the existing `resume` field. - CLI: `--restore-kind same-vm|clone`, required with `--restore-snapshot`. - VM worker: `VmWorkerParameters.saved_state` becomes `restore: Option<VmRestore>`, which carries the saved state and its `RestoreKind`. Petri's cross-process restore uses `SameVm`. No behavior depends on the kind yet. Clone-sensitive state, starting with the VM Generation ID (microsoft#4664), will use it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 44039ca6-d0e0-4228-8eb6-e64c811a3c66
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the explicit restore-kind change.
No open issues 🎉
What changed in this PR
Requires callers to distinguish restoring the same VM from creating a clone. This prepares OpenVMM for clone-sensitive behavior such as VM Generation ID updates; the choice is passed to the worker and logged, but does not yet change restore behavior.
Changes:
- Adds required restore-kind selection to ttrpc and CLI interfaces, breaking callers that omit it.
- Introduces
VmRestoreto carry saved state and restore kind through worker launch; Petri selectsSameVm. - Updates validation tests and Guide documentation for the explicit choice.
| File | Description |
|---|---|
vmm_tests/vmm_tests/tests/tests/ttrpc.rs |
Tests rejection of unspecified kinds and updates existing restore requests. |
petri/src/worker.rs |
Passes VmRestore through worker launch. |
petri/src/vm/openvmm/start.rs |
Marks cross-process restores as the same VM. |
openvmm/openvmm_ttrpc_vmservice/src/vmservice.proto |
Defines RestoreKind and adds the request field. |
openvmm/openvmm_entry/src/ttrpc/mod.rs |
Validates restore kind and forwards it to the worker. |
openvmm/openvmm_entry/src/lib.rs |
Converts the CLI selection into worker restore parameters. |
openvmm/openvmm_entry/src/cli_args.rs |
Adds --restore-kind, mutual requirements, and parser tests. |
openvmm/openvmm_defs/src/worker.rs |
Defines typed restore parameters and the internal restore-kind enum. |
openvmm/openvmm_core/src/worker/dispatch.rs |
Reads the restore wrapper and logs its kind. |
Guide/src/user_guide/openvmm/snapshots.md |
Explains restore choices and updates the command example. |
Guide/src/reference/openvmm/management/grpc.md |
Documents required kind and its independence from resume. |
Guide/src/reference/openvmm/management/cli.md |
Documents the new flag and snapshot requirement. |
Review effort: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 44039ca6-d0e0-4228-8eb6-e64c811a3c66
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 44039ca6-d0e0-4228-8eb6-e64c811a3c66
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 44039ca6-d0e0-4228-8eb6-e64c811a3c66
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 44039ca6-d0e0-4228-8eb6-e64c811a3c66
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 44039ca6-d0e0-4228-8eb6-e64c811a3c66
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.

Why
Restoring a snapshot can mean two different things:
The snapshot is identical in both cases, so OpenVMM can't tell them apart: the caller has to say. Clone-sensitive behavior needs this, starting with the VM Generation ID in #4664, which should change for a clone but not for the same VM (see the review discussion there).
This PR only adds the API and passes the choice to the VM worker. No behavior depends on it yet.
Changes
vmservice.proto): newRestoreKindenum and a requiredRestoreVMRequest.kindfield (5):RESTORE_KIND_SAME_VM,RESTORE_KIND_CLONE;RESTORE_KIND_UNSPECIFIEDis rejected withINVALID_ARGUMENT;resumefield, which only controls whether the restored VM starts running. The names avoid "resume" so the two don't get confused.--restore-kind same-vm|clone, required with--restore-snapshot(and only valid with it).openvmm_defs::worker):VmWorkerParameters.saved_state: Option<ProtobufMessage>becomesrestore: Option<RestoreParameters>, which carries the saved state and itsRestoreKind. The worker logs the kind on restore. Other save/restore paths (pulse save/restore, worker restart, reset) are unchanged.RestoreKind::SameVm.kindforRestoreVMand--restore-kindfor the CLI.