Skip to content

Commit 602b455

Browse files
committed
Fix goroutine leak in startVMM
Signed-off-by: Brandon Duffany <[email protected]>
1 parent 4648d28 commit 602b455

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

machine.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,10 +613,16 @@ func (m *Machine) startVMM(ctx context.Context) error {
613613
return err
614614
}
615615

616-
// This goroutine is used to kill the process by context cancelletion,
616+
// This goroutine is used to kill the process by context cancellation,
617617
// but doesn't tell anyone about that.
618618
go func() {
619-
<-ctx.Done()
619+
select {
620+
case <-ctx.Done():
621+
break
622+
case <-m.exitCh:
623+
// VMM exited on its own; no need to stop it.
624+
return
625+
}
620626
err := m.stopVMM()
621627
if err != nil {
622628
m.logger.WithError(err).Errorf("failed to stop vm %q", m.Cfg.VMID)

0 commit comments

Comments
 (0)