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
@@ -111,6 +112,7 @@ type VMOpts struct {

type QEMUOpts struct {
MinimumVersion *string `yaml:"minimumVersion,omitempty" json:"minimumVersion,omitempty" jsonschema:"nullable"`
CPUType CPUType `yaml:"cpuType,omitempty" json:"cpuType,omitempty" jsonschema:"nullable"`
}
Copy link
Member

Choose a reason for hiding this comment

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

Eventually VMOpts should be defined as map[string]any, and QEMUOpts should be moved to pkg/qemu.
Can be another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I make the changes in this PR itself, or raise an issue from your comment, and start working on it in another PR?

Copy link
Member

Choose a reason for hiding this comment

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

Can be another issue and PR

@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

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
2 participants