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

update the variable names of occlum process settings

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