Commit acdc1a0
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
File tree
- .github/workflows
- crates/openshell-driver-vm
- goshim
- src
- deploy/docker
- scripts
- tasks/scripts/vm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
171 | | - | |
| 177 | + | |
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
| |||
0 commit comments