Add Kill API for shim service

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang 2017-04-05 08:26:35 +08:00
parent 2048f891d2
commit 6132bec05a
13 changed files with 284 additions and 59 deletions

View file

@ -61,6 +61,10 @@ func (c *client) Resume(ctx context.Context, in *shimapi.ResumeRequest, opts ...
return c.s.Resume(ctx, in)
}
func (c *client) Kill(ctx context.Context, in *shimapi.KillRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
return c.s.Kill(ctx, in)
}
func (c *client) Exit(ctx context.Context, in *shimapi.ExitRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
// don't exit the calling process for the client
// but make sure we unmount the containers rootfs for this client

View file

@ -158,6 +158,12 @@ func (p *initProcess) Resume(context context.Context) error {
return p.runc.Resume(context, p.id)
}
func (p *initProcess) Kill(context context.Context, signal uint32, all bool) error {
return p.runc.Kill(context, p.id, int(signal), &runc.KillOpts{
All: all,
})
}
func (p *initProcess) killAll(context context.Context) error {
return p.runc.Kill(context, p.id, int(syscall.SIGKILL), &runc.KillOpts{
All: true,

View file

@ -217,3 +217,10 @@ func (s *Service) Exit(ctx context.Context, r *shimapi.ExitRequest) (*google_pro
}
return empty, nil
}
func (s *Service) Kill(ctx context.Context, r *shimapi.KillRequest) (*google_protobuf.Empty, error) {
if err := s.initProcess.Kill(ctx, r.Signal, r.All); err != nil {
return nil, err
}
return empty, nil
}