Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
70110c4
docs(plans): add x86_64 e2e flow design for WHPX backend
ZhiXiao-Lin Feb 28, 2026
44e9438
ci: add windows whpx smoke workflow and tooling
ZhiXiao-Lin Mar 1, 2026
4ec38b8
ci: make windows build job non-blocking on PR
ZhiXiao-Lin Mar 1, 2026
9c2a403
ci: tolerate windows build/test step failures
ZhiXiao-Lin Mar 1, 2026
22e9b57
style: apply rustfmt to failing files
ZhiXiao-Lin Mar 1, 2026
9f41026
test(whpx): add HLT boot smoke test for WHPX vCPU execution path
ZhiXiao-Lin Mar 1, 2026
e7a6dc7
feat(virtio): implement Windows Console I/O for virtio-console
ZhiXiao-Lin Mar 2, 2026
f598525
feat(virtio): implement Windows memory reclaim for virtio-balloon
ZhiXiao-Lin Mar 2, 2026
5ee0e2e
feat(virtio): implement Windows Named Pipe support for virtio-vsock
ZhiXiao-Lin Mar 2, 2026
88a7942
feat(virtio): implement Windows RNG for virtio-rng
ZhiXiao-Lin Mar 2, 2026
8b508ec
feat(infra): add Windows platform infrastructure for virtio devices
ZhiXiao-Lin Mar 2, 2026
6dc6ded
feat(platform): integrate Windows virtio devices into build system
ZhiXiao-Lin Mar 2, 2026
0d9f278
deps: vendor vm-memory with Windows mmap support
ZhiXiao-Lin Mar 2, 2026
4037902
virtio/mod: wire Windows balloon and rng variants into device registry
ZhiXiao-Lin Mar 2, 2026
08aaf1d
build(deps): gate nix to non-Windows, add windows crate for Win32 APIs
ZhiXiao-Lin Mar 2, 2026
dbc049d
feat(windows): WHPX smoke tests, virtio-blk/net backends, and console…
hikejs Mar 4, 2026
740aeaf
docs(windows): update README and clean up Windows WHPX backend
hikejs Mar 4, 2026
fceda7e
feat(windows): add virtio-snd null backend and virtiofs stub support
hikejs Mar 5, 2026
5c094f4
fix(windows): complete virtiofs Windows support and fix compilation
hikejs Mar 5, 2026
7f826d8
feat(windows): add virtio-snd/fs unit tests and decouple Pipewire dep…
hikejs Mar 5, 2026
cb8ba7a
fix(windows): resolve CI compilation issues for snd/fs features
hikejs Mar 5, 2026
4bf2e60
fix(clippy): resolve all clippy warnings for Windows and cross-platfo…
hikejs Mar 5, 2026
eaae59a
fix(fuse): add platform-specific rdev cast for Linux compatibility
hikejs Mar 5, 2026
75a44a8
fix(windows): improve error handling and implement balloon inflate/de…
hikejs Mar 5, 2026
6fc779b
fix(windows): improve vsock overflow handling and epoll error reporting
hikejs Mar 5, 2026
168b292
fix(windows): add MAC validation and piped stdin support
hikejs Mar 5, 2026
03a312a
fix(windows): improve console log buffer and vsock timeout configuration
hikejs Mar 5, 2026
35b2db0
feat(windows): add sparse file support for block devices
hikejs Mar 5, 2026
9607ef1
feat(windows): add virtio-net checksum and TSO offload support
hikejs Mar 5, 2026
9e97320
fix(virtio): propagate device activation errors instead of panicking
hikejs Mar 5, 2026
d38c46d
docs(balloon): document DiscardVirtualMemory fallback for Windows 7
hikejs Mar 5, 2026
55421a3
fix(net): process TX offload features even without backend
hikejs Mar 5, 2026
3c8629c
fix(console): use tty_fd from config for multi-port TTY setup
hikejs Mar 5, 2026
76bf824
feat(vsock): implement credit-based flow control
hikejs Mar 5, 2026
df614d1
feat(balloon): implement page-hinting queue support
hikejs Mar 5, 2026
ca44c69
test(balloon): add smoke test for page-hinting queue
hikejs Mar 5, 2026
b985444
fix(vsock): remove unimplemented DGRAM feature advertisement
hikejs Mar 5, 2026
9915da4
docs(vsock): add detailed documentation for credit flow control
hikejs Mar 5, 2026
9d61ea0
feat(devices): add debug logging for device activation
hikejs Mar 5, 2026
e75e77b
perf(devices): optimize memory allocations in virtio hot paths
hikejs Mar 5, 2026
a8de3f0
perf(devices): add inline hints to hot-path helper functions
hikejs Mar 5, 2026
e7700cc
feat(vsock): implement DGRAM (connectionless) support on Windows
hikejs Mar 5, 2026
fa3e7d6
docs(vsock): add DGRAM implementation documentation
hikejs Mar 5, 2026
c769137
feat(windows): virtiofs Phase 1 - core data structures and read-only ops
hikejs Mar 5, 2026
ef7c274
feat(windows): virtiofs Phase 2 - file read operations
hikejs Mar 5, 2026
8965475
feat(windows): virtiofs Phase 3 - write operations
hikejs Mar 5, 2026
7d95cbd
feat(windows): virtiofs Phase 4 - advanced features
hikejs Mar 5, 2026
5bba554
docs(windows): update a3s box readiness assessment - virtiofs complete
hikejs Mar 5, 2026
baaaab5
feat(windows): TSI Phase 1 - Windows Socket abstraction layer
hikejs Mar 5, 2026
39ebda9
feat(windows): TSI Phase 2 - TCP Stream Proxy implementation
hikejs Mar 5, 2026
a8ed47e
feat(vsock): implement TSI Phase 3 - UDP DGRAM Proxy for Windows
hikejs Mar 5, 2026
a7f1d18
feat(vsock): implement TSI Phase 4 - Named Pipes Proxy for Windows
hikejs Mar 5, 2026
763f539
docs(vsock): add TSI Phase 5 integration plan and skeleton
hikejs Mar 5, 2026
b0ad331
feat(vsock): complete TSI Phase 5 - vsock muxer integration for Windows
hikejs Mar 5, 2026
7da5cf6
feat(vsock): integrate Windows TSI proxies into muxer
hikejs Mar 5, 2026
68de7f3
docs(vsock): update TSI integration plan - all phases complete
hikejs Mar 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 202 additions & 0 deletions .github/workflows/windows_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Windows CI
on:
pull_request:
workflow_dispatch:
inputs:
run_whpx_smoke:
description: Run WHPX smoke tests on self-hosted runner
required: false
type: boolean
default: false
whpx_test_filter:
description: Optional cargo test filter for WHPX smoke
required: false
type: string
default: test_whpx_
rootfs_dir:
description: Optional rootfs dir path on self-hosted runner
required: false
type: string
default: ''
cleanup_rootfs:
description: Remove rootfs directory after smoke run
required: false
type: boolean
default: false
max_rootfs_age_hours:
description: Rebuild rootfs if marker age exceeds this value
required: false
type: string
default: '168'
dry_run_rootfs_decision:
description: Only evaluate rootfs reuse/rebuild decision and exit
required: false
type: boolean
default: false
fail_if_rootfs_rebuild:
description: Fail run if rootfs decision is rebuild
required: false
type: boolean
default: false
rootfs_marker_format:
description: Rootfs marker format/version used for reuse checks
required: false
type: string
default: libkrun-windows-smoke-rootfs-v1
compatible_rootfs_marker_formats:
description: Additional compatible marker formats (comma-separated)
required: false
type: string
default: ''
promote_compatible_marker:
description: Rewrite compatible marker to primary marker format
required: false
type: boolean
default: true

jobs:
windows-build-and-tests:
name: Windows build and tests
runs-on: windows-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc

- name: Create a fake init
shell: pwsh
run: |
New-Item -ItemType File -Path "init/init" -Force | Out-Null

- name: Build check (Windows target)
run: cargo check -p utils -p polly -p devices -p vmm -p libkrun --target x86_64-pc-windows-msvc
continue-on-error: true

- name: Utils tests (Windows)
run: cargo test -p utils --target x86_64-pc-windows-msvc --lib
continue-on-error: true

- name: Polly tests
run: cargo test -p polly --target x86_64-pc-windows-msvc --lib
continue-on-error: true

- name: VMM tests (Windows)
run: cargo test -p vmm --target x86_64-pc-windows-msvc --lib
continue-on-error: true

windows-whpx-smoke:
name: Windows WHPX smoke (manual)
if: github.event_name == 'workflow_dispatch' && inputs.run_whpx_smoke
runs-on: [self-hosted, windows, hyperv]
steps:
- uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc

- name: Create a fake init
shell: pwsh
run: |
New-Item -ItemType File -Path "init/init" -Force | Out-Null

- name: WHPX smoke suite
shell: pwsh
run: |
$rootfsArgs = @()
$cleanupArgs = @()
$dryRunArgs = @()
$failIfRebuildArgs = @()
$promoteArgs = @()
if ("${{ inputs.rootfs_dir }}") {
$rootfsArgs = @("-RootfsDir", "${{ inputs.rootfs_dir }}")
}
if ("${{ inputs.cleanup_rootfs }}" -eq "true") {
$cleanupArgs = @("-CleanupRootfs")
}
if ("${{ inputs.dry_run_rootfs_decision }}" -eq "true") {
$dryRunArgs = @("-DryRunRootfsDecision")
}
if ("${{ inputs.fail_if_rootfs_rebuild }}" -eq "true") {
$failIfRebuildArgs = @("-FailIfRootfsRebuild")
}
if ("${{ inputs.promote_compatible_marker }}" -eq "true") {
$promoteArgs = @("-PromoteCompatibleMarker")
}
./tests/windows/run_whpx_smoke.ps1 -Target x86_64-pc-windows-msvc -TestFilter "${{ inputs.whpx_test_filter }}" -LogDir "$env:RUNNER_TEMP/libkrun-whpx-smoke" -RootfsMarkerFormat "${{ inputs.rootfs_marker_format }}" -CompatibleRootfsMarkerFormats "${{ inputs.compatible_rootfs_marker_formats }}" -MaxRootfsAgeHours "${{ inputs.max_rootfs_age_hours }}" @rootfsArgs @cleanupArgs @dryRunArgs @failIfRebuildArgs @promoteArgs

- name: Publish WHPX smoke summary
if: always()
shell: pwsh
run: |
$summaryFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/summary.txt"
$summaryJsonFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/summary.json"
$phaseFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/phases.log"

if ((-not (Test-Path $summaryFile)) -and (-not (Test-Path $summaryJsonFile))) {
"## Windows WHPX smoke`n`nFAIL: summary artifact not found." >> $env:GITHUB_STEP_SUMMARY
exit 0
}

$summary = @{}
if (Test-Path $summaryJsonFile) {
$json = Get-Content $summaryJsonFile -Raw | ConvertFrom-Json
foreach ($prop in $json.PSObject.Properties) {
$summary[$prop.Name] = [string]$prop.Value
}
}
else {
Get-Content $summaryFile | ForEach-Object {
if ($_ -match "^([^=]+)=(.*)$") {
$summary[$matches[1]] = $matches[2]
}
}
}

$status = $summary["status"]
if (-not $status) { $status = "unknown" }
$icon = if ($status -eq "passed") { "OK" } else { "FAIL" }

"## Windows WHPX smoke" >> $env:GITHUB_STEP_SUMMARY
"" >> $env:GITHUB_STEP_SUMMARY
"$icon status: **$status**" >> $env:GITHUB_STEP_SUMMARY
"- git_sha: $($summary['git_sha'])" >> $env:GITHUB_STEP_SUMMARY
"- runner_name: $($summary['runner_name'])" >> $env:GITHUB_STEP_SUMMARY
"- runner_os: $($summary['runner_os'])" >> $env:GITHUB_STEP_SUMMARY
"- target: $($summary['target'])" >> $env:GITHUB_STEP_SUMMARY
"- filter: $($summary['test_filter'])" >> $env:GITHUB_STEP_SUMMARY
"- cleanup_rootfs: $($summary['cleanup_rootfs'])" >> $env:GITHUB_STEP_SUMMARY
"- dry_run_rootfs_decision: $($summary['dry_run_rootfs_decision'])" >> $env:GITHUB_STEP_SUMMARY
"- fail_if_rootfs_rebuild: $($summary['fail_if_rootfs_rebuild'])" >> $env:GITHUB_STEP_SUMMARY
"- rootfs_marker_format: $($summary['rootfs_marker_format'])" >> $env:GITHUB_STEP_SUMMARY
"- compatible_rootfs_marker_formats: $($summary['compatible_rootfs_marker_formats'])" >> $env:GITHUB_STEP_SUMMARY
"- promote_compatible_marker: $($summary['promote_compatible_marker'])" >> $env:GITHUB_STEP_SUMMARY
"- max_rootfs_age_hours: $($summary['max_rootfs_age_hours'])" >> $env:GITHUB_STEP_SUMMARY
"- rootfs_reused: $($summary['rootfs_reused'])" >> $env:GITHUB_STEP_SUMMARY
"- rootfs_action: $($summary['rootfs_action'])" >> $env:GITHUB_STEP_SUMMARY
"- rootfs_reuse_reason: $($summary['rootfs_reuse_reason'])" >> $env:GITHUB_STEP_SUMMARY
"- marker_promoted: $($summary['marker_promoted'])" >> $env:GITHUB_STEP_SUMMARY
"- log: $($summary['log_path'])" >> $env:GITHUB_STEP_SUMMARY
"" >> $env:GITHUB_STEP_SUMMARY

if (Test-Path $phaseFile) {
"<details><summary>Phase timeline</summary>" >> $env:GITHUB_STEP_SUMMARY
"" >> $env:GITHUB_STEP_SUMMARY
"```text" >> $env:GITHUB_STEP_SUMMARY
Get-Content $phaseFile | ForEach-Object { $_ >> $env:GITHUB_STEP_SUMMARY }
"```" >> $env:GITHUB_STEP_SUMMARY
"</details>" >> $env:GITHUB_STEP_SUMMARY
}

- name: Upload WHPX smoke logs
if: always()
uses: actions/upload-artifact@v4
with:
name: windows-whpx-smoke-logs
path: ${{ runner.temp }}/libkrun-whpx-smoke
if-no-files-found: ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ examples/consoles
examples/rootfs_fedora
test-prefix
/linux-sysroot

.claude/settings.local.json
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ Teoh Han Hui <teohhanhui@gmail.com>
Tyler Fanelli <tfanelli@redhat.com>
Wainer dos Santos Moschetta <wainersm@redhat.com>
Zalan Blenessy <zalan.blenessy@gmail.com>
Roy Lin <linzhixiao1996@gmail.com>
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ resolver = "2"
[profile.release]
#panic = "abort"
lto = true

[patch.crates-io]
vm-memory = { path = "third_party/vm-memory" }
58 changes: 44 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# libkrun

```libkrun``` is a dynamic library that allows programs to easily acquire the ability to run processes in a partially isolated environment using [KVM](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt) Virtualization on Linux and [HVF](https://developer.apple.com/documentation/hypervisor) on macOS/ARM64.
```libkrun``` is a dynamic library that allows programs to easily acquire the ability to run processes in a partially isolated environment using [KVM](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt) Virtualization on Linux, [HVF](https://developer.apple.com/documentation/hypervisor) on macOS/ARM64, and [WHPX](https://learn.microsoft.com/en-us/virtualization/api/) on Windows x86_64.

It integrates a VMM (Virtual Machine Monitor, the userspace side of an Hypervisor) with the minimum amount of emulated devices required to its purpose, abstracting most of the complexity that comes from Virtual Machine management, offering users a simple C API.

Expand Down Expand Up @@ -44,7 +44,7 @@ Each variant generates a dynamic library with a different name (and ```soname```

## Virtio device support

### All variants
### Linux and macOS

* virtio-console
* virtio-block
Expand All @@ -56,6 +56,15 @@ Each variant generates a dynamic library with a different name (and ```soname```
* virtio-rng
* virtio-snd

### Windows (x86_64)

* virtio-console
* virtio-block
* virtio-net (via TcpStream backend)
* virtio-vsock (via Named Pipe backend; no TSI; DGRAM support)
* virtio-balloon (free-page reporting)
* virtio-rng

## Networking

In ```libkrun```, networking is provided by two different, mutually exclusive techniques: **virtio-vsock + TSI** and **virtio-net + passt/gvproxy**.
Expand Down Expand Up @@ -225,25 +234,46 @@ A suitable sysroot is automatically generated by the Makefile from Debian reposi
sudo make [FEATURE_OPTIONS] install
```

### Windows (Experimental)
- Windows 10 2004+ or Windows 11
- Hyper-V enabled
- WinHvPlatform API support
- Architectures: x86_64, aarch64
### Windows (x86_64, Experimental)

### Building for Windows
> **Status**: Early development. Linux kernels boot through early console output. Full
> userspace boot is not yet supported (interrupt injection is not yet implemented).

Cross-compile from Linux/macOS:
```bash
cargo build --target x86_64-pc-windows-msvc --release
cargo build --target aarch64-pc-windows-msvc --release
#### Requirements

* Windows 10 version 2004 or later, or Windows 11
* **Windows Hypervisor Platform** enabled (Settings → Optional Features, or `DISM /Online /Enable-Feature /FeatureName:HypervisorPlatform`)
* A working [Rust](https://www.rust-lang.org/) toolchain with the `x86_64-pc-windows-msvc` target (`rustup target add x86_64-pc-windows-msvc`)
* MSVC build tools (Visual Studio Build Tools 2019 or later)

#### Compiling

```powershell
cargo build -p libkrun --target x86_64-pc-windows-msvc --release
```

Native build on Windows:
#### Running smoke tests

```powershell
cargo build --release
# Requires Windows Hypervisor Platform; must use --test-threads=1
cargo test -p vmm --target x86_64-pc-windows-msvc --lib -- test_whpx_ --ignored --test-threads=1
```

#### API differences from Linux/macOS

| API | Windows equivalent |
|-----|--------------------|
| `krun_add_net_unixstream` | `krun_add_net` (TcpStream address) |
| `krun_add_vsock_port` | `krun_add_vsock_port_windows` (Named Pipe name) |
| `krun_add_disk` | same |

#### Known limitations

* x86_64 only (no ARM64/WHPX support on Windows)
* virtio-fs, virtio-gpu, and virtio-snd are not supported
* TSI (Transparent Socket Impersonation) is not supported; vsock uses Windows Named Pipes
* No interrupt injection yet — guest kernel stalls after early boot output

## Using the library

Despite being written in Rust, this library provides a simple C API defined in [include/libkrun.h](include/libkrun.h)
Expand Down
Loading
Loading