Conversation
📝 WalkthroughWalkthroughThe VM interface now exposes platform-specific secondary CPU boot policy. KVM enables secondary vCPU booting, Apple Hypervisor disables it, and the VMM conditionally boots secondary vCPUs. KVM vCPU execution also retries ChangesSecondary vCPU boot behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Vm
participant HypervisorVm
participant SecondaryVcpu
Vm->>HypervisorVm: secondary_cpu_should_run_on_booting()
HypervisorVm-->>Vm: return boot policy
Vm->>SecondaryVcpu: boot each active vCPU ID starting at 1
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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-core/src/virtualization/kvm/vcpu.rs`:
- Around line 107-113: Update the `vcpu_fd.run()` error handling in the vCPU
execution loop to retry both `libc::EAGAIN` and `libc::EINTR` with `continue`.
Replace the fallback `panic!` for other errors with returning
`VcpuError::KvmError`, preserving the existing vCPU error propagation path.
🪄 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: bdb87d14-ddd8-4c7e-b441-2bcd30543c70
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (9)
Cargo.tomlcrates/vm-core/Cargo.tomlcrates/vm-core/src/virtualization/hvp/vm.rscrates/vm-core/src/virtualization/kvm/vcpu.rscrates/vm-core/src/virtualization/kvm/vm.rscrates/vm-core/src/virtualization/vm.rscrates/vm-vmm/src/vm.rscrates/vm-vmm/src/vm/config.rscrates/vm-vmm/src/vm/snapshot.rs
| let vm_exit = match vcpu_fd.run() { | ||
| Ok(vm_exit) => vm_exit, | ||
| Err(err) => match err.errno() { | ||
| libc::EAGAIN => continue, | ||
| _ => panic!("{err}"), | ||
| }, | ||
| }; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if VcpuError can wrap a kvm run error and look at the error enum.
rg -A 10 'enum VcpuError' crates/vm-core/src/
# Check for EINTR occurrences in similar kvm runs in other projects or this one.
rg 'EINTR' crates/vm-core/Repository: junyu0312/rust-vm
Length of output: 983
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map relevant files and inspect the vCPU error type and KVM run loop.
git ls-files crates/vm-core/src/virtualization/kvm/vcpu.rs crates/vm-core/src/virtualization/vcpu/error.rs
echo '--- error.rs ---'
cat -n crates/vm-core/src/virtualization/vcpu/error.rs
echo '--- kvm/vcpu.rs (around run loop) ---'
sed -n '1,220p' crates/vm-core/src/virtualization/kvm/vcpu.rsRepository: junyu0312/rust-vm
Length of output: 6721
🏁 Script executed:
#!/bin/bash
set -euo pipefail
git ls-files crates/vm-core/src/virtualization/kvm/vcpu.rs crates/vm-core/src/virtualization/vcpu/error.rs
echo '--- error.rs ---'
cat -n crates/vm-core/src/virtualization/vcpu/error.rs
echo '--- kvm/vcpu.rs (around run loop) ---'
sed -n '1,220p' crates/vm-core/src/virtualization/kvm/vcpu.rsRepository: junyu0312/rust-vm
Length of output: 6721
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- error.rs ---'
cat -n crates/vm-core/src/virtualization/vcpu/error.rs
echo '--- kvm/vcpu.rs (around run loop) ---'
sed -n '1,220p' crates/vm-core/src/virtualization/kvm/vcpu.rsRepository: junyu0312/rust-vm
Length of output: 6627
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the KVM vCPU run loop and its return type / error plumbing.
rg -n -A 4 -B 4 'vcpu_fd\.run\(\)|fn .*vcpu|Result<.*, VcpuError>|VcpuError' crates/vm-core/src/virtualization/kvm crates/vm-core/src/virtualization/vcpuRepository: junyu0312/rust-vm
Length of output: 19580
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- EINTR in repo ---'
rg -n 'EINTR|EAGAIN|errno\(\)' crates/vm-core/src crates -g '!target' || true
echo '--- kvm_ioctls dependency versions ---'
rg -n 'kvm_ioctls|kvm-bindings' Cargo.toml Cargo.lock crates/**/Cargo.toml || trueRepository: junyu0312/rust-vm
Length of output: 1121
Retry EINTR and avoid panicking on KVM run errors. Treat EINTR like EAGAIN here, and return the remaining run() errors via VcpuError::KvmError instead of aborting the vCPU thread.
🤖 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/src/virtualization/kvm/vcpu.rs` around lines 107 - 113, Update
the `vcpu_fd.run()` error handling in the vCPU execution loop to retry both
`libc::EAGAIN` and `libc::EINTR` with `continue`. Replace the fallback `panic!`
for other errors with returning `VcpuError::KvmError`, preserving the existing
vCPU error propagation path.
Summary by CodeRabbit
New Features
Bug Fixes