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

VM fails to start on M1 CPU when CPU cores set to more than the host has #1621 #2309

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

Conversation

NotPranav0
Copy link

No description provided.

@NotPranav0
Copy link
Author

NotPranav0 commented May 1, 2024

how do i run the linter?
edit: figured it out

Signed-off-by: notpranavunsw <118208399+notpranavunsw@users.noreply.github.com>

ran linter

Signed-off-by: notpranavunsw <118208399+notpranavunsw@users.noreply.github.com>
@NotPranav0 NotPranav0 marked this pull request as ready for review May 1, 2024 19:10
@AkihiroSuda AkihiroSuda added this to the v0.22.0 milestone May 4, 2024
@@ -108,6 +108,10 @@ func Validate(y LimaYAML, warn bool) error {
return errors.New("field `cpus` must be set")
}

if *y.CPUs > runtime.NumCPU() {
return fmt.Errorf("field `cpus` is set to %d, which is greater than the number of CPUs available (%d)", *y.CPUs, runtime.NumCPU())
}
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if the VM driver should automatically decrease the CPUs (with a warning)?

Copy link
Member

Choose a reason for hiding this comment

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

We could (i have no strong opinion either way), but why do it in the driver and not in FillDefault? We set the default memory in there based on actual memory available, so why not implement the cap on the number of CPUs there as well?

Copy link
Member

Choose a reason for hiding this comment

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

That would be fine as well

Copy link
Member

Choose a reason for hiding this comment

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

I just remembered: we may be executing FillDefault several times (we read the configurations of all instances during startup to look for things like shared network daemons, or shared additional disks). So any warnings generated while processing lima.yaml will be displayed multiple times, and we may be displaying warnings for other instances too.

So doing it in the driver might be preferable after all.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, I have a question.
Am I correct in thinking this should be implemented in vz_driver_darwin.go and qemu_driver.go?
Thanks

Copy link
Author

Choose a reason for hiding this comment

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

i'm able to generate a warning, but I'm not sure how to edit the yaml config to permanently set the number of cpu's.
setting y.cpus doesn't edit the yaml when viewed using limactl edit

@AkihiroSuda AkihiroSuda removed this from the v0.22.0 milestone May 4, 2024
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.

None yet

3 participants