From f3cf46a621864fd15bee3019ba956872e022957b Mon Sep 17 00:00:00 2001 From: "fupan.lfp" Date: Thu, 8 Jul 2021 15:39:12 +0800 Subject: [PATCH] shimv2: fix the issue of leaking the hypervisor processes Since we only send an shutdown qmp command to qemu when do stopSandbox, and didn't wait until qemu process's exit, thus we'd better to make sure it had exited when shimv2 terminated. Thus here to do the last cleanup of the hypervisor. Fixes: #2198 Signed-off-by: fupan.lfp --- src/runtime/containerd-shim-v2/service.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/runtime/containerd-shim-v2/service.go b/src/runtime/containerd-shim-v2/service.go index efb5d60ff8..6a57e7e90a 100644 --- a/src/runtime/containerd-shim-v2/service.go +++ b/src/runtime/containerd-shim-v2/service.go @@ -905,6 +905,11 @@ func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (_ * s.cancel() + // Since we only send an shutdown qmp command to qemu when do stopSandbox, and + // didn't wait until qemu process's exit, thus we'd better to make sure it had + // exited when shimv2 terminated. Thus here to do the last cleanup of the hypervisor. + syscall.Kill(int(s.hpid), syscall.SIGKILL) + os.Exit(0) // This will never be called, but this is only there to make sure the