mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-22 05:28:25 +00:00
runtime: make StopVM thread-safe
StopVM can be invoked by multiple threads and needs to be thread-safe Fixes: #5155 Signed-off-by: Feng Wang <feng.wang@databricks.com>
This commit is contained in:
parent
c3015927a3
commit
5cafe21770
@ -110,6 +110,8 @@ type qemu struct {
|
|||||||
nvdimmCount int
|
nvdimmCount int
|
||||||
|
|
||||||
stopped bool
|
stopped bool
|
||||||
|
|
||||||
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -968,6 +970,8 @@ func (q *qemu) waitVM(ctx context.Context, timeout int) error {
|
|||||||
|
|
||||||
// StopVM will stop the Sandbox's VM.
|
// StopVM will stop the Sandbox's VM.
|
||||||
func (q *qemu) StopVM(ctx context.Context, waitOnly bool) error {
|
func (q *qemu) StopVM(ctx context.Context, waitOnly bool) error {
|
||||||
|
q.mu.Lock()
|
||||||
|
defer q.mu.Unlock()
|
||||||
span, _ := katatrace.Trace(ctx, q.Logger(), "StopVM", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
span, _ := katatrace.Trace(ctx, q.Logger(), "StopVM", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user