-
Notifications
You must be signed in to change notification settings - Fork 41
Add SKU number and family to the SMBIOS type 1 input #1205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
886e1c4
Add SKU number and family to the SMBIOS type 1 input
sion42x eb7c939
Adding SMBIOS spec documentation link
sion42x 6f16413
Skip serializing unset SMBIOS SKU and family fields
sion42x e95be0f
Add a dedicated legacy spec error for SMBIOS downgrades
sion42x 77a62cc
Normalize empty SMBIOS SKU and family strings to unset
sion42x 2d4083b
Share one component amend helper between v6 and v7
sion42x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| //! Conversions between [`propolis_api_types_versions::v7`] instance specs and | ||
| //! the internal [`super::Spec`] representation. | ||
|
|
||
| use std::collections::BTreeMap; | ||
|
|
||
| use propolis_api_types::instance_spec::SpecKey; | ||
| use propolis_api_types_versions::{v1::instance::ReplacementComponent, v6, v7}; | ||
|
|
||
| use super::{builder::SpecBuilder, ApiSpecError, Spec}; | ||
| use crate::migrate::MigrateError; | ||
| use crate::spec::{api_spec_latest, api_spec_v6}; | ||
|
|
||
| impl From<Spec> for v7::instance_spec::InstanceSpec { | ||
| fn from(mut val: Spec) -> Self { | ||
| // v7 only widens the SMBIOS type 1 input, which would cause the | ||
| // conversion to a v6 spec to fail if the new fields are set. Set the | ||
| // input aside, convert the rest as v6, and put it back afterwards. | ||
| let smbios = val.smbios_type1_input.take(); | ||
|
|
||
| let v6_spec: v6::instance_spec::InstanceSpec = | ||
| val.try_into().unwrap_or_else(|e| { | ||
| unreachable!( | ||
| "Converting a Spec without v7 bits to v6 failed: {e}. \ | ||
| This is currently impossible. When Spec to \ | ||
| v7::instance_spec::InstanceSpec becomes fallible, \ | ||
| this should `?`." | ||
| ); | ||
| }); | ||
|
|
||
| let mut spec: v7::instance_spec::InstanceSpec = v6_spec.into(); | ||
| spec.smbios = smbios; | ||
| spec | ||
| } | ||
| } | ||
|
|
||
| /// Parses a v7 instance spec into a [`SpecBuilder`], validating component | ||
| /// names, PCI paths, and backend references along the way. Callers can add | ||
| /// additional (non-v7) components to the builder before calling `finish()`. | ||
| pub(crate) fn v7_to_spec_builder( | ||
| value: v7::instance_spec::InstanceSpec, | ||
| ) -> Result<SpecBuilder, ApiSpecError> { | ||
| api_spec_latest::latest_to_spec_builder(value) | ||
| } | ||
|
|
||
| pub(crate) fn amend( | ||
| spec: &mut v7::instance_spec::InstanceSpec, | ||
| replacements: &BTreeMap<SpecKey, ReplacementComponent>, | ||
| ) -> Result<(), MigrateError> { | ||
| // v7 reuses the v6 component types, so the v6 amendment logic applies. | ||
| api_spec_v6::amend_components(&mut spec.components, replacements) | ||
| } | ||
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.