You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 30ce395
Browse filesBrowse the repository at this point in the historyBrowse files
virt: refuse to restore an element that the partition lacks
A decoded snapshot is external input, and can hold an element that the
destination partition does not have: SynIC state for a microVM, whose
partition has no Hyper-V enlightenments, an element for an MSR that the
destination's KVM does not list, or the hypercall MSRs, the reference
time, or the reference TSC page of the VM state. The generated
restore_all asserted that each element it was about to set is present,
so it panicked on such a snapshot after it had set the elements that
precede the unsupported one, and, since OpenVMM builds with
panic = "abort", the process died with no restore error
(microsoft/nvx#1168).
restore_all now checks every element of the saved state against the
partition before it sets or commits any of them, and fails with the new
StateError::Unsupported, which names the element in the phase "restore
check" and has no source, since it fails before any backend access.
StateError becomes an enum, whose Access variant keeps the phase and the
backend's error as its source, so a backend failure is reported as
before. Each restore_all call checks its own saved state, the VM's or
one VP's, so a refusal for a later VP leaves the VM state and the
earlier VPs restored, as any other failed restore does, and the restore
still does not undo what it set before a setter fails. The change adds
no saved element and changes no saved state, format, or version, and
StateError is an in-memory error, not a saved one: a snapshot that
restored restores as before, and one that held an unsupported element no
longer panics.
The Guide's snapshot chapters say that a restore can fail this way,
where the format chapter said that it stops on an assertion, and the
rules comment of the VP state's state_trait! says that a capability that
a backend clears for a host also decides which hosts can restore a
snapshot.
Tests, in state::tests, with a test state whose second element the
partition lacks:
- a_restore_refuses_an_absent_element_before_it_changes_anything
requires that the restore fails with Unsupported, names the phase and
the element, has no source, and calls no setter or commit. At
359169f it panics with "assertion failed: <Absent as
StateElement<Caps, Vp>>::is_present(self.caps())", after the setter
of the first element ran.
- a_restore_sets_the_elements_that_the_partition_has and
a_failed_restore_keeps_the_error_of_the_backend pass before and after
the change: the first sets the elements of a state that holds only
what the partition has, and commits, and the second requires that the
error of a failing setter stays its source.
- a_refused_save_reads_nothing now matches the Access variant instead of
reading the phase field.
The 140 tests of virt pass with cargo nextest, with the ignored ones, on
Windows x64 and on Linux x64 (nvx-kvm-test), and the 237 of virt and
virt_mshv on nvx-mshv-test; virt_kvm, virt_mshv, and OpenHCL's
virt_mshv_vtl, which cargo check type-checks for x86_64-unknown-linux-
musl, build with the enum. cargo clippy --all-targets and cargo doc are
clean for virt, and virt and virt_hvf type-check for
aarch64-apple-darwin. The next commit adds the contract tests of the
real backends.
End to end, on Linux 6.18.57 with KVM (nvx-kvm-test) and with MSHV
(nvx-mshv-test): a microVM snapshot that a guest captured, with
state.bin edited to give VP 0 a SynIC element and manifest.bin to give
its length, restores as follows. OpenVMM at 359169f aborts, with
SIGABRT and no restore error: "thread 'vp-0' panicked at
vmm_core/virt/src/x86/vp.rs:2576:1: assertion failed: <SyntheticMsrs as
...>::is_present(self.caps())". With this commit it exits with status 1
and reports "failed to launch vm worker: loadedvm restore failed:
restore failed: {partition: failed to restore child device vp0: state
access error, phase restore check: the saved state has "synic", which
the partition does not support}", before any vCPU runs, and the unedited
snapshot restores and its guest continues. The snapshot-core,
snapshot-rollback, smp-snapshot, restore-processors, snapshot-tiers, and
run-console-restore scenarios of test-microvm, on 1 and 2 vCPUs, and its
smp-lapic, time-abi-conformance, restore-downtime, restore-memory,
platform-restore-processors, and console-snapshot scenarios, on 1, 2,
and 4, pass on both with this commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments