feat(shim): containerd Runtime v2 shim for k8s RuntimeClass and docker - #10
Merged
Merged
Conversation
lizhicui
force-pushed
the
feat-pvisor-containerd-shim
branch
from
September 30, 2026 11:35
93c06e0 to
b7cfc49
Compare
First milestone of the pVisor containerd Runtime v2 shim: the host process path. New crate crates/persisting-shim with the ttrpc task service, a two-phase init pipeline (namespaces, rootfs mounts, pivot_root), bundle FIFO stdio, task events, and a cgroup v2 subset.
lizhicui
force-pushed
the
feat-pvisor-containerd-shim
branch
from
September 30, 2026 11:36
b7cfc49 to
2d99fd1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
persisting-shim, a containerd Runtime v2 shim (io.containerd.pvisor.v2, binarycontainerd-shim-pvisor-v2) that exposes pVisor as a Kubernetes RuntimeClass (handler: pvisor) and a Docker runtime (--runtime=pvisor), as a new crate without touching the existing product surfaceCreatebuilds a plan from the OCI config plus the CreateTaskRequest mounts and re-executes the shim binary as an internal parent that enters namespaces, materializes the snapshotter rootfs, forks the init process, and releases it to pivot root and exec the workload onStartsandboxer = "shim": a dedicated bootstrap serves the task and sandbox services on one socket, a long-lived holder process replaces the pause container (joins the CRI pod network namespace, creates uts/ipc namespaces, optional pid sharing), and member containers join the holder's namespaces through the namespace paths in their specsvmcargo feature: annotation-routed tasks (io.pvisor.executor=vm) boot one VM per task with a virtio-fs rootfs, virtio-console IO, the implicit vsock disabled, and exec-in-VM through a vsock guest agent whose binary is injected into the rootfs at bootargv[0], shutdown/delete response ordering, TaskExit container-id semantics required by moby, CLOEXEC clearing for descriptors that cross the self-exec boundary, and namespace joins by path for pod containersValidation
cargo fmt --all -- --checkpasses;cargo clippy -p persisting-shim --all-targetsis warning-clean on the host and on thex86_64-unknown-linux-gnutarget; the shim unit suite (39 tests) passes viacargo nextest run --locked -p persisting-shimx86_64-unknown-linux-muslwith cargo-zigbuild, both default and--features vm(the VM build yields a ~4 MB static binary)ctr runcovered the full lifecycle including exit-code propagation, signals, and deletion;docker run --runtime=pvisorcovered attached runs, exit codes,docker exec, piped stdin with EOF, and stop semantics that match runc for PID-1 processes without SIGTERM handlerssandboxer = "shim":crictl runp --runtime=pvisorreached Ready, a pod container shared the holder's network/uts/pid namespaces (verified by comparing namespace inodes),crictl execworked, and the container completed a Running→Exited cycle-tstill reports "not a tty" inside the container: the PTY is allocated in the host namespace and the container's devpts instance does not contain the slave; the fix needs PTY allocation inside the container's mount namespace and is left out/dev/kvm, so VM workloads, the vsock agent, and exec-in-VM were not exercised on real hardware; pod-level VM sandboxes return a clear not-implemented error pointing at per-container VMs, and bind mounts and cgroup limits are not mapped into VMs yet