提交 af5043a0 编写于 作者: J jiazhiguang 提交者: jia zhang

update the variable names of occlum process settings

上级 47579ba0
......@@ -162,7 +162,7 @@ function buildUnsignedEnclave(){
/bin/cp -f ${occlum_config_path} Occlum.json
fi
# set occlum entrypoint
sed -i "s#/bin#${entry_point}#g" Occlum.json
# sed -i "s#/bin#${entry_point}#g" Occlum.json
# generate the configuration file Enclave.xml that used by enclave from Occlum.json
/opt/occlum/build/bin/gen_enclave_conf -i Occlum.json -o Enclave.xml
# build occlum image
......@@ -179,6 +179,7 @@ function buildUnsignedEnclave(){
mkdir -p ${rootfs}/${work_dir} || true
/bin/cp -fr .occlum ${rootfs}/${work_dir}
/bin/cp -f Enclave.xml ${rootfs}/${work_dir}
/bin/cp -f Occlum.json ${rootfs}/${work_dir}
popd
}
......
......@@ -8,16 +8,18 @@ import (
)
const (
EnvUserSpaceSize = "OCCLUM_USER_SPACE_SIZE"
EnvKernelSpaceHeapSize = "OCCLUM_KERNEL_SPACE_HEAP_SIZE"
EnvKernelSpaceStackSize = "OCCLUM_KERNEL_SPACE_STACK_SIZE"
EnvMaxNumOfThreads = "OCCLUM_MAX_NUM_OF_THREADS"
EnvDefaultStackSize = "OCCLUM_DEFAULT_STACK_SIZE"
EnvDefaultHeapSize = "OCCLUM_DEFAULT_HEAP_SIZE"
EnvDefaultMmapSize = "OCCLUM_DEFAULT_MMAP_SIZE"
EnvProductId = "OCCLUM_PRODUCT_ID"
EnvVersionNumber = "OCCLUM_VERSION_NUMBER"
EnvDebuggable = "OCCLUM_DEBUGGABLE"
UserSpaceSize = "OCCLUM_USER_SPACE_SIZE"
KernelSpaceHeapSize = "OCCLUM_KERNEL_SPACE_HEAP_SIZE"
KernelSpaceStackSize = "OCCLUM_KERNEL_SPACE_STACK_SIZE"
MaxNumOfThreads = "OCCLUM_MAX_NUM_OF_THREADS"
ProcessDefaultStackSize = "OCCLUM_PROCESS_DEFAULT_STACK_SIZE"
ProcessDefaultHeapSize = "OCCLUM_PROCESS_DEFAULT_HEAP_SIZE"
ProcessDefaultMmapSize = "OCCLUM_PROCESS_DEFAULT_MMAP_SIZE"
ProductId = "OCCLUM_PRODUCT_ID"
VersionNumber = "OCCLUM_VERSION_NUMBER"
Debuggable = "OCCLUM_DEBUGGABLE"
DefalutEnv = "OCCLUM_DEFAULT_ENV"
UntrustedEnv = "OCCLUM_UNTRUSTED_ENV"
)
type OcclumConfig struct {
......@@ -69,56 +71,70 @@ func (c *OcclumConfig) ApplyEnvs(envs []string) {
k := items[0]
v := items[1]
switch k {
case EnvUserSpaceSize:
case UserSpaceSize:
c.ResourceLimits.UserSpaceSize = v
break
case EnvKernelSpaceHeapSize:
case KernelSpaceHeapSize:
c.ResourceLimits.KernelSpaceHeapSize = v
break
case EnvKernelSpaceStackSize:
case KernelSpaceStackSize:
c.ResourceLimits.KernelSpaceStackSize = v
break
case EnvMaxNumOfThreads:
case MaxNumOfThreads:
i, err := strconv.ParseInt(v, 10, 64)
if err != nil {
logrus.Error("ApplyEnvs: parse environment variable %s failed. error: %++v", k, err)
}
c.ResourceLimits.MaxNumOfThreads = i
break
case EnvDefaultStackSize:
case ProcessDefaultStackSize:
c.Process.DefaultStackSize = v
break
case EnvDefaultHeapSize:
case ProcessDefaultHeapSize:
c.Process.DefaultHeapSize = v
break
case EnvDefaultMmapSize:
case ProcessDefaultMmapSize:
c.Process.DefaultMmapSize = v
break
case EnvProductId:
case ProductId:
i, err := strconv.ParseInt(v, 10, 64)
if err != nil {
logrus.Error("ApplyEnvs: parse environment variable %s failed. error: %++v", k, err)
}
c.Metadata.ProductId = i
break
case EnvVersionNumber:
case VersionNumber:
i, err := strconv.ParseInt(v, 10, 64)
if err != nil {
logrus.Error("ApplyEnvs: parse environment variable %s failed. error: %++v", k, err)
}
c.Metadata.VersionNumber = i
break
case EnvDebuggable:
case Debuggable:
i, err := strconv.ParseBool(v)
if err != nil {
logrus.Error("ApplyEnvs: parse environment variable %s failed. error: %++v", k, err)
}
c.Metadata.Debuggable = i
break
case DefalutEnv:
if len(v) > 0 {
c.Env.Default = strings.Split(v, ",")
}
break
case UntrustedEnv:
if len(v) > 0 {
c.Env.Untrusted = strings.Split(v, ",")
}
break
}
}
}
func (c *OcclumConfig) ApplyEntrypoints(entrypoints []string) {
c.EntryPoints = entrypoints
}
func GetDefaultOcclumConfig() *OcclumConfig {
return &OcclumConfig{
ResourceLimits: ResourceLimits{
......
......@@ -359,6 +359,7 @@ func (o *occlum) saveOcclumConfig(path string) error {
}
cfg := GetDefaultOcclumConfig()
cfg.ApplyEnvs(o.spec.Process.Env)
cfg.ApplyEntrypoints([]string{o.entryPoints[0]})
bytes, err := json.Marshal(cfg)
if err != nil {
return err
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册