Skip to content

refactor: migrate cpuType to vmOpts.qemu #3500

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

unsuman
Copy link
Contributor

@unsuman unsuman commented May 6, 2025

Description

This PR fixes #3486 by relocating the cpuType field to vmOpts.qemu.cpuType in both the YAML schema and limayaml.LimaYAML struct in Go. To maintain compatibility, the old top-level cpuType is still accepted and merged into the new path at runtime, with a warning to encourage migration. Validation and default logic have been moved to the qemu package.

if !slices.Contains(ArchTypes, arch) {
return fmt.Errorf("field `vmOpts.qemu.cpuType` uses unsupported arch %q", arch)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Probably defaults.go should just replicate the top-level CPUType to VMOpts (with a warning when they conflict), then no need to validate the CPUTypes here twice?

Copy link
Member

Choose a reason for hiding this comment

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

The validation should happen in pkg/qemu.
pkg/limayaml shouldn't be aware of the archs implemented by the QEMU driver

@AkihiroSuda AkihiroSuda added this to the v1.1.0 milestone May 7, 2025
@unsuman unsuman force-pushed the fix/revamp-cputype branch 2 times, most recently from 8d8f48d to aca2e46 Compare May 7, 2025 09:55
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
@unsuman unsuman force-pushed the fix/revamp-cputype branch from aca2e46 to 3ee6999 Compare May 7, 2025 09:56
// TODO: This check should be removed when we completely eliminate `CPUType` from limayaml.
if len(y.CPUType) > 0 {
if warn {
logrus.Warn("The top-level `cpuType` field is deprecated and will be removed in a future release. Please migrate to `vmOpts.qemu.cpuType`.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why this is not executing even if warn is set true by default

Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

There is also a linter error to fix.


# OS: "Linux".
# 🟢 Builtin default: "Linux"
os: null

# DEPRECATED: Use vmOpts.qemu.cpuType instead.
Copy link
Member

Choose a reason for hiding this comment

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

I think the duplicate documentation should be removed from the deprecated entry. Just point it to the new location instead.

Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

I would prefer that we hold off on merging this PR until we have agreement on how the final config settings are supposed to look like. Otherwise we might end up with double-migrations, which complicates the code, the docs, and confuses users.

See also #3520 (comment)

@AkihiroSuda AkihiroSuda modified the milestones: v1.1.0, v1.1.x (?) May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

YAML: cpuType should be moved to vmOpts.qemu
3 participants