Skip to content

chore: Remove hvp/kvm features - #185

Merged
junyu0312 merged 1 commit into
mainfrom
virtio
Jul 5, 2026
Merged

junyu0312 merged 1 commit into
mainfrom
virtio

Conversation

@junyu0312

@junyu0312 junyu0312 commented Jul 5, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Platform-specific virtualization handling now follows the detected operating system, simplifying how the app selects macOS and Linux virtualization support.
  • Bug Fixes

    • Updated build and runtime configuration so release builds and CI jobs use the correct platform-specific behavior without relying on extra feature flags.
    • Improved consistency across error handling for macOS and Linux virtualization paths.
  • Chores

    • Streamlined project configuration by removing obsolete feature-based setup.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@junyu0312, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f60c26d-a0b3-4f39-93bc-30e719d6b986

📥 Commits

Reviewing files that changed from the base of the PR and between fa5eff9 and 90ac1c5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .github/workflows/ci.yaml
  • crates/vm-cli/Cargo.toml
  • crates/vm-cli/src/main.rs
  • crates/vm-core/Cargo.toml
  • crates/vm-core/src/virtualization.rs
  • crates/vm-core/src/virtualization/hypervisor/error.rs
  • crates/vm-core/src/virtualization/vcpu/error.rs
  • crates/vm-core/src/virtualization/vm/error.rs
  • crates/vm-vmm/Cargo.toml
  • scripts/run_hvp.sh
📝 Walkthrough

Walkthrough

This PR migrates hypervisor selection and conditional compilation from Cargo feature flags (kvm, hvp) to target_os/target_arch cfg checks across vm-cli, vm-core, and vm-vmm crates, restructuring Cargo.toml dependency blocks and updating CI workflow and build script invocations accordingly.

Changes

Feature-to-target_os cfg migration

Layer / File(s) Summary
Cargo manifest restructuring
crates/vm-cli/Cargo.toml, crates/vm-core/Cargo.toml, crates/vm-vmm/Cargo.toml
Removes [features] sections defining kvm/hvp; moves dependencies (vm-aarch64, strum_macros, kvm-bindings, kvm-ioctls, applevisor, applevisor-sys, strum) into target-specific (aarch64, linux, macos) dependency blocks; makes strum non-optional in vm-vmm.
Hypervisor selection and module gating
crates/vm-cli/src/main.rs, crates/vm-core/src/virtualization.rs
Changes cfg_select! hypervisor construction and hvp/kvm module declarations to branch on target_os instead of feature flags.
Error enum cfg gating
crates/vm-core/src/virtualization/hypervisor/error.rs, crates/vm-core/src/virtualization/vcpu/error.rs, crates/vm-core/src/virtualization/vm/error.rs
Updates cfg attributes on Kvm/ApplevisorError/KvmError enum variants from feature-based to target_os-based gating.
CI and build script updates
.github/workflows/ci.yaml, scripts/run_hvp.sh
Removes --no-default-features --features hvp flags from Arm64/hvp build, clippy, and udeps CI steps and from the release build command in run_hvp.sh.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • junyu0312/rust-vm#111: Both PRs touch hvp module compilation/selection, with #111 refactoring applevisor to applevisor_sys in the same module affected by the target_os gating change.
  • junyu0312/rust-vm#139: Both PRs modify VmError's ApplevisorError variant in crates/vm-core/src/virtualization/vm/error.rs.
  • junyu0312/rust-vm#154: Both PRs modify the same kvm/hvp conditional compilation hotspots in crates/vm-core/src/virtualization.rs and related error modules.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: removing hvp/kvm feature gating in favor of target-specific compilation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch virtio

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/ci.yaml (1)

45-56: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value

Consider adding explicit permissions: blocks.

zizmor flags these jobs as running with default (broad) GITHUB_TOKEN permissions since no permissions: block is set. Pre-existing and unrelated to this feature-flag removal, but worth tightening while touching these jobs.

Also applies to: 103-116, 152-167

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yaml around lines 45 - 56, The GitHub Actions jobs
currently rely on the default broad GITHUB_TOKEN scope because they do not
define an explicit permissions block. Add a minimal permissions: section to the
affected job definitions in ci.yaml, including build_arm64_hvp and the other
referenced jobs, and keep the scopes as restrictive as possible for the steps
they run. Use the existing job names to locate each workflow block and apply the
same tightening consistently across them.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/vm-cli/src/main.rs`:
- Around line 22-27: The macOS branch in the hypervisor selection logic needs to
be limited to Apple Silicon builds because `AppleHypervisor` depends on
`crate::arch::aarch64::*` and will not compile on x86_64 macOS. Update the
platform gating in the `select_hypervisor` path so the
`vm_core::virtualization::hvp::AppleHypervisor` arm only matches when both
`target_os = "macos"` and `target_arch = "aarch64"` are true, and ensure the
other hypervisor arms remain unchanged.

In `@crates/vm-core/Cargo.toml`:
- Around line 24-38: The macOS virtualization dependencies are currently enabled
for every macOS build, which pulls in Apple Silicon-only crates on x86_64.
Update the dependency gate in Cargo.toml so the applevisor, applevisor-sys, and
strum entries are only included when both target_os is macos and target_arch is
aarch64, and keep the existing vm-core/vm-aarch64 related paths aligned with
that architecture-specific gating.

---

Nitpick comments:
In @.github/workflows/ci.yaml:
- Around line 45-56: The GitHub Actions jobs currently rely on the default broad
GITHUB_TOKEN scope because they do not define an explicit permissions block. Add
a minimal permissions: section to the affected job definitions in ci.yaml,
including build_arm64_hvp and the other referenced jobs, and keep the scopes as
restrictive as possible for the steps they run. Use the existing job names to
locate each workflow block and apply the same tightening consistently across
them.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 991b9cc6-b993-480a-8428-69f7eef671af

📥 Commits

Reviewing files that changed from the base of the PR and between f9a2e64 and fa5eff9.

📒 Files selected for processing (10)
  • .github/workflows/ci.yaml
  • crates/vm-cli/Cargo.toml
  • crates/vm-cli/src/main.rs
  • crates/vm-core/Cargo.toml
  • crates/vm-core/src/virtualization.rs
  • crates/vm-core/src/virtualization/hypervisor/error.rs
  • crates/vm-core/src/virtualization/vcpu/error.rs
  • crates/vm-core/src/virtualization/vm/error.rs
  • crates/vm-vmm/Cargo.toml
  • scripts/run_hvp.sh
💤 Files with no reviewable changes (1)
  • crates/vm-cli/Cargo.toml

Comment thread crates/vm-cli/src/main.rs
Comment on lines +22 to 27
target_os = "macos" => {
Ok(Box::new(vm_core::virtualization::hvp::AppleHypervisor))
}
feature = "kvm" => {
target_os = "linux" => {
Ok(Box::new(vm_core::virtualization::kvm::KvmHypervisor::new()?))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Files ==\n'
git ls-files crates/vm-cli/src/main.rs crates/vm-core/Cargo.toml crates/vm-core/src/virtualization.rs crates/vm-core/src/virtualization/* 2>/dev/null || true

printf '\n== main.rs outline ==\n'
ast-grep outline crates/vm-cli/src/main.rs --view expanded || true

printf '\n== Cargo.toml outline ==\n'
ast-grep outline crates/vm-core/Cargo.toml --view expanded || true

printf '\n== Search for AppleHypervisor and target_arch gates ==\n'
rg -n 'AppleHypervisor|target_arch|aarch64|x86_64-apple-darwin|target_os = "macos"|cfg_select!' crates/vm-core crates/vm-cli -S

Repository: junyu0312/rust-vm

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== main.rs around the relevant lines ==\n'
sed -n '1,120p' crates/vm-cli/src/main.rs

printf '\n== vm-core Cargo.toml around dependency/configuration lines ==\n'
sed -n '1,220p' crates/vm-core/Cargo.toml

printf '\n== virtualization.rs relevant slice ==\n'
sed -n '1,240p' crates/vm-core/src/virtualization.rs

Repository: junyu0312/rust-vm

Length of output: 3356


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Determine whether AppleHypervisor is gated by arch in code or docs ==\n'
rg -n 'AppleHypervisor|Hypervisor.framework|aarch64|arm64|Intel Macs|x86_64' -S .

Repository: junyu0312/rust-vm

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Narrow, read-only inspection for the exact branches and cfgs.
printf '\n== crates/vm-cli/src/main.rs ==\n'
nl -ba crates/vm-cli/src/main.rs | sed -n '1,120p'

printf '\n== crates/vm-core/Cargo.toml ==\n'
nl -ba crates/vm-core/Cargo.toml | sed -n '1,220p'

printf '\n== crates/vm-core/src/virtualization.rs ==\n'
nl -ba crates/vm-core/src/virtualization.rs | sed -n '1,260p'

Repository: junyu0312/rust-vm

Length of output: 228


🌐 Web query:

Hypervisor.framework Intel Macs supported Apple Silicon only macOS Hypervisor.framework availability

💡 Result:

The Hypervisor.framework is available and supported on both Intel-based Macs and Apple Silicon Macs [1][2][3]. It is not restricted to Apple Silicon [1][3]. On Intel-based Mac computers, the framework requires a processor that supports the Intel VT-x feature set, including Extended Page Tables (EPT) and Unrestricted Mode [1][4][5]. These requirements generally align with Intel processors from the Westmere generation (released in 2010) or newer [4][6]. Developers can verify if a specific Intel-based Mac supports the framework by checking if the command sysctl kern.hv_support returns 1 [4][5][7]. On Apple Silicon Macs, the Hypervisor.framework is fully supported to build virtualization solutions [8][9]. Furthermore, starting with macOS 15.0, Apple added support for nested virtualization on Apple Silicon through the framework, enabling a hypervisor to run inside another virtual machine [10]. For high-level tasks, Apple also provides the Virtualization.framework, which is available on both Intel and Apple Silicon architectures and provides a higher-level API for running virtual machines [3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,220p' crates/vm-core/src/virtualization/hvp.rs
printf '\n==\n'
sed -n '1,220p' crates/vm-core/src/virtualization/hvp/vm.rs
printf '\n==\n'
sed -n '1,260p' crates/vm-core/src/virtualization/hvp/vcpu.rs

Repository: junyu0312/rust-vm

Length of output: 16904


Gate the macOS hypervisor path on target_arch = "aarch64". AppleHypervisor pulls in crate::arch::aarch64::*, so x86_64-apple-darwin will hit this branch and fail to compile.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/vm-cli/src/main.rs` around lines 22 - 27, The macOS branch in the
hypervisor selection logic needs to be limited to Apple Silicon builds because
`AppleHypervisor` depends on `crate::arch::aarch64::*` and will not compile on
x86_64 macOS. Update the platform gating in the `select_hypervisor` path so the
`vm_core::virtualization::hvp::AppleHypervisor` arm only matches when both
`target_os = "macos"` and `target_arch = "aarch64"` are true, and ensure the
other hypervisor arms remain unchanged.

Comment thread crates/vm-core/Cargo.toml
Comment on lines 24 to +38
strum_macros = { workspace = true }
vm-aarch64 = { workspace = true }

[target.'cfg(target_arch = "x86_64")'.dependencies]
vm-firmware = { workspace = true }

[target.'cfg(target_os = "linux")'.dependencies]
kvm-bindings = { workspace = true }
kvm-ioctls = { workspace = true }
vmm-sys-util = { workspace = true }

[features]
kvm = ["kvm-bindings", "kvm-ioctls"]
hvp = ["applevisor", "applevisor-sys", "strum"]
[target.'cfg(target_os = "macos")'.dependencies]
applevisor = { workspace = true }
applevisor-sys = { workspace = true }
strum = { workspace = true }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== Cargo.toml ==\n'
sed -n '1,220p' crates/vm-core/Cargo.toml

printf '\n== virtualization.rs outline ==\n'
ast-grep outline crates/vm-core/src/virtualization.rs --view expanded || true

printf '\n== main.rs outline ==\n'
ast-grep outline crates/vm-cli/src/main.rs --view expanded || true

printf '\n== Search for applevisor / hvp / aarch64 gates ==\n'
rg -n --hidden --glob '!target' --glob '!**/node_modules/**' \
  'applevisor|applevisor-sys|hv_vm_config_set_el2_enabled|target_arch\s*=\s*"aarch64"|cfg_select!|feature\s*=\s*"hvp"|hvp' \
  crates/vm-core crates/vm-cli

Repository: junyu0312/rust-vm

Length of output: 14450


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== crates/vm-core/src/virtualization.rs (relevant slice) ==\n'
sed -n '1,260p' crates/vm-core/src/virtualization.rs

printf '\n== crates/vm-core/src/virtualization/hvp.rs (relevant slice) ==\n'
sed -n '1,260p' crates/vm-core/src/virtualization/hvp.rs

printf '\n== crates/vm-cli/src/main.rs (relevant slice) ==\n'
sed -n '1,260p' crates/vm-cli/src/main.rs

Repository: junyu0312/rust-vm

Length of output: 3528


🌐 Web query:

applevisor crate supported architectures macOS x86_64 aarch64 Hypervisor.framework

💡 Result:

The applevisor Rust crate provides safe bindings specifically for the Apple Silicon (aarch64) Hypervisor.framework [1][2]. According to its documentation and metadata, the crate is designed for and explicitly focuses on support for aarch64 (Apple Silicon) architectures [1][2]. It does not support x86_64 architectures because it acts as a wrapper for the Apple Silicon-specific Hypervisor.framework APIs [1][3]. Key points regarding its architecture support: - Primary Architecture: aarch64 (Apple Silicon) [1][2]. - Platform Limitation: The crate is intended for macOS on Apple Silicon [1][2]. - API Focus: It provides bindings to the Hypervisor.framework as it exists on Apple Silicon [1][3]. Consequently, it is incompatible with x86_64 macOS environments [1][2]. Developers using this crate must ensure their project is targeting the appropriate Apple Silicon hardware and that their binary has been granted the necessary com.apple.security.hypervisor entitlement to interact with the framework [3].

Citations:


Gate the macOS virtualization deps by target_arch = "aarch64". applevisor/applevisor-sys are Apple Silicon-only, but hvp is still compiled for every macOS target, so x86_64-apple-darwin will pull in the ARM-only path and fail the build. strum can move with the same gate since it’s only used there.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/vm-core/Cargo.toml` around lines 24 - 38, The macOS virtualization
dependencies are currently enabled for every macOS build, which pulls in Apple
Silicon-only crates on x86_64. Update the dependency gate in Cargo.toml so the
applevisor, applevisor-sys, and strum entries are only included when both
target_os is macos and target_arch is aarch64, and keep the existing
vm-core/vm-aarch64 related paths aligned with that architecture-specific gating.

@junyu0312
junyu0312 merged commit bef7270 into main Jul 5, 2026
11 of 12 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.

1 participant