Skip to content
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

refactor: Eliminate unused {Static,Custom}CpuTemplate variants #4391

Closed

Conversation

roypat
Copy link
Contributor

@roypat roypat commented Jan 22, 2024

They were needed for Versionize reasons, but with #4230 merged, we can eliminate them, simplifying the code.

Changes

...

Reason

...

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following
Developer Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet contribution quality standards.

  • This functionality cannot be added in rust-vmm.

Comment on lines 92 to 102
/// A CPU template that it is used to filter the CPU features exposed to the guest.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cpu_template: Option<StaticCpuTemplate>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "some_option"
)]
pub cpu_template: Option<Option<StaticCpuTemplate>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it might be worth noting why it is wrapped with two Options (The outer Option indicates whether cpu_template field is provided or not, and the inner one indicates whether the given cpu_template is "None" or a specific CPU template.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@roypat roypat force-pushed the no-static-none-variant branch from f335b52 to 4d1995b Compare January 22, 2024 11:58
@roypat roypat marked this pull request as ready for review January 22, 2024 11:58
@roypat roypat marked this pull request as draft January 22, 2024 12:10
They were needed for Versionize reasons, but with firecracker-microvm#4230 merged, we can
eliminate them, simplifying the code.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
@roypat roypat force-pushed the no-static-none-variant branch from eacad79 to b62cc65 Compare January 23, 2024 16:11
@roypat
Copy link
Contributor Author

roypat commented Jan 23, 2024

Closing this, as removing the None variants will require to handle the string "None" as a special case during deserialization (to keep backward compatible), so overall we just move the complexity somewhere else. Let's just "fix" this in 2.0 when static templates will be removed anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants