From 2ff43429f7a3a4b67e01f459dbaea1443a703daf Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Tue, 26 Sep 2023 15:28:05 -0500 Subject: [PATCH] applehv: machine tests for stop and rm change behaviour of stopped a stopped/exited machine to match qemu in that stopping a stopped machine is NOT an error. add condition to machine rm where rm is not run twice due to a logic error [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude --- pkg/machine/applehv/machine.go | 2 +- pkg/machine/applehv/rest.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/machine/applehv/machine.go b/pkg/machine/applehv/machine.go index d91c602fb0..1e4c340f67 100644 --- a/pkg/machine/applehv/machine.go +++ b/pkg/machine/applehv/machine.go @@ -681,7 +681,7 @@ func (m *MacMachine) Stop(name string, opts machine.StopOptions) error { } if vmState != machine.Running { - return machine.ErrWrongState + return nil } defer func() { diff --git a/pkg/machine/applehv/rest.go b/pkg/machine/applehv/rest.go index 4cb0a92dd5..a96834541f 100644 --- a/pkg/machine/applehv/rest.go +++ b/pkg/machine/applehv/rest.go @@ -94,9 +94,10 @@ func (vf *VfkitHelper) stop(force, wait bool) error { if err := vf.stateChange(define.HardStop); err != nil { return err } - } - if err := vf.stateChange(define.Stop); err != nil { - return err + } else { + if err := vf.stateChange(define.Stop); err != nil { + return err + } } if !wait { return nil