| 1 | |
| 2 | |
| 3 | @@ -574,7 +574,6 @@ |
| 4 | |
| 5 | func (l *LimaVzDriver) Stop(ctx context.Context) error { |
| 6 | logrus.Info("Shutting down VZ") |
| 7 | - defer l.removePIDFile() |
| 8 | |
| 9 | requested := false |
| 10 | if l.machine.CanRequestStop() { |
| 11 | @@ -599,7 +598,12 @@ |
| 12 | |
| 13 | // The VM is never stopped forcibly with l.machine.Stop(): that does not give the guest |
| 14 | // a chance to stop cleanly, and may corrupt the disk. |
| 15 | - return l.waitForStopped(gracefulStopTimeout) |
| 16 | + if err := l.waitForStopped(gracefulStopTimeout); err != nil { |
| 17 | + // Retain the owner record while the VM may still be running. |
| 18 | + return err |
| 19 | + } |
| 20 | + l.removePIDFile() |
| 21 | + return nil |
| 22 | } |
| 23 | |
| 24 | func (l *LimaVzDriver) waitForStopped(timeout time.Duration) error { |