specgen,wasm: switch to crun-wasm wherever applicable

Whenever image has `arch` and `os` configured for `wasm/wasi` switch to
`crun-wasm` as extension if applicable, following will only work if
`podman` is using `crun` as default runtime.

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]
A test for this can be added when `crun-wasm` is part of CI.

Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
Aditya R 2022-11-07 23:24:51 +05:30
parent 2b4068a039
commit f6da2b0608
No known key found for this signature in database
GPG Key ID: 8E5A8A19DF7C8673
2 changed files with 21 additions and 0 deletions

View File

@ -142,6 +142,17 @@ func WithOCIRuntime(runtime string) RuntimeOption {
} }
} }
// WithCtrOCIRuntime specifies an OCI runtime in container's config.
func WithCtrOCIRuntime(runtime string) CtrCreateOption {
return func(ctr *Container) error {
if ctr.valid {
return define.ErrCtrFinalized
}
ctr.config.OCIRuntime = runtime
return nil
}
}
// WithConmonPath specifies the path to the conmon binary which manages the // WithConmonPath specifies the path to the conmon binary which manages the
// runtime. // runtime.
func WithConmonPath(path string) RuntimeOption { func WithConmonPath(path string) RuntimeOption {

View File

@ -122,6 +122,16 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
if imageData != nil {
ociRuntimeVariant := rtc.Engine.ImagePlatformToRuntime(imageData.Os, imageData.Architecture)
// Don't unnecessarily set and invoke additional libpod
// option if OCI runtime is still default.
if ociRuntimeVariant != rtc.Engine.OCIRuntime {
options = append(options, libpod.WithCtrOCIRuntime(ociRuntimeVariant))
}
}
if newImage != nil { if newImage != nil {
// If the input name changed, we could properly resolve the // If the input name changed, we could properly resolve the
// image. Otherwise, it must have been an ID where we're // image. Otherwise, it must have been an ID where we're