docs.rs failed to build a3s-libkrun-sys-0.1.5
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
a3s-libkrun-sys
FFI bindings to libkrun with Windows WHPX backend support.
Features
- ✅ Cross-platform: Linux (KVM), macOS (Hypervisor.framework), Windows (WHPX)
- ✅ Windows WHPX Backend: Full Windows Hypervisor Platform support
- ✅ virtiofs: Passthrough filesystem on all platforms
- ✅ virtio-net: Network device with TCP backend on Windows
- ✅ virtio-blk: Block device support
- ✅ virtio-console: Serial console
- ✅ TSI: Transparent Socket Impersonation for vsock
Platform Support
| Platform | Backend | Status |
|---|---|---|
| Linux x86_64 | KVM | ✅ Supported |
| Linux aarch64 | KVM | ✅ Supported |
| macOS arm64 | Hypervisor.framework | ✅ Supported |
| Windows x86_64 | WHPX | ✅ Supported |
Installation
Add to your Cargo.toml:
[]
= "0.1.5"
Windows Requirements
On Windows, you need to enable the Windows Hypervisor Platform:
# Run as Administrator
Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform
# Reboot required
Restart-Computer
Verify it's enabled:
Get-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform
Usage
use *;
use CString;
unsafe
Windows-Specific APIs
Network Device (TCP Backend)
unsafe
Block Device
unsafe
VSock with Named Pipes
unsafe
Examples
See the examples directory:
windows_vm_test.rs- Basic Windows VM testnginx_test.rs- Full nginx container test
Run examples:
# Windows
cargo run --example windows_vm_test --target x86_64-pc-windows-msvc
cargo run --example nginx_test --target x86_64-pc-windows-msvc
Building from Source
Windows
# Clone with submodules
git clone --recursive https://github.com/A3S-Lab/Box.git
cd Box/src/deps/libkrun-sys
# Build libkrun
cd vendor/libkrun
cargo build --release --target x86_64-pc-windows-msvc
# Copy DLL
Copy-Item target\x86_64-pc-windows-msvc\release\krun.dll ..\..\prebuilt\x86_64-pc-windows-msvc\
# Run tests
cd ..\..
cargo test --target x86_64-pc-windows-msvc --lib -- --test-threads=1
Architecture
The Windows WHPX backend includes:
- WHPX VM/vCPU Management (
src/vmm/src/windows/vstate.rs,whpx_vcpu.rs) - virtio Devices:
virtio-fs- virtiofs passthrough (src/devices/src/virtio/fs/windows/)virtio-net- TCP backend (src/devices/src/virtio/net_windows.rs)virtio-blk- File-backed block device (src/devices/src/virtio/block_windows.rs)virtio-console- Serial console (src/devices/src/virtio/console_windows.rs)virtio-vsock- TSI implementation (src/devices/src/virtio/vsock/tsi/windows/)
- EventFd - Windows event wrapper (
src/utils/src/windows/eventfd.rs)
Testing
# All tests (Windows)
cargo test --target x86_64-pc-windows-msvc --lib -- --test-threads=1
# Specific test
cargo test --target x86_64-pc-windows-msvc --lib test_krun_create_ctx -- --test-threads=1
Note: Use --test-threads=1 on Windows due to WHPX partition limits.
Documentation
License
MIT License - see LICENSE for details.
Contributing
Contributions welcome! Please see CONTRIBUTING.md.
Credits
- Based on libkrun by Red Hat
- Windows WHPX backend by A3S Lab Team