HyperV: wait on stop

When using podman machine with hyperv, stop was releasing the terminal
back top the user prematurely.  This resulted in users being able to run
subsequent commands while the vm was still stopped.  Commands like
machine stop were prone to failing.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2023-04-17 16:24:04 -05:00
parent e7b9ae4f3b
commit 4b8230119e
6 changed files with 20 additions and 10 deletions

View File

@@ -239,6 +239,17 @@ func (vm *VirtualMachine) Stop() error {
return translateShutdownError(int(res))
}
// Wait for vm to actually *be* down
for i := 0; i < 25; i++ {
refreshVM, err := vm.vmm.GetMachine(vm.ElementName)
if err != nil {
return err
}
if refreshVM.State() == Disabled {
break
}
time.Sleep(50 * time.Millisecond)
}
return nil
}