mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-24 14:32:33 +00:00
runtime: Failed to clean up resources when QEMU is terminated by signal 15
When QEMU is terminated by signal 15, it deletes the PidFile. Upon detecting that QEMU has exited, the shim executes the stopVM function. If the PidFile is not found, the PID is set to 0. Subsequently, the shim executes `kill -9 0`, which terminates the current process group. This prevents any further logic from being executed, resulting in resources not being cleaned up. Signed-off-by: wangyaqi54 <wangyaqi54@jd.com>
This commit is contained in:
parent
44bf7ccb46
commit
cf4b81344d
@ -1226,20 +1226,20 @@ func (q *qemu) StopVM(ctx context.Context, waitOnly bool) (err error) {
|
|||||||
return errors.New("cannot determine QEMU PID")
|
return errors.New("cannot determine QEMU PID")
|
||||||
}
|
}
|
||||||
pid := pids[0]
|
pid := pids[0]
|
||||||
|
if pid > 0 {
|
||||||
if waitOnly {
|
if waitOnly {
|
||||||
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 = syscall.Kill(pid, syscall.SIGKILL)
|
err = syscall.Kill(pid, syscall.SIGKILL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.Logger().WithError(err).Error("Fail to send SIGKILL to qemu")
|
q.Logger().WithError(err).Error("Fail to send SIGKILL to qemu")
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if q.config.SharedFS == config.VirtioFS || q.config.SharedFS == config.VirtioFSNydus {
|
if q.config.SharedFS == config.VirtioFS || q.config.SharedFS == config.VirtioFSNydus {
|
||||||
if err := q.stopVirtiofsDaemon(ctx); err != nil {
|
if err := q.stopVirtiofsDaemon(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user