chore: One more pass at guest_disk simplification - #11394
Merged
Conversation
Now that we only have maximum one keyslot+token, we can do a few more simplifications / optimizations. - Rename `KeyslotMetadata` → `KeyslotToken`; add `SINGLE_KEYSLOT_INDEX`/`SINGLE_TOKEN_INDEX` constants replacing scattered `0` literals - Replace `read_keyslot_metadata` (Vec) with `read_single_keyslot_token` reading the one token from its fixed position - Make token writes deterministic: clear all token positions, then `ReplaceToken(SINGLE_TOKEN_INDEX)` instead of first-free `AddToken` - Drop the unused `keyslot` parameter of `add_sev_metadata` and the `KeyslotToken::keyslot()` method - `format_crypt_device` and `activate_crypt_device` no longer return the keyslot/device tuple - Collapse the duplicated Var/Store match arms in `SevDiskEncryption` into a shared `header_location()` helper - Both encryption backends own their metrics `Registry` - Tests assert the single-token invariant via new `assert_single_metadata_token`/`assert_no_metadata_token` helpers
|
✅ No security or compliance issues detected. Reviewed everything up to 421fa44. Security Overview
Detected Code Changes
|
frankdavid
requested review from
Bownairo
and
a balanced review from Copilot
September 1, 2026 14:10
Contributor
There was a problem hiding this comment.
Pull request overview
Simplifies guest disk encryption around the single-keyslot and single-token model.
Changes:
- Introduces fixed keyslot/token indices and deterministic token handling.
- Streamlines crypt-device APIs and SEV header selection.
- Updates registry ownership and invariant-focused tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crypt.rs |
Simplifies keyslot/token APIs and fixed-index handling. |
sev.rs |
Consolidates header selection and updates rekeying. |
generated_key.rs |
Owns its metrics registry. |
main.rs |
Shares the metrics registry through cloning. |
tests.rs |
Verifies single-token and no-token invariants. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Bownairo
approved these changes
Sep 2, 2026
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.
Now that we only have maximum one keyslot+token, we can do a few more simplifications / optimizations.
KeyslotMetadata→KeyslotToken; addSINGLE_KEYSLOT_INDEX/SINGLE_TOKEN_INDEXconstants replacing scattered0literalsread_keyslot_metadata(Vec) withread_single_keyslot_tokenreading the one token from its fixed positionReplaceToken(SINGLE_TOKEN_INDEX)instead of first-freeAddTokenkeyslotparameter ofadd_sev_metadataand theKeyslotToken::keyslot()methodformat_crypt_deviceandactivate_crypt_deviceno longer return the keyslot/device tupleSevDiskEncryptioninto a sharedheader_location()helperRegistryassert_single_metadata_token/assert_no_metadata_tokenhelpers