Skip to content

Commit 145e7e0

Browse files
authored
ci: add manual workflow to probe macOS Virtualization.framework (#157)
Adds a workflow_dispatch-only job that runs on an Apple Silicon (arm64) GitHub-hosted macOS runner and reports whether the Virtualization framework is available. Probes layer from cheapest to most authoritative: runner identity dump, arm64 assertion, kern.hv_support sysctl, framework bundle presence, and finally VZVirtualMachine.isSupported via an inline Swift program. Writes a result table to the job step summary.
1 parent 40eaee5 commit 145e7e0

1 file changed

Lines changed: 127 additions & 0 deletions

File tree

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
# Manual probe: confirm the Virtualization.framework is available on a
4+
# GitHub-hosted Apple Silicon (ARM64) macOS runner.
5+
#
6+
# Apple's Virtualization.framework is the macOS analogue of KVM/WHP that
7+
# hyperlight needs for micro-VMs. This job inspects the runner so we can
8+
# verify before betting on macOS hosting (see /memories/azure-hosting-kvm.md
9+
# for why "just use platform X" warrants a real check first).
10+
11+
name: Check macOS Virtualization Framework
12+
13+
on:
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
check-virtualization:
21+
name: Inspect Virtualization.framework on ARM macOS
22+
runs-on: macos-latest
23+
24+
steps:
25+
- name: Report runner identity
26+
run: |
27+
echo "::group::Runner identity"
28+
echo "OS: $(sw_vers -productName) $(sw_vers -productVersion) (build $(sw_vers -buildVersion))"
29+
echo "Architecture: $(uname -m)"
30+
echo "Kernel: $(uname -srv)"
31+
echo "::endgroup::"
32+
33+
- name: Assert Apple Silicon (arm64)
34+
run: |
35+
arch="$(uname -m)"
36+
if [ "$arch" != "arm64" ]; then
37+
echo "::error::Expected arm64 runner, got '$arch'"
38+
exit 1
39+
fi
40+
echo "Confirmed ARM64 runner."
41+
42+
- name: Check hypervisor support via sysctl
43+
run: |
44+
echo "::group::sysctl hv/vmm"
45+
# kern.hv_support is the canonical "hypervisor available" flag.
46+
hv_support="$(sysctl -n kern.hv_support 2>/dev/null || echo missing)"
47+
echo "kern.hv_support = ${hv_support}"
48+
# Useful neighbours for diagnostics; not all present on every release.
49+
sysctl -a 2>/dev/null | grep -E '^(kern\.hv_|hw\.optional\.arm|machdep\.cpu\.brand_string)' || true
50+
echo "::endgroup::"
51+
52+
if [ "$hv_support" != "1" ]; then
53+
echo "::error::kern.hv_support is not 1 — hypervisor not advertised by kernel."
54+
exit 1
55+
fi
56+
57+
- name: Locate Virtualization.framework
58+
run: |
59+
fw="/System/Library/Frameworks/Virtualization.framework"
60+
if [ ! -d "$fw" ]; then
61+
echo "::error::Virtualization.framework not present at $fw"
62+
exit 1
63+
fi
64+
echo "Found framework bundle: $fw"
65+
ls -la "$fw"
66+
# Best-effort version read; not fatal if Info.plist layout changes.
67+
if [ -f "$fw/Resources/Info.plist" ]; then
68+
/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$fw/Resources/Info.plist" 2>/dev/null \
69+
| sed 's/^/Framework version: /' || true
70+
fi
71+
72+
- name: Probe VZVirtualMachine.isSupported via Swift
73+
# The framework being on disk doesn't guarantee the runtime says
74+
# "yes you can boot a VM here". The authoritative check is
75+
# VZVirtualMachine.isSupported, exposed by Apple's Swift API.
76+
run: |
77+
probe="$(mktemp -t vz-probe.XXXXXX).swift"
78+
cat > "$probe" <<'SWIFT'
79+
import Foundation
80+
#if canImport(Virtualization)
81+
import Virtualization
82+
let supported = VZVirtualMachine.isSupported
83+
FileHandle.standardOutput.write(Data("VZVirtualMachine.isSupported = \(supported)\n".utf8))
84+
exit(supported ? 0 : 2)
85+
#else
86+
FileHandle.standardError.write(Data("Virtualization module not importable on this runner\n".utf8))
87+
exit(3)
88+
#endif
89+
SWIFT
90+
91+
echo "Running probe: $probe"
92+
set +e
93+
swift "$probe"
94+
rc=$?
95+
set -e
96+
97+
case "$rc" in
98+
0)
99+
echo "Virtualization framework is ENABLED on this runner."
100+
;;
101+
2)
102+
echo "::error::Virtualization.framework loaded but VZVirtualMachine.isSupported == false"
103+
exit 1
104+
;;
105+
3)
106+
echo "::error::Swift could not import the Virtualization module"
107+
exit 1
108+
;;
109+
*)
110+
echo "::error::Swift probe failed with exit code $rc"
111+
exit 1
112+
;;
113+
esac
114+
115+
- name: Summary
116+
if: always()
117+
run: |
118+
{
119+
echo "### macOS Virtualization Framework check"
120+
echo ""
121+
echo "| Property | Value |"
122+
echo "| --- | --- |"
123+
echo "| Runner label | macos-latest |"
124+
echo "| OS | $(sw_vers -productName) $(sw_vers -productVersion) |"
125+
echo "| Architecture | $(uname -m) |"
126+
echo "| kern.hv_support | $(sysctl -n kern.hv_support 2>/dev/null || echo missing) |"
127+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)