Skip to content

Integrate WHP and macOS HVF support - #2

Merged
misaelzapata merged 6 commits into
mainfrom
port-macos-support
May 3, 2026
Merged

Integrate WHP and macOS HVF support#2
misaelzapata merged 6 commits into
mainfrom
port-macos-support

Conversation

@misaelzapata

Copy link
Copy Markdown
Owner

Summary

  • Port the Windows/WHP runtime work into the backend-split native layout and keep KVM, WHP, and HVF separated by module.
  • Extend the public CLI/SDK surface for Slirp networking, persistent and explicit disks, attached disks, prebuilt rootfs handling, and host capabilities.
  • Add macOS/HVF ARM64 runtime support, docs, tests, Darwin prebuild packaging, and release workflow coverage.

Validation

  • npm test
  • npm run test:macos-hvf
  • npm run pack:check
  • NODE_VMM_PACK_REQUIRE_DARWIN=1 node scripts/pack-check.mjs
  • git diff --check
  • git diff --cached --check
  • Manual Alpine ARM64 run with apk update and apk add --no-cache nodejs npm on HVF/Slirp

misaelsnap and others added 3 commits April 30, 2026 17:05
- native/hvf_backend.cc: full ARM64 VMM using Apple Hypervisor.framework
  (macOS 15+): GICv3, PL011 UART, virtio-mmio block, virtio-mmio net via
  vmnet.framework shared mode (NAT). Includes FDT/DTB builder, ARM64 Image
  loader, ESR decode, PSCI/HVC emulation, and WFI yield.
- binding.gyp: add darwin/arm64 target linking Hypervisor + vmnet + CoreFoundation
- src/native.ts: add HvfProbeResult, HvfRunConfig, NativeHvfBackend
- src/kvm.ts: add probeHvf, runHvfVm, hvfDefaultKernelCmdline (PL011/virtio-mmio)
- src/index.ts: hostBackend() returns "hvf" on darwin; featureLines and
  doctor() are HVF-aware; run/start paths dispatch to HVF on macOS
- src/net.ts: --net auto on darwin returns vmnet:shared sentinel instead of
  requiring ip/iptables
- scripts/build-native.mjs: add darwin/arm64 to supported platforms
- test/unit.test.ts: guard Linux-only assertions behind platform checks
Copilot AI review requested due to automatic review settings May 3, 2026 18:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR expands node-vmm to support additional host backends (Windows/WHP and macOS/HVF) and broadens the CLI/SDK surface around networking and disk/rootfs workflows, including prebuilt rootfs and new packaging/release automation.

Changes:

  • Add/extend cross-platform networking + disk/rootfs capabilities (slirp, persistent/explicit disks, attached disks, prebuilt rootfs).
  • Introduce macOS/HVF (arm64) runtime support and Windows/WHP runtime refactor with new native modules/devices.
  • Update build/packaging scripts and CI/release workflows to ship Linux/Windows/macOS prebuilds and release rootfs assets.

Reviewed changes

Copilot reviewed 89 out of 108 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vcpkg.json Adds vcpkg manifest for Windows-native dependency management (libslirp/glib).
third_party/libslirp/lib/x64-windows/libslirp.exp Adds Windows libslirp export artifact.
third_party/libslirp/lib/x64-windows/libslirp.def Adds DEF file describing libslirp exported symbols.
third_party/libslirp/include/libslirp-version.h Adds vendored libslirp version header for consumers/builds.
test/ext4.test.ts Adds scaffold/contract tests for the new ext4 writer stubs.
src/types.ts Extends public SDK types for backends, networking modes, progress events, disks, and prebuilt rootfs modes.
src/rootfs-linux.ts Adds Linux rootfs build implementation (mount/chroot/unshare path).
src/rootfs-darwin.ts Adds macOS rootfs build implementation (mkfs.ext4 discovery + OCI extraction).
src/process.ts Improves runCommand coverage annotations and makes commandExists() Windows-aware (where.exe).
src/oci.ts Adds blob download progress plumbing and reporting during OCI pulls.
src/net.ts Adds slirp networking mode and macOS HVF networking backend selection logic.
src/kernel.ts Refactors kernel naming/lookup to support ARM64 kernels (esp. macOS/HVF) while keeping legacy aliases.
src/ext4/writer.ts Introduces Ext4ImageWriter scaffold API (currently stubbed via NotImplementedError).
src/ext4/types.ts Defines ext4 writer types (entries, inode modes, options, finalize result).
src/ext4/superblock.ts Adds superblock constants/types + stub planning/serialization.
src/ext4/inode.ts Adds inode/inode-table scaffolding types + stubs.
src/ext4/index.ts Adds ext4 module public re-exports under src/ext4.
src/ext4/group.ts Adds group descriptor table scaffolding + stubs.
src/ext4/dir.ts Adds directory writer scaffolding + stubs, plus record-length helper.
src/ext4/bitmap.ts Adds bitmap scaffolding + stubs plus group bitmap factory helper.
src/disk.ts Adds persistent/explicit root disk materialization + attached disk resolution/validation helpers.
scripts/vendor-libslirp.mjs Adds Windows-only libslirp vendor script (MSYS2 download + DEF/implib generation).
scripts/slirp-flags.mjs Adds pkg-config helper to supply slirp/glib flags for macOS builds.
scripts/package-prebuild.mjs Extends prebuild packaging for Windows DLL staging and macOS dylib bundling/rewrite/codesign.
scripts/pack-check.mjs Hardens npm pack checks across platforms and validates required prebuild artifacts.
scripts/fetch-kernel.mjs Updates kernel fetch defaults for macOS/arm64 kernel naming.
scripts/check-gcov.mjs Updates KVM gcov paths to the new native file layout.
scripts/build-prebuilt-rootfs.mjs Adds CI-facing tool to build + gzip + manifest prebuilt rootfs release assets.
scripts/build-native.mjs Extends native build to macOS arm64 and adds libslirp detection/staging for Windows builds.
package.json Exposes new subpath exports (./disk, ./prebuilt-rootfs), adds scripts, and adjusts coverage command args.
native/whp/win_io.h Adds Windows file I/O helpers for virtio-blk/overlay operations.
native/whp/win_console_ctrl.h Declares scoped console Ctrl handler helper.
native/whp/win_console_ctrl.cc Implements Ctrl-C/Ctrl-Break forwarding hook lifecycle.
native/whp/virtio/rng.h Adds virtio-rng-mmio device declaration.
native/whp/virtio/rng.cc Implements virtio-rng-mmio device using BCryptGenRandom.
native/whp/virtio/desc.h Adds shared virtio-mmio constants + descriptor types/helpers.
native/whp/virtio/blk.h Refactors/introduces virtio-blk-mmio device interface for WHP.
native/whp/page_tables.h Adds helpers for x86_64 identity-map page tables + segment/table register helpers.
native/whp/page_tables.cc Implements page table and register helper routines.
native/whp/irq.h Adds WHP IRQ delivery state machine declarations + pure decision helper API.
native/whp/irq.cc Implements WHP external interrupt injection + window arming logic.
native/whp/guest_memory.h Adds guest memory view helper with bounds checking.
native/whp/elf_loader.h Declares ELF kernel loader for WHP vmlinux-style kernels.
native/whp/elf_loader.cc Implements ELF64 segment loading into guest memory with range/size checks.
native/whp/devices/uart.h Adds UART device interface with IRQ raiser wiring and CRLF normalization contract.
native/whp/devices/pit.h Adds PIT device declaration for IRQ0 + channel 2 calibration behavior.
native/whp/devices/pit.cc Implements PIT behavior (reload, latching, irq coalescing, channel 2 gating).
native/whp/devices/pic.h Adds minimal PIC (8259A) device declaration used to gate ExtInt injection.
native/whp/devices/pic.cc Implements PIC init/mask handling + fixed interrupt requests.
native/whp/devices/hpet.h Adds HPET device declaration for Linux clocksource/timer usage.
native/whp/devices/cmos.h Adds CMOS/RTC device declaration for stable boot/runtime reads.
native/whp/devices/cmos.cc Implements CMOS/RTC reads with host UTC refresh on access.
native/whp/devices/acpi_pm_timer.h Adds ACPI PM timer device declaration.
native/whp/devices/acpi_pm_timer.cc Implements free-running ACPI PM timer counter reads.
native/whp/boot_params.h Declares Linux x86 boot params + MP table writers.
native/whp/boot_params.cc Implements boot params and MP table construction.
native/whp/api.h Adds header-only dynamic loader for WinHvPlatform/WinHvEmulation entry points.
native/common/bytes.h Adds shared C++ byte helpers, checked arithmetic/range helpers, and Windows error formatting.
guest/node-vmm-console.cc Improves guest console helper (CRLF handling, tty mode, polling/drain behavior, tty sizing).
docs/testing.md Updates test documentation for Windows/WHP and macOS/HVF gates and matrices.
docs/sdk.md Documents expanded SDK surface: Windows prebuilt rootfs behavior, persistence/attach-disk semantics, etc.
docs/publishing.md Updates publishing docs for multi-OS prebuild release workflow and rootfs prebuilts.
docs/performance.md Adds latest WHP performance measurements and sample outputs.
docs/cpp-coverage-exclusions.json Updates excluded native file path to new KVM backend location.
binding.gyp Splits native backend sources per OS, adds HVF sources/flags, and WHP module list + optional libslirp wiring.
.gitignore Ignores new tooling/cache directories.
.github/workflows/release-prebuilds.yml Adds tag-triggered multi-OS prebuild build+release+publish workflow.
.github/workflows/prebuilt-rootfs.yml Adds tag-triggered rootfs prebuild build+release workflow.
.github/workflows/ci.yml Renames/restructures CI jobs and adds self-hosted WHP/KVM gates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/disk.ts
@misaelzapata
misaelzapata merged commit 8f13389 into main May 3, 2026
4 checks passed
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