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

Detect QEMU virtualization on Darwin. #1813

Merged
merged 1 commit into from
Oct 24, 2023
Merged

Detect QEMU virtualization on Darwin. #1813

merged 1 commit into from
Oct 24, 2023

Conversation

williamtheaker
Copy link
Contributor

This PR adds a check for whether a Darwin machine is running as a QEMU guest.

Description

Apple added a Virtualization Framework based on QEMU to recent releases of macOS. This has resulted in many more options, such as UTM for organizations looking to run virtual macOS machines on Apple hardware.

One such organization appears to be Github, which seems to be adding Veertu VMs to their Github Actions runners. Unfortunately, Chef's virtual? helper fails to detect these machines as guests, since ohai isn't setting the role for QEMU VMs.

The XNU kernel added an Object ID named kern.hv_vmm_present, which returns 0 for physical hardware and 1 for virtual machines. This OID is present on x86 devices running macOS Big Sur (version 11) and all Apple ARM macOS devices. By shelling out to sysctl, we can use this OID to detect VMs.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • If Gemfile.lock has changed, I have used --conservative to do it and included the full output in the Description above.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@williamtheaker williamtheaker requested review from a team as code owners October 20, 2023 18:42
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@tpowell-progress tpowell-progress merged commit 521d91e into chef:main Oct 24, 2023
28 of 29 checks passed
@williamtheaker williamtheaker deleted the wt.qemu_darwin branch October 24, 2023 21:09
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