From 90cc8932d223a9683253479543aaf6f1fdc0534c Mon Sep 17 00:00:00 2001 From: jiazhiguang Date: Mon, 31 Aug 2020 17:33:11 +0800 Subject: [PATCH] shim-rune: adapts to occlum 0.15.1 Signed-off-by: Zhiguang Jia --- shim/runtime/carrier/constants/constants.go | 17 ++++++++--------- shim/runtime/carrier/occlum/occlum.go | 4 ++-- shim/runtime/v2/rune/v2/service.go | 13 ++++++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/shim/runtime/carrier/constants/constants.go b/shim/runtime/carrier/constants/constants.go index 45cd11c..62b11b8 100644 --- a/shim/runtime/carrier/constants/constants.go +++ b/shim/runtime/carrier/constants/constants.go @@ -10,7 +10,7 @@ const ( EnclaveTypeKeyName = "ENCLAVE_TYPE" EnclaveRuntimePathKeyName = "ENCLAVE_RUNTIME_PATH" EnclaveRuntimeArgsKeyName = "ENCLAVE_RUNTIME_ARGS" - DefaultEnclaveRuntimeArgs = ".occlum" + DefaultEnclaveRuntimeArgs = "./" ) const ( @@ -140,8 +140,8 @@ function copyOcclumLiberaries() { /bin/cp -f /usr/lib/libsgx_u*.so* ${lib_dir} /bin/cp -f /usr/lib/libsgx_enclave_common.so.1 ${lib_dir} /bin/cp -f /usr/lib/libsgx_launch.so.1 ${lib_dir} - #/bin/cp -f .occlum/build/lib/libocclum-pal.so ${lib_dir}/liberpal-occlum.so - #ln -sfn .occlum/build/lib/libocclum-pal.so liberpal-occlum.so + #/bin/cp -f ./build/lib/libocclum-pal.so ${lib_dir}/liberpal-occlum.so + #ln -sfn ./build/lib/libocclum-pal.so liberpal-occlum.so #chroot ${rootfs} /sbin/ldconfig popd } @@ -169,17 +169,16 @@ function buildUnsignedEnclave(){ /bin/bash ${base_dir}/replace_occlum_image.sh ${rootfs} image # occlum build occlum build - if [ ! -f .occlum/build/lib/libocclum-libos.so ]; then - if [ -f .occlum/build/lib/libocclum-libos.so.0 ]; then - pushd .occlum/build/lib/ + if [ ! -f ./build/lib/libocclum-libos.so ]; then + if [ -f ./build/lib/libocclum-libos.so.0 ]; then + pushd ./build/lib/ ln -s libocclum-libos.so.0 libocclum-libos.so popd fi fi 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} + rm -fr image + /bin/cp -fr . ${rootfs}/${work_dir} popd } diff --git a/shim/runtime/carrier/occlum/occlum.go b/shim/runtime/carrier/occlum/occlum.go index 3878c12..2ba37cf 100644 --- a/shim/runtime/carrier/occlum/occlum.go +++ b/shim/runtime/carrier/occlum/occlum.go @@ -217,7 +217,7 @@ func (c *occlum) BuildUnsignedEnclave(req *task.CreateTaskRequest, args *carrier logrus.Errorf("BuildUnsignedEnclave: exec failed. error: %++v", err) return "", err } - enclavePath := filepath.Join("/", rootfsDirName, c.workDirectory, ".occlum/build/lib/libocclum-libos.so") + enclavePath := filepath.Join("/", rootfsDirName, c.workDirectory, "./build/lib/libocclum-libos.so") return enclavePath, nil } @@ -246,7 +246,7 @@ func (c *occlum) GenerateSigningMaterial(req *task.CreateTaskRequest, args *carr func (c *occlum) CascadeEnclaveSignature(req *task.CreateTaskRequest, args *carrier.CascadeEnclaveSignatureArgs) ( signedEnclave string, err error) { var bufferSize int64 = 1024 * 4 - signedEnclave = filepath.Join("/", rootfsDirName, c.workDirectory, ".occlum/build/lib/libocclum-libos.signed.so") + signedEnclave = filepath.Join("/", rootfsDirName, c.workDirectory, "./build/lib/libocclum-libos.signed.so") publicKey := filepath.Join("/", enclaveDataDir, "public_key.pem") signature := filepath.Join("/", enclaveDataDir, "signature.dat") if err := utils.CopyFile(args.Key, filepath.Join(req.Bundle, publicKey), bufferSize); err != nil { diff --git a/shim/runtime/v2/rune/v2/service.go b/shim/runtime/v2/rune/v2/service.go index 0911479..ba49452 100644 --- a/shim/runtime/v2/rune/v2/service.go +++ b/shim/runtime/v2/rune/v2/service.go @@ -324,9 +324,11 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ * logrus.Infof("CreateTaskRequest: %s", string(data)) container, err := runc.NewContainer(ctx, s.platform, r) - if err != nil { - logrus.Errorf("rune Create NewContainer error: %++v", err) - /*//FIXME debug + + /*if carr.Name() == "occlum" { + //if err != nil { + // logrus.Errorf("rune Create NewContainer error: %++v", err) + //FIXME debug if _, err := os.Stat(r.Bundle); err == nil { path := "/tmp/rune-container-test/runc-rootfs" os.RemoveAll(path) @@ -341,9 +343,10 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ * time.Sleep(time.Minute) } else { logrus.Infof("bundle dir is not exist.", r.Bundle) - }*/ + } return nil, err - } + //} + }*/ data, _ = json.Marshal(container) logrus.Infof("rune.NewContainer success: %s %s", r.ID, string(data)) -- GitLab