Repository navigation
Description
Motivation
propolis currently only runs on Linux (KVM) and macOS (Hypervisor.framework) via libkrun. There is no Windows support. This issue tracks adding a Hyper-V backend to enable running OCI container images as microVMs on Windows.
Depends on: #1 (hypervisor abstraction layer)
Background
Why Hyper-V?
- Native Windows hypervisor — ships with Windows 10/11 Pro and Server editions
- HCS (Host Compute Service) — well-maintained Go bindings via
hcsshim, used by Docker Desktop and containerd - LCOW support — HCS natively supports Linux Containers on Windows (running Linux guests on Hyper-V)
- No CGO required — hcsshim is pure Go, unlike the libkrun backend
Alternatives considered
| Alternative | Why not |
|---|---|
| Hyperlight | No OS in guest, no filesystem, no networking, no OCI support, no Go SDK. Fundamentally different execution model (function sandbox, not container VM). |
| QEMU + WHPX | Too heavyweight. Full device emulation stack adds significant complexity and binary size. |
| WSL2 + KVM | KVM support in WSL2 is unreliable — works in some WSL versions, regressed in others. Not shippable. |
| Firecracker | Linux/KVM only, no Windows support. |
Proposed Implementation
Backend: hypervisor/hyperv/
Implements the hypervisor.Backend interface from #1:
//go:build windows
type Backend struct {
// KernelPath is the path to the Linux kernel to boot.
KernelPath string
// InitRDPath is the optional path to an initrd image.
InitRDPath string
}
func (b *Backend) Name() string { return "hyperv" }
func (b *Backend) PrepareRootFS(ctx context.Context, rootfsPath string, initCfg InitConfig) (string, error) {
// 1. Write /.propolis_init.json to rootfs (generic init config)
// 2. Convert flat rootfs directory to VHDX disk image
// 3. Return path to VHDX
}
func (b *Backend) Start(ctx context.Context, cfg VMConfig) (VMHandle, error) {
// 1. Create LCOW utility VM via hcsshim
// 2. Attach root VHDX
// 3. Configure networking (hvsock transport)
// 4. Add filesystem mounts (Plan 9 shares)
// 5. Start VM
// 6. Return hcsHandle wrapping uvm.UtilityVM
}Key components
Rootfs → VHDX conversion
The OCI image extraction pipeline produces a flat directory. Hyper-V needs a VHDX disk image. Options to investigate:
virtdisk.dllWindows API (CreateVirtualDisk, AttachVirtualDisk)- hcsshim's internal LCOW layer utilities
diskpart/Convert-VHDPowerShell (fragile, last resort)
Networking: gvisor-tap-vsock over hvsock
gvisor-tap-vsock already supports Hyper-V socket transport (AF_HYPERV). The same virtual network stack used by libkrun's in-process networking can be reused with a different transport:
- libkrun:
AcceptQemu()over Unix socketpair - Hyper-V:
AcceptHyperV()over hvsock
The NetEndpoint type from #1 carries the transport info:
NetEndpoint{Type: NetEndpointHVSocket, Path: serviceGUID}Guest init
libkrun reads /.krun_config.json via its built-in init. Hyper-V needs a different mechanism:
- Write
/.propolis_init.jsonwith the same schema ({cmd, env, working_dir}) - Extend the
guest/bootpackage to read this config and exec the workload - Or use a minimal custom init binary in the initrd
Linux kernel
Unlike libkrun (which bundles a kernel in libkrunfw), Hyper-V requires a separate kernel image. Options:
- Bundle a kernel build (like Docker Desktop uses LinuxKit)
- Build a custom minimal kernel with virtio + 9p + ext4
- Let users provide their own via
Backend.KernelPath
Platform-specific files needed
| File | Purpose |
|---|---|
hypervisor/hyperv/backend.go |
Backend implementation via hcsshim |
hypervisor/hyperv/handle.go |
VMHandle wrapping uvm.UtilityVM |
hypervisor/hyperv/vhd.go |
Rootfs dir → VHDX conversion |
hypervisor/default_windows.go |
DefaultBackendName = "hyperv" |
preflight/hyperv_windows.go |
Check Hyper-V is enabled |
preflight/resources_windows.go |
Disk/CPU/RAM checks |
internal/procutil/process_windows.go |
Process identification via QueryFullProcessImageName |
extract/libname_windows.go |
.dll naming convention |
VM lifecycle
Unlike libkrun (where krun_start_enter() takes over the process and never returns), Hyper-V manages VM lifecycle via API calls:
type hcsHandle struct {
vm *uvm.UtilityVM
}
func (h *hcsHandle) Stop(ctx context.Context) error {
// Graceful: vm.Shutdown()
// Force: vm.Terminate()
// Cleanup: vm.Close()
}
func (h *hcsHandle) IsAlive() bool { return h.vm.State() == StateRunning }
func (h *hcsHandle) ID() string { return h.vm.ID() }No two-process model needed. No signals. No Setsid. Pure API-driven lifecycle.
Open Questions
- Kernel bundling: LinuxKit kernel? Custom minimal build? User-provided? What's the right default for a library?
- VHD creation: Which Windows API is most reliable for creating ext4-formatted VHDX from a directory tree?
- Guest init: Extend
guest/bootpackage, or build a separate init binary for Hyper-V guests? - CI/CD: How to test? Windows runners with nested virtualization? Mock HCS interfaces? Integration test matrix?
- hvsock vs named pipe: Which transport for gvisor-tap-vsock? hvsock is more natural for Hyper-V, named pipes are simpler.
- Hyper-V editions: Require Pro/Enterprise (full Hyper-V) or also support Home (limited WHP)?
- Filesystem mounts: Plan 9 shares via hcsshim, or alternative mechanism?
Implementation phases
- Introduce hypervisor.Backend abstraction layer #1 must land first — the abstraction layer
- Windows platform files — preflight, procutil, extract, default backend (can be done in parallel with 3)
- Hyper-V backend — hcsshim integration, VHD creation, hvsock networking
- Guest init — extend guest/boot or build custom init for non-libkrun backends
- Kernel packaging — decide on and implement kernel bundling strategy
- CI — Windows test infrastructure
Activity
thejoeejoee commentedon Nov 10, 2026
Feasibility & Technical Analysis against current
main(a0df24a)With #1 (
hypervisor.Backendabstraction) merged, we analyzed what it would take to implement the Hyper-V backend on top of currentstacklok/go-microvmmain.Overall: feasible, and
CGO_ENABLED=0on Windows can be preserved, but several interfaces and assumptions have evolved since this issue was drafted, and there are three key architectural gaps (hcsshim/internal/uvmvisibility, guest-sideAF_HYPERV↔ NIC bridging, and NTFS UID/GID loss during rootfs extraction) that affect the design.1. Drift between the issue proposal and current
mainhypervisor.Backend&VMConfighave grown (hypervisor/backend.go:11-64)VMConfignow includesDisks []Disk,VsockPorts []VsockPort,LogLevel uint32, andFilesystemMount.{ReadOnly, SimplifiedOwnership}.NetEndpointType(hypervisor/backend.go:72-83) already definesNetEndpointNone,NetEndpointUnixSocket,NetEndpointNamedPipe, andNetEndpointHVSocket.PrepareRootFSpath containment check (microvm.go:251-261,vm.go:155)microvm.govalidates that the path returned bybackend.PrepareRootFS(ctx, rootfs.Path, initCfg)satisfiesisWithin(rootfs.Path, preparedPath) || preparedPath == rootfs.Path."backend returned rootfs path outside original". EitherPrepareRootFSmust writerootfs.vhdinsiderootfs.Path(e.g.filepath.Join(rootfsPath, "rootfs.vhd")), or returnrootfsPathand keep the VHD at a deterministic subpath consumed byStart().microvm.go:243-244)hypervisor/default_*.godoes not exist yet;microvm.go:244callslibkrun.NewBackend()directly whencfg.backend == nil. Moving this to build-taggeddefaultBackend()helpers decouplesmicrovm.gofromhypervisor/libkrunon Windows.NetEndpointconstruction inmicrovm.go(microvm.go:318-320) andnet.Provider(net/provider.go)net.Providercurrently exposesSocketPath() stringandmicrovm.go:318hardcodesType: hypervisor.NetEndpointUnixSocket. To supportNetEndpointHVSocket,net.Providerneeds an endpoint descriptor (orNetEndpointmethod) rather than assuming a Unix domain socket path.2. Three Architectural Blockers to Address in the Design
A.
hcsshim'suvmpackage isinternal/(cannot be imported)The issue sketches
uvm.CreateLCOWand*uvm.UtilityVM, which live undergithub.com/Microsoft/hcsshim/internal/uvm(internal/uvm/create_lcow.go). Go forbids importinginternal/packages across module boundaries.github.com/Microsoft/hcsshim/hcspackage (hcs.CreateComputeSystem,hcs.OpenComputeSystem,*hcs.System) with an HCS Schema v2 (hcsshim/internal/schema2or a minimal local struct)ComputeSystemJSON document declaringVirtualMachine(ComputeTopology,Devices.{Scsi, HvSocket, Plan9}, andGuestOs/LinuxKernelFile+InitrdFile). This stays 100% pure Go (vmcompute.dllviagolang.org/x/sys/windowslazy proc).B. Guest Networking:
AF_HYPERVdoes not create a guest NIC (eth0)In the
libkrunbackend,libkrunemulates avirtio-netdevice (eth0in the guest) backed by the host Unix socket connected togvisor-tap-vsock.HvSocket(AF_VSOCK/hv_sockinside the Linux guest) is a stream socket, not a network interface—the guest kernel has noeth0, soguest/netcfg.Configure(guest/netcfg/netcfg.go:22, which configureseth0via netlink) will fail unless a virtual interface is created.gvisor-tap-vsockv0.9.0 does not have anAcceptHyperV()method onvirtualnetwork.VirtualNetwork. It exposesAcceptQemu(ctx, net.Conn)(4-byte big-endian length-prefixed L2 frames over anyio.ReadWriteCloser/net.Conn, used bynet/hosted/provider.go:294,299).net/hosted/provider.go): Listen onAF_HYPERVusinggithub.com/linuxkit/virtsock/pkg/hvsock(already an indirect dependency ingo.modviagvisor-tap-vsock) and pass acceptednet.Connconnections into the existingvn.AcceptQemu(bgCtx, conn)path.TAPinterface namedeth0, dial the hostAF_VSOCK(hv_sock) service port/GUID, and bridge L2 frames with the 4-byte length prefix (QemuProtocol) betweeneth0and the vsock stream beforenetcfg.Configureruns.C. NTFS loses POSIX UID/GID/mode/xattrs if RootFS is extracted to a host directory first
Currently,
image/extracts OCI layers into host directories and usesinternal/xattr(override_other.gois a no-op on Windows) androotfs/clone.go(os.Lchown,syscall.Stat_t) to preserve ownership/permissions. Extracting to an NTFS directory and then converting that directory to VHDX loses Linux UIDs, GIDs, symlink semantics, andsetuidbits.github.com/Microsoft/hcsshim/ext4/tar2ext4(public, pure Go, no CGO, novirtdisk.dllor host disk mounting required).tar2ext4.ConvertTarToExt4(r, w, tar2ext4.ConvertWhiteout, tar2ext4.AppendVhdFooter)converts an OCI layer/merged tar stream directly into an ext4 filesystem image with a fixed VHD footer while preserving full POSIX UID/GID, permissions, xattrs, and.wh.whiteouts without touching NTFS metadata.3. Exact
GOOS=windows CGO_ENABLED=0Compile AuditTesting
GOOS=windows CGO_ENABLED=0 go build ./...againstmain(a0df24a) shows:Already compiling cleanly on Windows:
hypervisor,net,net/hosted,net/egress,virtiofs(prepare_other.go),internal/xattr(override_other.go),internal/procutil,ssh,state,guest/env,guest/vmconfig.Files failing compilation on Windows and required fixes:
GOOS=windowsinternal/pathutil/mode.go:53,private.go:107syscall.Stat_tundefinedmode_unix.go/mode_windows.goandprivate_unix.go/private_windows.goextract/libname.go:9libNameundefined (only_darwin/_linux)extract/libname_windows.go(or build-tagextractto!windowsif only used bylibkrun)preflight/checker.go:61registerPlatformChecksundefinedpreflight/platform_windows.go(hyperv_windows.go+resources_windows.go)rootfs/clone.go:136,143,266cloneFileandfileOwneronly inclone_{darwin,linux}.gorootfs/clone_windows.gooptions.go:197(microvm.go:497,514)syscall.Killundefined on WindowskillProcessinto build-taggedprocess_unix.go/process_windows.gorunner/spawn.go:44,117,191&hypervisor/libkrunsyscall.Kill,SysProcAttr.Setsid,isExpectedProcessrunner/andhypervisor/libkrun/with//go:build !windows(orlinux || darwin) and split default backend selection inmicrovm.go:2444. Answers & Recommendations for the 7 Open Questions
libkrunfw(versions.env:LIBKRUNFW_VERSION=v5.6.2, built inimages/builder/Containerfile:30-33).CONFIG_HYPERV,hv_vmbus,hv_storvsc,hv_sock,hv_utils,9pnet_virtio/9p,ext4, andtun.WithKernelPath/WithInitrdPathoption onhyperv.Backendfirst, and add an LCOW kernel + minimal initrd target toimages/builder/Containerfile(or fetch LinuxKit's LCOW kernel release artifact into the cache directory) in Phase 5.github.com/Microsoft/hcsshim/ext4/tar2ext4withtar2ext4.AppendVhdFooterto produce a fixed.vhdin pure Go. Avoidvirtdisk.dll(AttachVirtualDisk) for rootfs preparation because mounting virtual disks on the Windows host requires elevation and loses POSIX metadata on NTFS.guest/bootvs separate init):guest/boot.Run()(guest/boot/boot.go:41) is a library helper that mounts essentials (/proc,/sys,/dev), configureseth0, mounts virtio-fs workspaces, applies sysctls/seccomp/cap-drop, and starts optionalsshd—it does not read/.krun_config.jsonorexecthe workload (libkrun's built-ininit.krundoes that).guest/mount/mount.go:105hardcodes fstype"virtiofs"."virtiofs"vs"9p") toguest/vmconfig(VirtioFSMountInfo) andguest/mount.Workspace.guest/bootmode) for Hyper-V that: (1) mounts essential filesystems, (2) starts thehv_sock↔eth0TAP relay, (3) runsguest/boot.Run(), and (4) reads the init config (Cmd,Env,WorkingDir) andexecs the entrypoint underreaper.windows-latestrunners support nested virtualization / Hyper-V on standard hosted runners when enabled, but start by adding a fastGOOS=windows CGO_ENABLED=0 go build ./...+ unit test job in.github/workflows/ci.yamlso Windows compilation never regresses.AF_HYPERV(hvsock) between guest and host (NetEndpointHVSocket). A Linux guest inside Hyper-V cannot directly dial a Windows host Named Pipe (\\.\pipe\...) withoutHvSocketanyway; HCSHvSocketbridges guestAF_VSOCKdirectly to hostAF_HYPERV.vmcompute.dll+ Linux Utility VMs) requires the Windows Hyper-V platform components (Hyper-V-Hypervisor/VirtualMachinePlatform). Checking for the HCS service (vmcompute) and hypervisor presence inpreflight/hyperv_windows.gogives a clear actionable error when the feature isn't enabled. (Also worth noting: upstreamcontainers/libkrunlists a native Windows WHP backend as upcoming on its roadmap, which could eventually allow thelibkrunbackend itself to work on Windows WHP alongside HCS.)9p) vsvirtio-fsforFilesystemMounts:Plan9(9p2000.Lover VMBus/virtio). Inhyperv.Backend.Start, map eachFilesystemMountto aPlan9share +HvSocketport, and inguest/mount/mount.gomount withfstype="9p"andtrans=virtio,version=9p2000.L,msize=524288(honoringReadOnly). RejectSimplifiedOwnershipandOverrideUID/OverrideGIDon Windows during validation (consistent withmicrovm.go:96). Also note thatWithRootFSShare(microvm.go:179) assumesvirtio-fsand should be rejected byhyperv.Backend.validate().thejoeejoee commentedon Nov 11, 2026
Open questions: HCS backend vs. libkrun on WHP
While working on #173 (HCS v2 backend), libkrun's Windows support kept moving upstream, and I'd like maintainer input before taking the HCS path further.
What changed upstream
containers/libkrunmain(2.0.0-dev) has a WHP backend insrc/whp(latest commits Sep 2026). It also has a Windows virtio-fs passthrough insrc/devices/src/virtio/fs/windows/(commits through Nov 2026), including handling forLinuxSimplifiedFixedOwner. The README still lists Windows as "upcoming".Trade-offs as I see them
HcsGrantVmAccessHypervisorPlatformWindows feature)tar2ext4); POSIX metadata has to be carried through NTFSAF_VSOCK↔ TAP relay, plus hostAF_HYPERVport coordinationAF_UNIXstream sockets work on Windows)hypervisor/libkrunand the guestQuestions
Direction: is HCS still the preferred Windows backend, as Add Hyper-V backend for Windows support #2 originally proposed with hcsshim, or would you rather wait for libkrun on WHP and keep a single backend across all platforms?
Splitting feat(hyperv): add Hyper-V backend and Windows host support #173: would you accept the hypervisor-agnostic part on its own first? That part is:
internal/pathutil,internal/procutil,runner,options,hooks,extract,rootfs)default_backend_{unix,windows}.gonet.EndpointProviderinterfaceThe HCS-specific parts (
hypervisor/hyperv,image/vhd, the Plan9/vsock guest mount, and thehvrelaynetwork relay) would then stay as a draft or experimental PR.Privileges: is an HCS backend that needs admin or Hyper-V Administrators acceptable for go-microvm's consumers? For CLI tools that run as the user, this is a significant UX cost.
Guest artifacts for HCS: if HCS stays, should go-microvm ship its own kernel and initrd? The kernel would need
CONFIG_HYPERV*,HYPERV_VSOCKETS,9P_FS,TUNandEXT4. Or would consumers be expected to bring their own? And is an initrd preferred over injecting/.krun_initinto the VHD?libkrun on Windows: is anyone in contact with the libkrun maintainers about a timeline? Specifically:
unixstreamvsunixgram)go-microvm-runnerprocess model carries over unchangedCI: is a Windows build/vet job (
GOOS=windows CGO_ENABLED=0) acceptable now, so that portability doesn't regress whichever backend is chosen? Is a Windows runner with nested virtualization an option for boot tests later?Windows on ARM64: is it a target? If so, HCS is currently the only option that supports it.