Skip to content

openvmm: require an explicit restore kind (same VM or clone) - #5244

Open
ayusharora221204 wants to merge 6 commits into
microsoft:mainfrom
ayusharora221204:user/ayusharora/restore-kind
Open

ayusharora221204 wants to merge 6 commits into
microsoft:mainfrom
ayusharora221204:user/ayusharora/restore-kind

Conversation

@ayusharora221204

@ayusharora221204 ayusharora221204 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

Restoring a snapshot can mean two different things:

  • The same VM, continuing where it left off. For example, the host saved it to disk to free resources (guest-transparent hibernation). There is a single logical timeline.
  • A clone: a new copy of the saved VM. For example, one of several VMs created from a template snapshot, or a rollback to an earlier snapshot.

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

  • ttrpc (vmservice.proto): new RestoreKind enum and a required RestoreVMRequest.kind field (5):
    • RESTORE_KIND_SAME_VM, RESTORE_KIND_CLONE;
    • RESTORE_KIND_UNSPECIFIED is rejected with INVALID_ARGUMENT;
    • independent of the existing resume field, which only controls whether the restored VM starts running. The names avoid "resume" so the two don't get confused.
  • CLI: --restore-kind same-vm|clone, required with --restore-snapshot (and only valid with it).
  • VM worker (openvmm_defs::worker): VmWorkerParameters.saved_state: Option<ProtobufMessage> becomes restore: Option<RestoreParameters>, which carries the saved state and its RestoreKind. The worker logs the kind on restore. Other save/restore paths (pulse save/restore, worker restart, reset) are unchanged.
  • Petri: the cross-process restore restores the same VM, so it uses RestoreKind::SameVm.
  • Guide: documents kind for RestoreVM and --restore-kind for the CLI.

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
@ayusharora221204
ayusharora221204 requested a review from a team as a code owner November 23, 2026 09:19
Copilot AI balanced review requested due to automatic review settings November 23, 2026 09:19
@github-actions github-actions Bot added the Guide label Nov 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 VmRestore to carry saved state and restore kind through worker launch; Petri selects SameVm.
  • 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
Copilot AI balanced review requested due to automatic review settings November 23, 2026 09:43
Ayush Arora and others added 2 commits November 23, 2026 15:16
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The restore test lacks regression coverage for rejecting unspecified and unknown kinds and for accepting Clone.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 23, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because the published review omits findings about test coverage for invalid restore kinds and required snapshot/restore-kind flag pairing.

1 open issue

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 44039ca6-d0e0-4228-8eb6-e64c811a3c66
Copilot AI balanced review requested due to automatic review settings November 23, 2026 10:11
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 44039ca6-d0e0-4228-8eb6-e64c811a3c66

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues blocking the changes that explicitly distinguish same-VM restores from clones.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants