diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-05-15 15:01:02 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-05-19 09:39:47 +0000 |
| commit | 27f689959decd391b047c8034d481267d500549e (patch) | |
| tree | 79ce6364d592fd6841e25ec64ca645fc3c65cdcf /vm/bhyve | |
| parent | 8f9cf946b3733d0b4ad3124bce155a4fc3849c3a (diff) | |
vm: func Run accepts context
It allows to use context as a single termination signal source.
Diffstat (limited to 'vm/bhyve')
| -rw-r--r-- | vm/bhyve/bhyve.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/vm/bhyve/bhyve.go b/vm/bhyve/bhyve.go index 74025e63d..6cccf7a9f 100644 --- a/vm/bhyve/bhyve.go +++ b/vm/bhyve/bhyve.go @@ -4,6 +4,7 @@ package bhyve import ( + "context" "fmt" "io" "os" @@ -324,7 +325,7 @@ func (inst *instance) Copy(hostSrc string) (string, error) { return vmDst, nil } -func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command string) ( +func (inst *instance) Run(ctx context.Context, command string) ( <-chan []byte, <-chan error, error) { rpipe, wpipe, err := osutil.LongPipe() if err != nil { @@ -360,9 +361,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin go func() { select { - case <-time.After(timeout): - signal(vmimpl.ErrTimeout) - case <-stop: + case <-ctx.Done(): signal(vmimpl.ErrTimeout) case err := <-inst.merger.Err: cmd.Process.Kill() |
