mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
@@ -240,6 +240,9 @@ func loadSpec(cPath string) (spec *specs.Spec, err error) {
|
||||
if err = json.NewDecoder(cf).Decode(&spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = validatePlatform(&spec.Platform); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return spec, validateProcessSpec(&spec.Process)
|
||||
}
|
||||
|
||||
@@ -254,3 +257,13 @@ func createLibContainerRlimit(rlimit specs.Rlimit) (configs.Rlimit, error) {
|
||||
Soft: uint64(rlimit.Soft),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func validatePlatform(platform *specs.Platform) error {
|
||||
if platform.OS != runtime.GOOS {
|
||||
return fmt.Errorf("target os %s mismatch with current os %s", platform.OS, runtime.GOOS)
|
||||
}
|
||||
if platform.Arch != runtime.GOARCH {
|
||||
return fmt.Errorf("target arch %s mismatch with current arch %s", platform.Arch, runtime.GOARCH)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user