Skip to content

Commit 6aebdfa

Browse files
committed
fix unclean stop for vz driver
Signed-off-by: Balaji Vijayakumar <[email protected]>
1 parent e4ede4f commit 6aebdfa

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

pkg/vz/vz_driver_darwin.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"errors"
99
"fmt"
1010
"path/filepath"
11+
"time"
1112

1213
"github.com/lima-vm/lima/pkg/reflectutil"
1314

@@ -121,10 +122,27 @@ func (l *LimaVzDriver) Start(ctx context.Context) (chan error, error) {
121122

122123
func (l *LimaVzDriver) Stop(_ context.Context) error {
123124
logrus.Info("Shutting down VZ")
124-
canStop := l.machine.CanStop()
125+
canStop := l.machine.CanRequestStop()
126+
125127
if canStop {
126-
return l.machine.Stop()
128+
_, err := l.machine.RequestStop()
129+
if err != nil {
130+
return err
131+
}
132+
133+
timeout := time.After(5 * time.Second)
134+
tick := time.Tick(500 * time.Millisecond)
135+
for {
136+
select {
137+
case <-timeout:
138+
return errors.New("vz timeout while waiting for stop status")
139+
case <-tick:
140+
if l.machine.State() == vz.VirtualMachineStateStopped {
141+
return nil
142+
}
143+
}
144+
}
127145
}
128146

129-
return nil
147+
return errors.New("VZ CanRequestStop is not supported")
130148
}

0 commit comments

Comments
 (0)