1
0
mirror of https://github.com/kata-containers/kata-containers.git synced 2025-09-03 01:44:29 +00:00

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: 

Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
This commit is contained in:
fupan.lfp
2021-06-23 17:47:42 +08:00
parent f607641a6e
commit d671f78952
2 changed files with 12 additions and 2 deletions
src/runtime/virtcontainers/pkg/agent/protocols/grpc

@@ -524,7 +524,8 @@
"write",
"writev"
],
"action": "SCMP_ACT_ALLOW"
"action": "SCMP_ACT_ALLOW",
"errnoRet": 1008
},
{
"names": [

@@ -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)