diff --git a/pkg/sentry/kernel/task_block.go b/pkg/sentry/kernel/task_block.go index 45d28d363..7b2413140 100644 --- a/pkg/sentry/kernel/task_block.go +++ b/pkg/sentry/kernel/task_block.go @@ -189,6 +189,7 @@ func (t *Task) block(C <-chan struct{}, timerChan <-chan struct{}) error { // prepareSleep prepares to sleep. func (t *Task) prepareSleep() { t.assertTaskGoroutine() + t.p.PrepareSleep() t.Deactivate() t.accountTaskGoroutineEnter(TaskGoroutineBlockedInterruptible) } diff --git a/pkg/sentry/platform/kvm/context.go b/pkg/sentry/platform/kvm/context.go index ed7564a20..81904e874 100644 --- a/pkg/sentry/platform/kvm/context.go +++ b/pkg/sentry/platform/kvm/context.go @@ -126,3 +126,6 @@ func (c *context) FullStateChanged() {} // PullFullState implements platform.Context.PullFullState. func (c *context) PullFullState(as platform.AddressSpace, ac *arch.Context64) {} + +// PrepareSleep implements platform.Context.platform.Context. +func (*context) PrepareSleep() {} diff --git a/pkg/sentry/platform/platform.go b/pkg/sentry/platform/platform.go index c1d971e3a..fc4e0b9cc 100644 --- a/pkg/sentry/platform/platform.go +++ b/pkg/sentry/platform/platform.go @@ -244,6 +244,10 @@ type Context interface { // Release() releases any resources associated with this context. Release() + + // PrepareSleep() is called when the tread switches to the + // interruptible sleep state. + PrepareSleep() } var ( diff --git a/pkg/sentry/platform/ptrace/ptrace.go b/pkg/sentry/platform/ptrace/ptrace.go index 176f7e46b..4286518e0 100644 --- a/pkg/sentry/platform/ptrace/ptrace.go +++ b/pkg/sentry/platform/ptrace/ptrace.go @@ -199,6 +199,9 @@ func (c *context) FullStateChanged() {} // PullFullState implements platform.Context.PullFullState. func (c *context) PullFullState(as platform.AddressSpace, ac *arch.Context64) {} +// PrepareSleep implements platform.Context.platform.PrepareSleep. +func (*context) PrepareSleep() {} + // PTrace represents a collection of ptrace subprocesses. type PTrace struct { platform.MMapMinAddr