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

View File

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

View File

@ -53,6 +53,15 @@ func copyValue(to, from reflect.Value) error {
return copySliceValue(to, from) return copySliceValue(to, from)
case reflect.Map: case reflect.Map:
return copyMapValue(to, from) 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: default:
// We now are copying non pointers scalar. // We now are copying non pointers scalar.
// This is the leaf of the recursion. // This is the leaf of the recursion.
@ -62,7 +71,7 @@ func copyValue(to, from reflect.Value) error {
return nil 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) to.Set(from)