From d671f78952c1b8f62cdc14e02c3362fb02e4e67d Mon Sep 17 00:00:00 2001 From: "fupan.lfp" Date: Wed, 23 Jun 2021 17:47:42 +0800 Subject: [PATCH] agent: fix the issue of convert OCI spec to RPC spec Since the rpc spec used an interface to represen the ErrnoRet, thus the transform function of OCItoGRPC should take care of this case. Depends-on: github.com/kata-containers/tests#3629 Fixes: #1441 Signed-off-by: fupan.lfp --- .../pkg/agent/protocols/grpc/config.json | 3 ++- .../virtcontainers/pkg/agent/protocols/grpc/utils.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/runtime/virtcontainers/pkg/agent/protocols/grpc/config.json b/src/runtime/virtcontainers/pkg/agent/protocols/grpc/config.json index b027e6346d..1bed44ae49 100644 --- a/src/runtime/virtcontainers/pkg/agent/protocols/grpc/config.json +++ b/src/runtime/virtcontainers/pkg/agent/protocols/grpc/config.json @@ -524,7 +524,8 @@ "write", "writev" ], - "action": "SCMP_ACT_ALLOW" + "action": "SCMP_ACT_ALLOW", + "errnoRet": 1008 }, { "names": [ diff --git a/src/runtime/virtcontainers/pkg/agent/protocols/grpc/utils.go b/src/runtime/virtcontainers/pkg/agent/protocols/grpc/utils.go index bcb5201450..4989587d4a 100644 --- a/src/runtime/virtcontainers/pkg/agent/protocols/grpc/utils.go +++ b/src/runtime/virtcontainers/pkg/agent/protocols/grpc/utils.go @@ -53,6 +53,15 @@ func copyValue(to, from reflect.Value) error { return copySliceValue(to, from) case reflect.Map: return copyMapValue(to, from) + case reflect.Interface: + if to.Type().Name() == "isLinuxSyscall_ErrnoRet" { + dest := LinuxSyscall_Errnoret{Errnoret: uint32(from.Uint())} + var destintf isLinuxSyscall_ErrnoRet = &dest + toVal := reflect.ValueOf(destintf) + to.Set(toVal) + return nil + } + return grpcStatus.Errorf(codes.InvalidArgument, "Can not convert %v to %v, kind= %v", from.Type(), to.Type(), toKind) default: // We now are copying non pointers scalar. // This is the leaf of the recursion. @@ -62,7 +71,7 @@ func copyValue(to, from reflect.Value) error { return nil } - return grpcStatus.Errorf(codes.InvalidArgument, "Can not convert %v to %v", from.Type(), to.Type()) + return grpcStatus.Errorf(codes.InvalidArgument, "Can not convert %v to %v, kind= %v", from.Type(), to.Type(), toKind) } to.Set(from)