Skip to content

Commit acdc1a0

Browse files
committed
refactor(driver-vm): replace OCI registry client with containerd shim
The VM driver's registry image pull and layer-unpack logic was a hand-rolled OCI client (auth, manifest/index parsing, per-layer blob download and digest verification) plus a from-scratch tar-layer merge that only understood plain files, dirs, symlinks, and OCI whiteouts. Replace it with containerd's own Go client libraries (core/remotes/docker for registry resolve/fetch/auth, core/content/local for the content store, pkg/archive for OCI-correct layer application including opaque dirs, xattrs, and device/fifo entries). There is no live containerd daemon involved: the new goshim/ Go module links those packages directly and is built with `go build -buildmode=c-shared` into a small cgo shared library (openshell-containerd-shim), loaded at runtime via libloading the same way this crate already loads libkrun. - crates/openshell-driver-vm/goshim/: the Go module. Exports ContainerdResolveDigest (cheap cache-hit check), ContainerdPullImage (resolve + platform-filtered pull into an OCI Image Layout), and ContainerdUnpackLayout (apply layers onto a directory). - src/containerd_shim.rs: Rust-side dynamic loader and safe wrappers, mirroring ffi.rs's LibKrun pattern. - src/driver.rs: removed parse_registry_reference, registry_client, linux_platform_resolver, registry_auth, pull_registry_image_rootfs, the manual layer-download/whiteout-merge code, and the manual OCI layout writer; both the bootstrap-image and prepared-image pull paths now call into the shim. - build.rs / embedded_runtime.rs: embed the shim's compressed shared library the same way as libkrun/libkrunfw/gvproxy. - tasks/scripts/vm/build-containerd-shim.sh: builds the shim (native or cross via GOOS/GOARCH/CC), wired into `mise run vm:setup`, the Linux CI workflow, and the macOS Docker cross-build (osxcross's oa64-clang cross-compiles the shim too). - Dropped the now-unused oci-client, flate2, and sha2 dependencies. Added `go` to mise.toml/mise.lock (new build-time requirement). Registry auth env vars (OPENSHELL_REGISTRY_USERNAME/_TOKEN) and the GHCR __token__ convenience default are unchanged. Per-layer pull progress events are coarser (one PullingImage event instead of one per layer) since the whole pull now happens inside a single blocking call into the shim. Verified against a real registry (docker.io/library/busybox) through the actual built shared library via Rust libloading, and the macOS cross-build was verified end-to-end with docker buildx (osxcross cross-compiling the shim to a real Mach-O arm64 dylib alongside the Rust binary). Signed-off-by: Eric Curtin <eric.curtin@docker.com>
1 parent 541b97f commit acdc1a0

24 files changed

Lines changed: 1600 additions & 1369 deletions

.github/workflows/driver-vm-linux.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,16 @@ jobs:
165165
OPENSHELL_VM_RUNTIME_COMPRESSED_DIR="${PWD}/target/vm-runtime-compressed" \
166166
tasks/scripts/vm/build-supervisor-bundle.sh --arch "${{ matrix.guest_arch }}"
167167
168+
- name: Build containerd shim
169+
run: |
170+
set -euo pipefail
171+
OPENSHELL_VM_RUNTIME_COMPRESSED_DIR="${PWD}/target/vm-runtime-compressed" \
172+
mise x -- tasks/scripts/vm/build-containerd-shim.sh
173+
168174
- name: Verify embedded driver inputs
169175
run: |
170176
set -euo pipefail
171-
for file in libkrun.so.zst libkrunfw.so.5.zst gvproxy.zst umoci.zst openshell-sandbox.zst; do
177+
for file in libkrun.so.zst libkrunfw.so.5.zst gvproxy.zst umoci.zst openshell-sandbox.zst libopenshell_containerd_shim.so.zst; do
172178
test -s "target/vm-runtime-compressed/${file}"
173179
done
174180

0 commit comments

Comments
 (0)