diff options
author | Shane Smith <shane.smith@shopify.com> | 2022-06-02 16:31:21 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2022-06-14 16:12:10 -0400 |
commit | 31c3229c9a525002c446b6314c07c5d75256d887 (patch) | |
tree | 14555dbd881921879a78a1a91fc3941b72155ecb /pkg | |
parent | bc8f7b3b430d4c0d89ac02b65ad69a474b01d791 (diff) | |
download | podman-31c3229c9a525002c446b6314c07c5d75256d887.tar.gz podman-31c3229c9a525002c446b6314c07c5d75256d887.tar.bz2 podman-31c3229c9a525002c446b6314c07c5d75256d887.zip |
Prevent simultaneous machine starts
Running `podman machine start` twice at the same time in different
terminals, for example, will make the second invocation fail and the
first one hang.
[NO NEW TESTS NEEDED]
Signed-off-by: Shane Smith <shane.smith@shopify.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/machine/qemu/machine.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index bf724f685..d6048ee15 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -480,6 +480,10 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error { wait = time.Millisecond * 500 ) + if v.Starting { + return fmt.Errorf("machine %q is already in the process of being started", v.Name) + } + v.Starting = true if err := v.writeConfig(); err != nil { return fmt.Errorf("writing JSON file: %w", err) |