mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
runtime: sending SIGKILL to qemu
There is a race condition when virtiofsd is killed without finishing all the clients. Because of that, when a pod is stopped, QEMU detects virtiofsd is gone, which is legitimate. Sending a SIGTERM first before killing could introduce some latency during the shutdown. Fixes #6757. Signed-off-by: Beraldo Leal <bleal@redhat.com>
This commit is contained in:
parent
7c9faab523
commit
0e47cfc4c7
@ -1122,22 +1122,21 @@ func (q *qemu) StopVM(ctx context.Context, waitOnly bool) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pids := q.GetPids()
|
||||||
|
if len(pids) == 0 {
|
||||||
|
return errors.New("cannot determine QEMU PID")
|
||||||
|
}
|
||||||
|
pid := pids[0]
|
||||||
|
|
||||||
if waitOnly {
|
if waitOnly {
|
||||||
pids := q.GetPids()
|
|
||||||
if len(pids) == 0 {
|
|
||||||
return errors.New("cannot determine QEMU PID")
|
|
||||||
}
|
|
||||||
|
|
||||||
pid := pids[0]
|
|
||||||
|
|
||||||
err := utils.WaitLocalProcess(pid, qemuStopSandboxTimeoutSecs, syscall.Signal(0), q.Logger())
|
err := utils.WaitLocalProcess(pid, qemuStopSandboxTimeoutSecs, syscall.Signal(0), q.Logger())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err := q.qmpMonitorCh.qmp.ExecuteQuit(q.qmpMonitorCh.ctx)
|
err = syscall.Kill(pid, syscall.SIGKILL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.Logger().WithError(err).Error("Fail to execute qmp QUIT")
|
q.Logger().WithError(err).Error("Fail to send SIGKILL to qemu")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user